Question: Euler's method, more efficiently store data during simulation

Hello Im trying to implement a method for numerical simulating a DE with Euler's method. I have got a second degree differential equations which i then transform to two first degrees which i give to my method. The code is given below. The method I'am using uses a list for which I ad an element after each step. This requires shifting al elements in the list one index lift or right. This works fine when there aren't many steps to do, but becomes very slow and uses a gigantic amount RAM in worksheet when i do 10.000 steps. Is there a way do to this more efficiently both in terms of speed and RAM ? Thanks Pieter EULER2 := proc (f1,f2,x0,y0,z0,a,b,h) # y'(x)=f1(x,y,z) and z'(x) = f2(x,y,z) with substitution y'(x)=z(x) #x0 start x-as #y0 corresponding y value #z0 corresponding z value #a leftboundary #b rightboundary #h stepsize local x, y, y00,z00 ,z,datapoints,fasepoints; description "Numerieke simulatie van een tweede orde differentiaalvergelijking met methode van Euler"; x := x0; y := y0; z := z0; datapoints := [[x,y]]; phasepoints := [[y,z]]; while(x
Please Wait...