4
$\begingroup$

I am trying to calculate $\sigma_1 \otimes \sigma_2 + \sigma_2 \otimes \sigma_1$ as a inner product. My attempt

Inner[KroneckerProduct, {PauliMatrix[1], PauliMatrix[2]}, {PauliMatrix[2], PauliMatrix[1]}, Plus] 

does not work. Any idea why?

$\endgroup$
3
  • 3
    $\begingroup$ Inner strips all list levels from {PauliMatrix[1], PauliMatrix[2]}, not just the outer braces. Since Inner does not have a level option, I would say it is not suitable for the task. $\endgroup$ Commented Mar 16, 2017 at 19:47
  • 3
    $\begingroup$ You could do Inner[KroneckerProduct, {a, b}, {b, a}, Plus] /. {a -> PauliMatrix[1], b -> PauliMatrix[2] }. $\endgroup$ Commented Mar 17, 2017 at 3:43
  • 2
    $\begingroup$ ... also Plus @@ MapThread[ KroneckerProduct, {{PauliMatrix[1], PauliMatrix[2]}, {PauliMatrix[2], PauliMatrix[1]}}] $\endgroup$ Commented Mar 26, 2017 at 22:32

3 Answers 3

2
$\begingroup$

Utilizing march's comment.

You want to first construct an inner product, then insert Pauli matrices:

f[a_, b_] = Inner[KroneckerProduct, {a, b}, {b, a}, Plus] f[PauliMatrix[1], PauliMatrix[2]] // MatrixForm 

enter image description here

Note the usage of Set (=) instead of the usual SetDelayed (:=).

$\endgroup$
1
$\begingroup$

Some Inactive[] trickery gets the job done:

With[{p1 = Inactive[PauliMatrix][1], p2 = Inactive[PauliMatrix][2]}, Inner[Inactive[KroneckerProduct], {p1, p2}, {p2, p1}, Plus] // Activate] {{0, 0, 0, -2 I}, {0, 0, 0, 0}, {0, 0, 0, 0}, {2 I, 0, 0, 0}} 

(Use Hold[]/ReleaseHold[] in earlier versions.)

$\endgroup$
1
$\begingroup$
Plus @@ MapThread[KroneckerProduct, {#, Reverse@#} &[PauliMatrix /@ {1, 2}]] // MatrixForm 

Mathematica graphics

$\endgroup$

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.