Von Neumann equation

I’m trying to symbolically integrate the Von Neumann equation for a two-level system with some basic Hamiltonians. Thus, I want to solve

I \[HBar] \[Rho]'[t] = H[t].\[Rho] - \[Rho].H[t]

Where

\[Rho]

is a 2x2 matrix.

In the simplest case,

H[t]

will be the Pauli sigma X matrix.

What’s the proper way of setting this problem up using DSolve?

They key point is that you can’t just define H and ? to be interpreted as matrix values functions, since by default symbols are interpreted as complex numbers. So you have to define ? and H to be matrices, like this

In[59]:= \[Rho][t_] := {{a[t], b[t]}, {c[t], d[t]}}

In[60]:= H[t_] := PauliMatrix[1]

You can then type in commutation relation pretty much as expected, except you must remember that your unknowns are a,b,c, and d.

In[61]:= DSolve[{I \[HBar] \[Rho]'[t] ==
H[t].\[Rho][t] - \[Rho][t].H[t], \[Rho][0] == PauliMatrix[3]}, {a, b, c,
d}, t]

Out[61]= {{a -> Function[{t}, Cos[(2 t)/\[HBar]]],
b -> Function[{t}, I Sin[(2 t)/\[HBar]]],
c -> Function[{t}, -I Sin[(2 t)/\[HBar]]],
d -> Function[{t}, -Cos[(2 t)/\[HBar]]]}}

You can now substitute this into to get your solution. Note the use if Set (=) rather than SetDelayed (:=) to make sure the substitution is done immediately, rather than each time you evaluate ?.

In[62]:= \[Rho][t_] = \[Rho][t] /. First[%]

Out[62]= {{Cos[(2 t)/\[HBar]],
I Sin[(2 t)/\[HBar]]}, {-I Sin[(2 t)/\[HBar]], -Cos[(2 t)/\[HBar]]}}

You can also try this:

\[Rho]M[t_] = Table[\[Rho][i, j][t], {i, 2}, {j, 2}]

H = PauliMatrix[1]

sol1 = DSolve[{I \[HBar] \[Rho]M'[t] == 
    H.\[Rho]M[t] - \[Rho]M[t].H, \[Rho]M[0] == 
    Table[\[Rho]0[i, j], {i, 2}, {j, 2}]}, Flatten[\[Rho]M[t]], t]

or more elegantly

sol2 = MatrixExp[-I t H/\[HBar]].Table[\[Rho]0[i, j], {i, 2}, {j, 
    2}].Simplify[ConjugateTranspose[MatrixExp[-I t H/\[HBar]]], 
   Element[{t, \[HBar]}, Reals]]

Thanks for the help.
Itai, that looks like exactly what I wanted. However, I still seem to get an error when I run the code you suggested

In[22]:= \[Rho][t_] := {{a[t], b[t]}, {c[t], d[t]}}
H[t_] := PauliMatrix[1]
DSolve[{I \[HBar] \[Rho]'[t] == 
   H[t].\[Rho] - \[Rho].H[t], \[Rho][0] == PauliMatrix[3]}, {a, b, c, 
  d}, t]

During evaluation of In[22]:= DSolve::nolist: List encountered within {{{I \[HBar] (a^\[Prime])[t],I \[HBar] (b^\[Prime])[t]},{I \[HBar] (c^\[Prime])[t],I \[HBar] (d^\[Prime])[t]}}==-\[Rho].{{0,1},{1,0}}+{{0,1},{1,0}}.\[Rho]}. There should be no lists on either side of the equations. >>

Out[24]= DSolve[{{{I \[HBar] Derivative[1][a], 
     I \[HBar] Derivative[1][b]}, {I \[HBar] Derivative[1][c], 
     I \[HBar] Derivative[1][d][
       t]}} == -\[Rho].{{0, 1}, {1, 0}} + {{0, 1}, {1, 
       0}}.\[Rho], {{a[0], b[0]}, {c[0], d[0]}} == {{1, 
     0}, {0, -1}}}, {a, b, c, d}, t][/b]

Do you know what this means?

There was a copy/paste problem. On the RHS of the equation, it should have been

H[t].\[Rho][t] - \[Rho][t] . H[t]

(Notice that the ? is now ?[ t ]). I have fixed my original post, so copy and pasting it out should work now.

Perfect, thank you.