5
$\begingroup$

Squaring a Pauli matrix results in the identity matrix.

These bits of documentation (weakly, to a Mathematica-newbie like me) imply that some algebraic identities that link the Pauli matrices together are built into Mathematica:

I enter in Mathematica:

PauliMatrix[2]

FullSimplify[PauliMatrix[1] . PauliMatrix[1] . PauliMatrix[2]]

Is there a way of getting the second expression simplified to just PauliMatrix[2] because PauliMatrix[1] . PauliMatrix[1] is the identity matrix?

Mathematica simply prints out the resulting matrices for comparison rather than sticking to the algebra.

I see that someone else is trying to manipulate the Pauli matrices algebraically (for a similar purpose): http://homepage.cem.itesm.mx/lgomez/quantum/v7pauli.pdf (page 2. Setup Pauli Algebra)

... so I imagine that Mathematica doesn't have the behaviour built in?

$\endgroup$
  • $\begingroup$ Mathematica is automatically evaluating PauliMatrix to give you the actual matrix, then doing the calculation. You probably need to be working with objects that you prescribe the rules for. $\endgroup$ – KraZug Jun 18 '15 at 10:30
2
$\begingroup$

Try the following:

SetAttributes[simplifyPM, HoldFirst]

simplifyPM[expression_] := Module[
  {intermediate},
  intermediate = HoldForm[expression] //. PauliMatrix[a_].PauliMatrix[a_] :> IdentityMatrix[Dimensions[PauliMatrix[a]]];
  intermediate /. IdentityMatrix[_].m_?MatrixQ :> m
 ]

You can then use it as follows:

results = simplifyPM[PauliMatrix[1].PauliMatrix[1].PauliMatrix[2]]
(* Out: PauliMatrix[2] *)

The results are in a held form. If you want to obtain their actual value, you can release the hold:

ReleaseHold@results

(* Out: {{0, -I}, {I, 0}} *)

The function also works on multiple substitutions:

simplifyPM[PauliMatrix[4].PauliMatrix[4].PauliMatrix[3].PauliMatrix[3]]
ReleaseHold[%]

(* Out: 
IdentityMatrix[Dimensions[PauliMatrix[3]]] 
{{1, 0}, {0, 1}}
*)

Since Pauli matrices are always 2x2 matrices, you could also simplify the code above by using IdentityMatrix[2] in place of IdentityMatrix[Dimensions[PauliMatrix[a]]] in the definitions, but I thought I would leave the current expression in as a more general approach that may come in handy for cases in which the size of the matrix is not known a priori.

$\endgroup$
  • $\begingroup$ Marked as the answer; this does exactly as I asked and is very straightforward to understand. Thanks! $\endgroup$ – David B Jun 29 '15 at 12:33
  • $\begingroup$ @daveboden What would you like that expression to be reduced to? $\endgroup$ – MarcoB Jul 9 '15 at 23:50
  • $\begingroup$ Using associativity and factoring out of a scalar, this should reduce to just PauliMatrix[2]: simplifyPM[-(-PauliMatrix[2].PauliMatrix[3]).PauliMatrix[3]] and Additionally, this example doesn't clear the identity away because it's on the right hand side. Is there a good way of marking the Identity replacement rule as commutative? simplifyPM[PauliMatrix[2].(PauliMatrix[3].PauliMatrix[3])] $\endgroup$ – David B Jul 10 '15 at 9:59
5
$\begingroup$

I had actually answered this in a different thread that was eventually closed. Since that answer fits perfectly for this question, I'll use it here:

I will use $\sigma$ as an abbreviation for PauliMatrix.

The goal is to get back a result in terms of the symbolic matrices $\sigma$. Fortunately, this can always be done because the Pauli matrices when combined with the unit matrix form a basis of the vector space of two-dimensional matrices. This means that for a given matrix a, the equation Solve[{x1, x2, x3, x4}.PauliMatrix[{0, 1, 2, 3}] == a] has one and only one solution {x1, x2, x3, x4}. These coefficients can be used to form a linear expression using the symbolic matrices $\sigma$ in the end.

So here is a function pauliReduce which takes an expression involving the symbolic σ[i] (where i = 0, 1, 2, 3), and returns a simplified result in terms of the same symbols, and potentially the unit matrix which I called $\hat{1}$ to distinguish it from the number 1. The unit matrix is also given by σ[0].

Clear[pauliReduce]
pauliReduce[a_] := 
 Module[{x, symbolicPauliIndices, expression}, 
  x = Array[\[FormalX], 4];
  symbolicPauliIndices = 
   DeleteDuplicates[Cases[a, σ[i_Symbol] :> i, Infinity]];
  expression = {OverHat[1], σ[1], σ[2], σ[
      3]}.(x /. 
      First[Solve[
        x.PauliMatrix[{0, 1, 2, 3}] == a /. σ[i_] :> 
          Sum[KroneckerDelta[i, k] PauliMatrix[k], {k, 0, 3}], x]]);
  FullSimplify[expression, 
   Assumptions -> 
    Map[# ∈ Integers && 1 <= # <= 3 &, 
     symbolicPauliIndices]]]

Here are some relations that can now be proved:

pauliReduce[σ[1].σ[2]]

$\mathbb{i}$ σ$[3]$

pauliReduce[σ[1].σ[2] - σ[2].σ[1]]

2 $\mathbb{i}$ σ$[3]$

pauliReduce[σ[1].σ[1]]

$\hat{1}$

pauliReduce[σ[1].σ[2] + σ[2].σ[1]]

0

pauliReduce[MatrixExp[α σ[1]]]

Cosh[α] $\hat{1}$ + Sinh[α] σ$[1]$

pauliReduce[σ[i].σ[j] + σ[j].σ[i]]

1

pauliReduce[σ[1].σ[2].σ[3]]

$\mathbb{i} \hat{1}$

pauliReduce[σ[1].σ[1].σ[2]]

σ$[2]$

$\endgroup$
  • $\begingroup$ I've marked the simpler response as the "answer", but your contribution is clearly very complete, general and powerful. I'm going to learn plenty from it; really appreciate your reply. $\endgroup$ – David B Jun 29 '15 at 12:34
  • $\begingroup$ @daveboden Thanks, it's always good to see different approaches. $\endgroup$ – Jens Jun 29 '15 at 15:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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