I have created a midpoint algorithm to solve 2nd order ODEs in Matlab. And now Im comparing my solver with built in - ode23s. I have used a harmonic motion described as a 2nd order ODE, the .m file with the ODE looks like this
function dy=oscillator(t,y) y1=y(1); v=y(2); dy1=v; dy2=-y1; dy=[dy1;dy2]; end
And after plotting through ode23s and my Midpoint I got this graph. Now my question is how is it possible that using the modified euler method(midpoint) to solve the oscillator problem does not give me the same result as using ode23s?