Discussion:
"Imaginary parts of complex X and/or Y arguments ignored."
(too old to reply)
mark
2007-06-18 21:25:07 UTC
Permalink
I get this warning at certain timesteps in using ode45. I've
encountered no mention of complex components showing up in the
solution to this ode, so I didn't expect this. Could this warning
have come up as a result of something I've done wrong? It indicates
the line where I call ode45, and one line in my (self-defined) output
function where I compare the values of two components of the
solution.
I would appreciate any help in figuring out what this arises from.

Mark
Roger Stafford
2007-06-19 01:04:04 UTC
Permalink
Post by mark
I get this warning at certain timesteps in using ode45. I've
encountered no mention of complex components showing up in the
solution to this ode, so I didn't expect this. Could this warning
have come up as a result of something I've done wrong? It indicates
the line where I call ode45, and one line in my (self-defined)
output
function where I compare the values of two components of the
solution.
I would appreciate any help in figuring out what this arises from.
Mark
-------------
You are not likely to receive a satisfactory explanation to your
inquiry unless you describe the particular differential equations you
have given to 'ode45'. There are many things that can lead to
complex results, such as the square root of a negative number, the
logarithm of a negative quantity, the arcsine of a number greater
than one, etc.

Alternatively, you can make a careful study on your own of the
functions you have used to see if there are circumstances that can
cause them to produce complex values. In particular, see what their
values have become immediately prior to the appearance of the complex
results.

Roger Stafford
Mark
2007-06-19 15:08:09 UTC
Permalink
Here is the function defining my ode:

function yprime = eoms (t,y)
m = 0.5;
mu = sqrt(2);
yprime = zeros(4,1);
yprime(1) = y(3)/m;
yprime(2) = y(4)/m;
yprime(3) = (mu^2)/(m*(y(1))^3) -
(4*sqrt(2)*y(1))/((y(1)^2)+(2*(y(2))^2))^(3/2) - 2/(y(1))^2;
yprime(4) = (-8*sqrt(2)*y(2))/((y(1))^2+(2*(y(2))^2))^(3/2);

And here is the call:
[t,y] = ode45(@eoms, tspan, y0, options);

Options are as follows:
options = odeset('RelTol', 1e-5, 'AbsTol', 1e-4, 'OutputFcn',
@xsecplot);

Inside xsecplot I check if the 2nd component of the solution is zero,
and the 4th non-negative, and if so, plot the first component vs. the
third.

It would have been ideal if I could've done this using Events, but
from what I understand I can only detect the event I want and stop
integration then- can't actually *do* something else upon event
detection.
Post by Roger Stafford
You are not likely to receive a satisfactory explanation to your
inquiry unless you describe the particular differential equations
you
have given to 'ode45'. There are many things that can lead to
complex results, such as the square root of a negative number, the
logarithm of a negative quantity, the arcsine of a number greater
than one, etc.
Alternatively, you can make a careful study on your own of the
functions you have used to see if there are circumstances that can
cause them to produce complex values. In particular, see what
their
values have become immediately prior to the appearance of the
complex
results.
Roger Stafford
Loading...