How to recover Pauli matrices properties in Mathematica?



I want to do a cross or dot product involving a vector of Pauli matrices
$ \vec\sigma=(\sigma^1, \sigma^2, \sigma^3) $; for example, $ \vec\sigma\times\vec\sigma=2\mathrm i\vec\sigma $ and $ \vec\sigma\cdot\vec\sigma=3 I_{2\times2} $.

Is there a simple way to do these operations?


Posted 2016-10-27T22:32:23.877

Reputation: 81

Vectors like your $\sigma$ can be mapped to quaternions. You could consider doing this and using the Quaternions package. I'm saying this because implementing the algebraic properties of these matrices is the same as implementing quaternion calculations. Also, we do need a fourth basis vector $I$ as evidenced by your last relationship ($\sigma_i^2 = I$).

– Szabolcs – 2016-10-28T13:51:39.407



The Pauli vector:

σ = Table[PauliMatrix[i], {i, 1, 3}]
MatrixForm /@ σ

enter image description here

One can define a dot product of matrices (in spaces of arbitrary dimension):

dot[a_, b_] := Total @ MapThread[Dot, {a, b}]


dot[σ, σ] // MatrixForm

enter image description here

For the cross product of matrices, I literally took the cross product of vectors

Cross[{a, b, c}, {x, y, z}] /. {Times[A_Symbol, B_Symbol] -> Dot[A, B]}

{b.z - c.y, -a.z + c.x, a.y - b.x}

and redefined it as (in a 3D space)

cross[{a_, b_, c_}, {x_, y_, z_}] := {b.z - c.y, -a.z + c.x, a.y - b.x}

This gives

MatrixForm /@ cross[σ, σ]

enter image description here


cross[σ, σ] == 2 I σ


Because I particularly like the multidimensional cross product of vectors, I'd like to post a few links:


Posted 2016-10-27T22:32:23.877

Reputation: 22 814


There is a function called PauliMatrix. Here is the product of two such matrices:


For example:

PauliMatrix[1].PauliMatrix[1] == PauliMatrix[4]



PauliMatrix[1].PauliMatrix[2] == -PauliMatrix[2].PauliMatrix[1]


bill s

Posted 2016-10-27T22:32:23.877

Reputation: 62 963

2I think the OP wants symbolic results, rather than explicitly specifying the matrices. – QuantumDot – 2016-10-27T22:43:35.213

The Pauli matrices are just particular case of geometric (Clifford) algebra orthonormal base elements. So you need some software of geometric algebra. Till you find better one, can look at my own implementation To mimic Pauli matrices you can use Cl[3,0] algebra (or Cl[2,0], where the role of third matrix is plays a bivector.

– user18792 – 2016-11-04T07:02:35.080


If you want to go the GeometricAlgebra way (as suggested in @user18792 's comment), there is a thread on this: and a slick Paclet based implementation of generalized Geometric Algebra

– Joshua Schrier – 2020-08-04T16:43:21.923



pv = σ /@ Range[3];

Then this verifies $ \vec{\sigma}\cdot\vec{\sigma}=3I $:

(Inner[Dot, pv, pv] /. σ -> PauliMatrix) == 3 IdentityMatrix[2]

And this verifies $ \vec{\sigma}\times\vec{\sigma}=2\mathrm i\vec{\sigma} $:

2 HodgeDual[Outer[f, pv, pv]] // Normal;
(% /. {f -> Dot, σ -> PauliMatrix}) == (2 I pv /. σ -> PauliMatrix)

Αλέξανδρος Ζεγγ

Posted 2016-10-27T22:32:23.877

Reputation: 8 492


Another possibility using FeynCalc 9.3 or above (could be interesting for particle physicists)

CLC[i, j, k] CSI[j].CSI[k] // PauliSimplify[#, PauliReduce -> True] & // FCE
2 I CSI[i]
CSI[i].CSI[i] // PauliSimplify // FCE

CSI is a shortcut for a Cartesian Pauli sigma matrix, while CLC denotes a Cartesian Levi-Civita tensor. PauliSimplify handles simplifications of the Pauli algebra. The option PauliReduce is used to reduce every Pauli chain to at most one Pauli matrix per term. FCE converts the output into a notation that is easier to read (external notation).


Posted 2016-10-27T22:32:23.877

Reputation: 3 088