This page is a self-testing ladder. Work each problem before opening its solution. The levels climb from "can you spot RK4?" up to "can you build and prove things with it?". Every symbol used here is defined on the parent note RK4 derivation — keep it open as your reference.
In the RK4 recipe, at which x-value is k3 evaluated, and which previous slope does it reuse?
Recall Solution
k3=hf(xn+2h,yn+2k2). So it is sampled at the midpointxn+2h, and it reuses k2 (a refined midpoint slope). Look at figure s01: the two amber arrows (k2 and k3) share the same vertical dashed line at the midpoint; only the height of the estimated y differs.
A student writes yn+1=yn+6h(k1+2k2+2k3+k4) using ki=hf(…). Is the extra 6h correct here, or should it be 61?
Recall Solution
It should be 61, not6h. In our convention each kialready contains one factor of h (because ki=hf). Putting 6h would multiply by h twice, giving an h2 step — wrong dimensions.
yn+1=yn+61(k1+2k2+2k3+k4).
The 6h form is only correct in the other convention where ki is a pure slope (no h).
Solve y′=x+y, y(0)=1 for one step to find y(0.2) using h=0.2. (Different step size from the parent's example.)
Recall Solution
Here f(x,y)=x+y, x0=0, y0=1, h=0.2.
k1=0.2f(0,1)=0.2(0+1)=0.2 — slope at left edge.
k2=0.2f(0.1,1+0.1)=0.2f(0.1,1.1)=0.2(0.1+1.1)=0.24 — midpoint, using 2k1=0.1.
k3=0.2f(0.1,1+0.12)=0.2f(0.1,1.12)=0.2(0.1+1.12)=0.244 — refined midpoint, using 2k2=0.12.
k4=0.2f(0.2,1+0.244)=0.2f(0.2,1.244)=0.2(0.2+1.244)=0.2888 — right edge, using full k3.
y1=1+61(0.2+2(0.24)+2(0.244)+0.2888)=1+61.4568=1.2428.
Exact: y=2ex−x−1⇒y(0.2)=2e0.2−1.2=1.242806. Error ≈6×10−6.
Solve y′=−2y, y(0)=3 for one step to y(0.5) with h=0.5. (Note: f has nox-dependence, so all stages use the samex shift trivially.)
Recall Solution
f(x,y)=−2y, y0=3, h=0.5.
k1=0.5(−2⋅3)=−3.
k2=0.5(−2(3+2−3))=0.5(−2⋅1.5)=−1.5.
k3=0.5(−2(3+2−1.5))=0.5(−2⋅2.25)=−2.25.
k4=0.5(−2(3+(−2.25)))=0.5(−2⋅0.75)=−0.75.
y1=3+61(−3+2(−1.5)+2(−2.25)+(−0.75))=3+6−11.25=1.125.
Let's check the bracket: −3+2(−1.5)+2(−2.25)+(−0.75)=−3−3−4.5−0.75=−11.25, and 3−611.25=3−1.875=1.125.
Exact: y=3e−2x⇒y(0.5)=3e−1=1.103638. Here the step h=0.5 is large for a fast-decaying equation, so the error (≈0.021) is visible — a reminder that "4th order" is a statement about smallh.
For y′=f(x) (right-hand side depends on xonly), show that the RK4 update collapses into Simpson's rule for ∫xnxn+hf(x)dx.
Recall Solution
When f depends only on x, the y-arguments are irrelevant, so:
k1=hf(xn),k2=k3=hf(xn+2h),k4=hf(xn+h).
Substituting into the update:
yn+1−yn=61(hf(xn)+2⋅hf(xn+2h)+2⋅hf(xn+2h)+hf(xn+h)).=6h(f(xn)+4f(xn+2h)+f(xn+h)).
That last line is exactly Simpson's rule6h(f0+4fmid+f1) for the integral over [xn,xn+h]. So RK4 is Simpson's rule, generalized to allow y-dependence. This is why the weights are 1,2,2,1: the two midpoint samples merge into the single "4" of Simpson.
The local (per-step) error of RK4 is O(h5). Explain why the global error over a fixed interval [a,b] is only O(h4).
Recall Solution
To cross a fixed length L=b−a you take N=hL steps — that is, N∝h1.
What "each step adds ∼Ch5" means. On a single step the method's answer differs from the true curve by an amount bounded by (some constant) ×h5. Call that constant C: it packages together how curvy the solution is (roughly, the size of its 5th derivative over the interval) and the fixed numerical factor 1201 that RK4 leaves behind. C does not shrink as h shrinks — it depends on the problem, not the step — so the whole h-dependence of one step's error lives in the h5. That is why we write "local error =Ch5".
Why the errors add up (error propagation). Picture the calculation as a relay: each step starts from the previous step's (already slightly wrong) answer and adds its own fresh Ch5 mistake. So two things happen at every step — (i) a new∼Ch5 error is committed, and (ii) the errors already present get carried forward. For a well-behaved (stable) equation the carried-forward errors don't blow up; they grow at most by a bounded factor. In that case the total is dominated by simply summing the N fresh contributions, one per step:
global error∼how many stepsN×one step’s errorCh5=hL⋅Ch5=CLh4=O(h4).
One power of h is "eaten" by the growing number of steps: you make more steps when h is small, so more little errors pile up, cancelling one factor of h. See Local vs Global Truncation Error. This is why RK4 is called 4th order (the global statement), even though each step is 5th-order accurate.
Solve y′=y, y(0)=1 using two RK4 steps of size h=0.5 to estimate y(1). Compare with the single-step-of-h=1 result (2.70833 from the parent) and the exact e.
k4=0.5(1.6484375+1.081787…)=1.3651123…y2=1.6484375+61(0.82421875+2(1.0302734)+2(1.0817871)+1.3651123).
The bracket sum =6.4134277…, so y2=1.6484375+1.0689046…=2.7173421.
Exact e=2.7182818; error ≈0.00094. The single big step gave 2.70833 (error ≈0.010). Halving the step cut the error by roughly 16=24 — the signature of a 4th-order method.
Using the observation in L4.1, predict the error if you instead used four steps of h=0.25 for the same problem, without computing them. State the reasoning.
Recall Solution
Global error ∝h4. Going from h=0.5 to h=0.25 halves h, so the error scales by (21)4=161.
new error≈160.00094≈5.9×10−5.
So we predict y(1)≈e−5.9×10−5≈2.718222. (Direct computation gives error ≈6.5×10−5 — the 24 rule works.)
Show algebraically that RK4 applied to y′=y, y(0)=1 with a single step of size h gives
y1=1+h+2h2+6h3+24h4,
i.e. the first five terms of eh. (This is the direct proof that RK4 matches Taylor to h4.)
Recall Solution
With f(x,y)=y, y0=1:
k1=h⋅1=h.
k2=h(1+2k1)=h(1+2h)=h+2h2.
k3=h(1+2k2)=h(1+2h+4h2)=h+2h2+4h3.
k4=h(1+k3)=h(1+h+2h2+4h3)=h+h2+2h3+4h4.
Now combine with weights 1,2,2,1:
k1+2k2+2k3+k4.
Collect by power of h:
h1: 1+2+2+1=6 → contributes 6h.
h2: 2⋅21+2⋅21+1=1+1+1=3 → contributes 3h2.
h3: 2⋅41+1⋅21=21+21=1 → contributes h3.
h4: 1⋅41=41 → contributes 41h4.
So k1+2k2+2k3+k4=6h+3h2+h3+41h4. Divide by 6:
y1=1+h+2h2+6h3+24h4.
These are exactly the first five terms of eh=1+h+2h2+6h3+24h4+120h5+⋯. The first term RK4 misses is 120h5 — confirming local error O(h5). See Taylor Series Methods.
Solve the coupled system dtdx=y,dtdy=−x with x(0)=1,y(0)=0 using one RK4 step h=0.1 to estimate x(0.1),y(0.1). (This is x¨=−x, simple harmonic motion; exact answer x=cost,y=−sint.) Use vector RK4: treat u=(x,y) and f(u)=(y,−x).
Recall Solution
Vector RK4 is identical to scalar RK4, just applied componentwise. Let u0=(1,0), h=0.1, f(x,y)=(y,−x).
k1=hf(u0):f(1,0)=(0,−1), so k1=(0,−0.1).
k2=hf(u0+2k1): argument =(1+0,0−0.05)=(1,−0.05); f=(−0.05,−1); so k2=(−0.005,−0.1).
k3=hf(u0+2k2): argument =(1−0.0025,0−0.05)=(0.9975,−0.05); f=(−0.05,−0.9975); so k3=(−0.005,−0.09975).
k4=hf(u0+k3): argument =(1−0.005,0−0.09975)=(0.995,−0.09975); f=(−0.09975,−0.995); so k4=(−0.009975,−0.0995).
So x(0.1)≈0.9950042,y(0.1)≈−0.0998333. Exact: cos0.1=0.9950042,−sin0.1=−0.0998334. Both match to about 2×10−6 — RK4 handles systems with the same 4th-order accuracy, no new machinery needed.