# L-31 MCS 471 Wed 2 Nov 2022 : rk45exp.jl # Using RK45 of the SciPy.integrate module on the test equation. using SciPy using Printf println("Solving y\' = y, y(0) = 1 with SciPy.integrate.RK45") testfun(t,y) = y sol = SciPy.integrate.RK45(testfun, 0.0, (1.0,), 1.0, rtol=1.0e-8) println("step : t : h : y : error") stepcnt = 0 while sol.status != "finished" sol.step() global stepcnt = stepcnt + 1 scnt = @sprintf("%4d", stepcnt) step = @sprintf("%.2e", sol.step_size) tval = @sprintf("%.2e", sol.t) soly = @sprintf("%.16e", sol.y[1]) err = abs(sol.y[1] - exp(sol.t)) serr = @sprintf("%.2e", err) println("$scnt : $tval : $step : $soly : $serr") end