#======== demo1 Solves dy/dx = y * sin(x) + x y(0) = 1 over the interval [0,14] Converges around K = 6 < 14 Coarse integrator is Euler Method step size 1 Fine integrator is Euler Method step size 1/fine =========# function demo1() simulate(0,14,6,14,50,1,((x,y)->y*sin(x)+x),7,true); end #====== demo2 Solves dy/dx = 0 y(0) = 0 over the interval [-10,10] Converges after K = 1 Coarse integrator is Euler Method step size 1 Fine integrator is Euler Method step size 1/fine (fine steps) =======# function demo2() simulate(-10,10,2,10,50,0,((x,y)->0),7,true) end #======= demo3 Solves dy/dx = sin(x*y) y(-10) = 10 over the interval [-10,10] Converges only after K = 20 Coarse integrator is Euler Method step size 40/10 = 4 (10 steps) Fine integrator is Euler Method step size 4 / 500 ========# function demo3() simulate(-20,20,10,10,500,10,((x,y)->sin(x*y)),7,true); end #======= forTheSkeptics Solves dy/dx = e^(x/333) * sin(x) y(1) = 1 over the interval [1,1001] Coarse integrator is Euler method step size 1000/10 = 100 (10 steps) Fine integrator is Euler method step size 100/5000 = .02 (500 steps) =======# function forTheSkeptics() x,y,yF,sub,xC,yC = simulate(1,1001,10,10,5000,pi/2,((x,y)->exp(x/333)*sin(x)),7,true); end #======= forTheSkeptics2 Solves dy/dx = e^(x/333) * sin(x/50) y(1) = 1 over the interval [1,1001] Coarse integrator is Euler method step size 1000/10 = 100 (10 steps) Fine integrator is Euler method step size 100/5000 = .02 (500 steps) =======# function forTheSkeptics2() x,y,yF,sub,xC,yC = simulate(1,1001,10,10,5000,pi/2,((x,y)->exp(x/333)*sin(x/50)),7,false); end #======= For timing demo, run the following: @time eulerMethod(50000,0,14,1,((x,y)->y*sin(x)+x)) @time pararealSimulator(0,14,6,14,50000,1,((x,y)->y*sin(x)+x)) @time pararealActual(0,14,6,14,50000,1,((x,y)->y*sin(x)+x)) =======#