I have a system of ODE, dx/dt = f(t,x,y), dy/dt = g(t,x,y), x(0) = x0, y(0) = y0, for which NDSolve is giving unexpected results. Moreover, I have run it with no problems with a fixed stepsize Runge-Kutta package so I think the math is correct.
The functions f and g are piecewise defined (they are both essentially continuous), and it is around where the pieces fit together that NDSolve has problems. If you have some expertise with NDSolve and/or variable stepsize algorithms could you take a look at the system and see if you can spot what is happening?
The trajectory of this lies on the algebraic curve y^2 = x^2 + x^3. This curve has a double point at (0,0) which is where the second definitions in f and g kick in. To keep this simple I have given you the system so that smoothness of solution is guaranteed only for t >= 0.
The problem with NDSolve is that it "bounces back" from the origin at (0,0), instead of passing through it as the fixed step Runge-Kutta method does. What follows is the NDSolve version with all the variables printed out so that you can see it "bouncing back" at the origin. (Sorry about the length of this, but I have found that NDSolve is picky about how you input a piecewise defined equation. I need the flexibility of using a Module in order to obtain the desired solution for all t.)