Runge-Kutta method: Difference between revisions

m
(OCaml implementation)
Line 412:
=={{header|OCaml}}==
<lang ocaml>let y' t y = t *. sqrt y
let exact t = let u = 0.25*.t*.t +. 1.0 in u*.u
 
let rk4_step (y,t) h =
Line 423:
let rec loop h n (y,t) =
if n mod 10 = 1 then
Printf.printf "t = %f,\ty = %f,\terr = %g\n" t y (abs_float (y -. exact t));
if n < 102 then loop h (n+1) (rk4_step (y,t) h)
 
Anonymous user