Skip to content
Free public beta until December 4, 2026: every course is open, no card needed. After that, the first chapter of each course stays free and full access is a one-time $39 ($19 for up to 100 founding members chosen for helpful feedback). Your progress is kept. How the beta works

Recipe

Take one RK4 step

Use when: you're given an IVP y'=f(t,y), y(t_0)=y_0, a chosen step size h, and asked to advance the numerical solution by one step with fourth-order accuracy

Goal: the next point (t_{n+1},y_{n+1}) on the numerical solution

Taught in RK4

  1. 1

    k_1=f(t_n,y_n) — evaluate the differential equation exactly where you already stand.

    Example

    For y'=-2ty, y_0=1 at t_0=0: k_1=f(0,1)=-2(0)(1)=0.

    Why: k_1 is the ordinary Euler slope — the differential equation evaluated at a point that's known exactly, with no estimation involved yet.

  2. 2

    k_2=f\!\left(t_n+\tfrac h2,\ y_n+\tfrac h2k_1\right) — walk half a step using k_1, then ask f for the slope there.

    Example

    t_0+\tfrac h2=0.25, y_0+\tfrac h2k_1=1+0.25(0)=1. k_2=f(0.25,1)=-2(0.25)(1)=-0.5.

    • f does not depend on t (an autonomous equation) — t_n+\tfrac h2 never enters the calculation at all; see the shortcut below.
    • f depends on both t and y — compute t_n+\tfrac h2 explicitly before evaluating f there, as in the example.

    Why: k_2 is a first, Euler-quality guess at the slope in the MIDDLE of the step — better-centered information than k_1 alone provides.

  3. 3

    k_3=f\!\left(t_n+\tfrac h2,\ y_n+\tfrac h2k_2\right) — the SAME midpoint, reached using k_2 instead of k_1.

    Example

    y_0+\tfrac h2k_2=1+0.25(-0.5)=0.875. k_3=f(0.25,0.875)=-2(0.25)(0.875)=-0.4375.

    ⚡ Shortcut

    For an AUTONOMOUS equation, f ignores t entirely, so this step (and Step 2) never need t_n+\tfrac h2 tracked at all — only the y-argument changes between them. Section 6's own y'=y example: k_1=f(y_0)=1, k_2=f(y_0+\tfrac h2k_1)=f(1.25)=1.25, k_3=f(y_0+\tfrac h2k_2)=f(1.3125)=1.3125 — no t-bookkeeping anywhere, only y-values.

    Why: k_2 was only Euler-quality; refining the walk to the midpoint using k_2 instead of k_1 gives a second, more trustworthy midpoint slope before the step ever reaches the endpoint.

  4. 4

    k_4=f(t_n+h,\ y_n+hk_3) — walk the FULL step using k_3's refined midpoint slope, then ask f for the slope there.

    Example

    t_0+h=0.5, y_0+hk_3=1+0.5(-0.4375)=0.78125. k_4=f(0.5,0.78125)=-2(0.5)(0.78125)=-0.78125.

    Why: k_4 estimates the slope at the FAR end of the step, using the best midpoint information (k_3) available to get there — completing the set of four points the method samples before committing to a step.

  5. 5

    y_{n+1}=y_n+\dfrac h6(k_1+2k_2+2k_3+k_4) — NOT a plain average; the two midpoint estimates each count double.

    Example

    y_1=1+\dfrac{0.5}{6}\big(0+2(-0.5)+2(-0.4375)+(-0.78125)\big)=1+0.08333(-2.65625)\approx0.77865. (True value e^{-0.25}\approx0.77880 — error \approx0.00015.)

    Why: this exact, non-uniform weighting is what makes the combined step match the true solution's Taylor expansion through the h^4 term — see rk4-formula's own proof for why 1{:}2{:}2{:}1 specifically achieves that match.

Common mistakes

  • Using t_n instead of t_n+\tfrac h2 when evaluating k_2 or k_3 — both midpoint stages need the SAME shifted t-argument, not the step's own starting time.
  • Treating the weighting as a plain average — dividing by 4 with equal weights (instead of dividing by 6 with weights 1{:}2{:}2{:}1) silently drops the method back toward lower accuracy.
  • Computing k_4 from k_2 instead of k_3 — k_4 needs the SECOND (refined) midpoint slope to step across the full interval, not the first.
  • Forgetting that k_2, k_3, and k_4 all depend on the PREVIOUS stage's own computed value — none of the four can be computed out of order.