MATLAB: Ode45, evolution giving NaNs after some time, with no evidence of singularities in the equations

MATLABnanode45

Hello,
Attached is a simple integrator for four coupled first order ode s.
after a certain time, the 4-vector solution turns into NaNs with no evidence of singularities in the equations.
This happens after a certain range where the solutions (starting as real) are written in complex notation although the imaginary part is zero. (why?)
can anyone please have a look and let me know if there's something im missing?

Best Answer

Your first order, e1, gets to be more than 1.0, and then the sqrt(1-x^2) gets to be complex. Problems accumulate from there.
What are the original equations that you are trying to deal with? Do you have the Symbolic Toolbox ?