Given the IVP y(1)(t = t y(t) - t2 + 1 with y(0) = 3, to approximate y(1), we can do:
t[0] := 0; t[1] := 1; y[0] := 3; f := (t, y) -> t*y - t^2 + 1; h := t[1] - t[0]; K[0] := f(t[0], y[0] ); K[1] := f(t[0] + h, y[0] + h*K[0]); y[1] := y[0] + h*(K[0] + K[1])/2;Copyright ©2005 by Douglas Wilhelm Harder. All rights reserved.