In Physics it's common to write matrices in vector components to simplify notation. This commonly occures with the pauli vector $\vec\sigma = \begin{pmatrix}\sigma_1 & \sigma_2 & \sigma_3\end{pmatrix}^\mathrm{T}$

Then the scalar product $\vec \sigma \cdot \vec p$ with any vector p would be $\sigma_1 p_1 + \sigma_2 p_2 + \sigma_3 p_3$.

How would I implement such a product in Mathematica? Sure, I could use something like

paulivector = Table[PauliMatrix[k],{k,1,3}];
vector = {p1,p2,p3};


But this doesn't seem to be the Mathematica way. I tried


which resulted in:

Inner::incom: Length 2 of dimension 3 in {{{0,1},{1,0}},{{0,-I},{I,0}},{{1,0},{0,-1}}} is incommensurate with length 3 of dimension 1 in {px,py,pz}.

Is there a built-in function that I can use for this case?

Related (but 8-9 years old): A matrix-vector cross product


1 Answer 1

σ = Array[PauliMatrix, 3]
(*    {{{0, 1}, {1, 0}},
       {{0, -I}, {I, 0}},
       {{1, 0}, {0, -1}}}    *)

p = {x, y, z};

p . σ
(*    {{z, x - I y},
       {x + I y, -z}}    *)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.