# Solve system of first order ODEs when values are a matrix

I have a set of first order ODEs such that

$$\frac{d \Psi}{ds} = H(s)\Psi$$

H(s) is an 8x8 matrix.

I would like to find $\Psi(b)$ where $b$ is 10, for instance. The initial value for $\Psi(a)$ is a 8x8 identity matrix when $a$ is 5, for instance.

Normally I would solve something like this in Matlab using ode45 (Runge-Kutta), but I'm not sure how to handle this when $\Psi$ is a matrix instead of a vector.

Is there anything special that needs to be done when $\Psi$ is a matrix instead of a vector?

The short answer is: Nothing changes. You can interpret your matrix equation as 8 vector equations, i.e. $\Psi=(\Psi_1,\ldots,\Psi_8)$ where $\Psi_1,\ldots,\Psi_8$ are vector valued functions. There is no kind of "interaction" between the 8 equations, i.e. you can solve them independently. I can also imagine (just give it a try) that matlab won't bother wether you have a vector or a matrix as initial value.
• FYI, Matlab's ODE solvers only work with vectors, but yes you can use a matrix initial condition. That matrix will be linearized along it's rows, i.e, y0 = y0(:);. The user-written integration function will still need to take in and return vectors. Commented Aug 30, 2014 at 22:52
• I was understanding horchler a little differently. $\Psi$ would be an array (1x64) passed to the integration function, in the integration function it would be changed to an 8x8 matrix, multiplied by H(s) such that $\frac{d \Psi}{ds} = H(s) \Psi$, then $\frac{d \Psi}{ds}$ is re-formulated as an array (1x64) and return from the integration function. Will this work? Commented Aug 30, 2014 at 23:26