This problem must have been encountered by many people but I could not find a neat solution googling.
Many problems in mathematical physics can be written as a matrix ordinary differential equation (ODE), i.e. as $$ \frac{d A}{dt} = f(A) $$ with initial condition $$ A(0) = A_0 $$ where $A$ (and $f(A)$) is an $n\times n$ matrix. For simplicity I consider the case where the function $f$ is not explicitly time dependent, as in the above equation. In many circumstances it is easy to produce the function $f$ with matrix operations. For example for the Schroedinger equation one has $$f(A) = -i[H,A]$$ (square brackets represent the commutator).
Here is the question: what is a neat way to pass the ODE above to NDSolve
? In my situations the matrix $A$ (and $f(A)$) are hermitian, so it suffices to send to NDSolve
the $n$ real diagonal terms and the $n(n-1)/2$ complex terms in the upper diagonal. Essentially I am trying to find an elegant way to extract equations out of a matrix for general $n$.
$$
not to speak of\begin{align}?
$\endgroup$