3
$\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
    $\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$ – Felix Mar 16 '17 at 19:47
  • 3
    $\begingroup$ You could do Inner[KroneckerProduct, {a, b}, {b, a}, Plus] /. {a -> PauliMatrix[1], b -> PauliMatrix[2] }. $\endgroup$ – march Mar 17 '17 at 3:43
  • 2
    $\begingroup$ ... also Plus @@ MapThread[ KroneckerProduct, {{PauliMatrix[1], PauliMatrix[2]}, {PauliMatrix[2], PauliMatrix[1]}}] $\endgroup$ – kglr Mar 26 '17 at 22:32
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 (:=).

| improve this answer | |
$\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.)

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

Mathematica graphics

| improve this answer | |
$\endgroup$

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.