2
$\begingroup$

For a specific quantum mechanical problem I need to multiply out operators in order to calculate a trace by hand. For example I need a Hamiltonian squared with $H^2$. The Hamiltonian contains of a few single terms and flip-flop terms embedded in sums like $\frac{1}{2} \sum_{m=1}^N S_0^+ S_m^- + S_0^- S_m^+$.

My first idea was simply to write down the sums and ask Mathematica to multiply them out by expanding them. Unfortunately, this yields a result I could have imagined myself with $\sum_m (...) \times \sum_n (...)$. What I need is a sum of those product terms for example of the form $\sum_{m=1,n=1}^N S_0^+ S_m^-S_0^+ S_n^- + \sum_{m=1,n=1}^N (...)$ as I want to evaluate each operator separately by hand.

Changing the sum parenthesis doesn't seem to have any effect. Expand refuses to work.

Is there a possibility to let Mathematica multiply out all those terms individually?

Remark: As specific operators don't commute, e.g. $[S^+,S^-]$ for the same index I need Mathematica to give out each term. Simplifying by changing operator positions could lead to false results, so something like $(a+b)*(a+b)=a^2+ab+ba+b^2$ is needed here.

Edit: Here is a minimum example of what doesn't work as expected:

Expand[(-h Subscript[S^z, 0] - 
Sum[Subscript[J, 
  m] (Subscript[S, 0]^z Subscript[S, m]^z + 
    1/2 SuperPlus[Subscript[S, 0]] SuperMinus[Subscript[S, m]] + 
    1/2 SuperMinus[Subscript[S, 0]] SuperPlus[Subscript[S, 
     m]]), {m, 1, NN}]) (-h Subscript[S^z, 0] - 
Sum[Subscript[J, 
  n] (Subscript[S, 0]^z Subscript[S, n]^z + 
    1/2 SuperPlus[Subscript[S, 0]] SuperMinus[Subscript[S, n]] + 
    1/2 SuperMinus[Subscript[S, 0]] SuperPlus[Subscript[S, 
     n]]), {n, 1, NN}])]
$\endgroup$
6
  • 1
    $\begingroup$ If you can provide a minimum (non-)working example it would be great. $\endgroup$
    – Sektor
    Commented Apr 22, 2015 at 15:56
  • $\begingroup$ Welcome to Mathematica.SE! I suggest the following: 0) Browse the common pitfalls question 1) As you receive help, try to give it too, by answering questions in your area of expertise. 2) Read the faq! 3) When you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge. Also, please remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign! $\endgroup$ Commented Apr 22, 2015 at 16:15
  • $\begingroup$ is NN known, or does it need to remain as NN? $\endgroup$
    – chuy
    Commented Apr 22, 2015 at 16:51
  • $\begingroup$ Related: Pull out scalars from NonCommutativeMultiply in commutator of SU2 spin algebra, and Traces of products of Pauli matrices $\endgroup$
    – Jens
    Commented Apr 22, 2015 at 19:40
  • $\begingroup$ @chuy It has to remain that way. The variable is not known beforehand. $\endgroup$
    – pbx
    Commented Apr 23, 2015 at 11:34

1 Answer 1

1
$\begingroup$

Try to read this. I used the package some time ago and it works quite nicely.

$\endgroup$

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.