Exercise: Euler and RK4 by hand on a first-order ODE
Solve for y'=f(t,y) in an ODE given in implicit form and approximate y(3) with two Euler steps and one RK4 step, comparing both results.
Setup
Consider the ODE with , and approximate . The equation is not in normal form, so first solve for :
Two Euler steps
Apply two steps of explicit Euler with from , .
First step: at the denominator is , so .
Second step: at the numerator is , hence and the solution does not change.
Euler with gives . The step is too large: the first jump takes the solution to , a point where vanishes and the method stays.
One Runge-Kutta step
Apply one step of classical Runge-Kutta with from , .
Initial slope: .
Midpoint () advancing with : , so .
Midpoint again, now with : , so .
Final endpoint () with : , so .
Combination with weights :
RK4 gives . With the same number of evaluations as four Euler steps, it avoids the collapse at and produces a reasonable approximation.