[SciPy-user] Using odeint to solve complex-valued ode's
David L. Goldsmith
David.L.Goldsmith at noaa.gov
Fri Nov 17 18:09:52 EST 2006
Robert Kern wrote:
> Calling real(f) where f is a function object won't do anything sensible. In
> fact, what's happening is that numpy doesn't recognize it as an ndarray, so it
> calls array(f) to make it an array. array() doesn't recognize it as any kind of
> sequence or number, so it assumes that you wanted to treat it as a scalar type
> numpy.object_ (the numpy scalar version of object arrays). I believe when faced
> with an object array, real() simply returns its input just like it does for any
> dtype that is not explicitly complex. The result is a scalar object, which is
> not callable; thus, you get that exception.
>
>
Yeah, I figured something like that was what was happening.
>> This is correct from what I remember. I don't think that the underlying ODEPACK
>> handles complex-valued ODEs (except as converted to a real vector-valued ODE)
OK. Perhaps you can save me a little time. Let cv() = transpose(u +
iv, u' + iv'). Then if I have:
cv()' = L * cv() = A*cv() + iB*cv() (where A and B, the real and
imaginary parts of L, resp., are real-valued 2x2 matrices)
which expanded and separated into real and imaginary parts becomes:
cv(u, u')' = A*cv(u,u') - B*cv(v,v')
cv(v, v')' = A*cv(v,v') + B*cv(u,u')
then this is equivalent to the four by four real-valued system:
| A -B |
cv(u, u', v, v')' = | B A | * cv(u, u', v, v'), correct? (I hope none
of my former linear algebra teachers are reading this :-) . If they
are: for the record, A) I'm 99% sure this is right; B) I could of course
go look it up, but all my LA books are at work and I'm working at home;
and C) I'm still capable of proving it, but it's time consuming, thus
the preface: "perhaps you can save me a little time".)
Thanks as always,
DG
More information about the SciPy-User
mailing list