2
$\begingroup$

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?

$\endgroup$

1 Answer 1

1
$\begingroup$

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.

$\endgroup$
4
  • 1
    $\begingroup$ 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. $\endgroup$
    – horchler
    Commented Aug 30, 2014 at 22:52
  • $\begingroup$ I see, thank you for this remark. So you could implement the above problem by replacing the matrix H by a 64x64 block diagonal matrix which contains 8 copies of the original H and then pass the the initial value as a matrix. $\endgroup$
    – Martin
    Commented Aug 30, 2014 at 23:01
  • 1
    $\begingroup$ 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? $\endgroup$
    – Andrew
    Commented Aug 30, 2014 at 23:26
  • 1
    $\begingroup$ Yes, of course. You can either convert the input vector into an 8x8 matrix and then multiply it with the actual H and then convert it back into a vector, or you can do what I have written before. The only difference could be the performance of your programme. To me, your solution sounds faster but I think you have to try it (or you have to know very precisely how matlab works internaly $\endgroup$
    – Martin
    Commented Aug 30, 2014 at 23:36

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .