an ode where numerical method fails in matlab

1 view (last 30 days)
hello, consider this ode:
syms t
y=dsolve('Dy=sqrt(1-y^2)','y(0)=1/sqrt(2)',t)
and the result is
y = sin(pi/4 + t)
when i try to use numerical methods (like euler, runge kutta, adams bashforth or built in ode solvers in matlab) and plotting it, i get this warning message:
Warning: Imaginary parts of complex X and/or Y arguments ignored
and because y starts to get imaginary values and matlab ignores imaginary parts, resultant points starts to diverge after t=pi/4. is there any way to overcome this problem?

Accepted Answer

Roger Stafford
Roger Stafford on 13 Dec 2014
Edited: Roger Stafford on 13 Dec 2014
When y nears 1, your differential equation system becomes what is known as 'stiff'. Even though the ideal solution is a perfectly smooth and regular function, the sizes of steps required in solving the corresponding differential equation system numerically become increasingly small. Look at it this way. When y attains a value of one, the differential equation dictates that the derivative dy/dt should be zero there. What is to prevent it from remaining fixed at y = 1 from that point on, or wandering off in any of a number of different directions? It is clearly a point of instability as far as the differential equation is concerned. This situation is not caused by the complex values you are seeing but lies in the very nature of the differential equation at this point. Read about this phenomenon at:
http://en.wikipedia.org/wiki/Stiff_equation
  2 Comments
Star Strider
Star Strider on 14 Dec 2014
I appreciate the clear, concise discussion.
Can
Can on 14 Dec 2014
thanks Roger Stafford, i'll look into it.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!