Worked examples — Runge-Kutta 4th order (RK4) — derivation
This deep-dive drills the parent RK4 derivation into practice. We solve one step of using the four slopes and the update . Nothing new is assumed — every symbol below was built in the parent note. Here we make sure no case surprises you.
Before any numbers, let's recall the machine we are feeding, so a reader arriving cold can follow.
Why re-list it? Because 90% of RK4 mistakes are plugging the wrong or into a stage. Keep this box open while you read.
Because our promise is visual-first, every worked example below comes with its own step-diagram: a picture of the slope samples on the actual curve, so the arithmetic never floats free of geometry. Look at the figure first, then read the numbers.
The scenario matrix
Every RK4 problem you will ever see is one (or a mix) of the cells below. The examples that follow are labelled with the cell they hit, so together they cover the whole grid.
| Cell | What makes it different | Example |
|---|---|---|
| A. Pure- integrand | RK4 collapses into Simpson's rule | Ex 1 |
| B. Linear mixed | Both variables move; smooth growth | Ex 2 |
| C. Negative / decaying slope | Signs flip; shrinks, must not overshoot below | Ex 3 |
| D. Nonlinear in etc. | Stages differ a lot; sensitivity | Ex 4 |
| E1. Zero slope everywhere | Nothing moves; sanity floor | Ex 5a |
| E2. Zero only at start , rest | Motion still happens; don't stop early | Ex 5b |
| F. Multi-step march (two steps of ) | Errors chain; from | Ex 6 |
| G. Large step / limiting big | Where accuracy strains; Taylor view | Ex 7 |
| H. Word problem (real world) cooling / motion | Translate a story into , keep units | Ex 8 |
| I. Exam twist depends on and nonlinearly, awkward numbers | Careful arithmetic, no calculator luxuries | Ex 9 |
Cell A — pure- integrand (RK4 = Simpson)
Forecast: The exact answer is . RK4 should nail it exactly — guess why before reading on. (Hint: Simpson is exact on cubics.)

Figure 1 (Cell A): the parabola with the three sample -values (left, midpoint, right) marked; because ignores , the two midpoint samples coincide.
- . Why this step? Left-edge slope. Since ignores , we just plug .
- . Why? Midpoint . The -shift is irrelevant because has no .
- . Why? Same midpoint, same value — with no -dependence, always for pure- problems.
- . Why? Right edge .
- . The bracket is , so
Verify: Exact . RK4 error . This is Cell A's whole point: when , RK4 is Simpson's rule and is exact on polynomials up to degree 3. See Simpson's Rule.
Cell B — linear mixed slope
Forecast: Exact solution is , so . Predict RK4 matches to ~5 decimals.

Figure 2 (Cell B): the true curve from to , with the four slope samples as short line segments at their sample points — see how each successive segment tilts a little steeper.
- . Why? Left slope.
- . Why? Midpoint , shifted by .
- . Why? Refined midpoint, shifted by .
- . Why? Right edge, shifted by full .
Verify: ; our matches. Error — textbook 4th-order behaviour.
Cell C — negative / decaying slope
Forecast: Exact is , so . The naive worry: could RK4 overshoot below zero? Guess: no, it stays positive.

Figure 3 (Cell C): the decaying curve ; every slope sample points downward (negative), but the arrows get shorter as drops — the picture of a self-limiting decay that never dives below zero.
- . Why? Slope at start; the negative sign says "go down".
- . Why? Midpoint is lower than start, so the downward slope is gentler.
- . Why? Refined midpoint.
- . Why? Right edge has dropped further.
Verify: ; error (larger step, still tiny). Crucially — RK4's averaged slope tracks the decaying curve rather than firing straight down like Euler (which would give , way low). Compare with Euler's Method.
Cell D — nonlinear in
Forecast: Exact is (it blows up at !). So . Predict RK4 close to that.

Figure 4 (Cell D): the curve steepening toward its blow-up at ; the four slope arrows visibly lengthen from to because squaring amplifies each -shift.
- . Why? Slope .
- . Why? Midpoint ; squaring amplifies the shift.
- . Why? Refined midpoint .
- . Why? Right edge .
Verify: ; error . Even near a singularity (far away here), RK4 shines because it senses the steepening slope through the midpoint refinements.
Cell E — zero / degenerate inputs (two flavours)
Forecast: With zero slope, cannot change. Answer should be exactly .
- . Why? Slope is everywhere.
- . Why? Still zero even after any -shift, since .
- , . Why? Same reasoning — nothing to sample.
Verify: Exact . Error . Sanity floor: if the true solution is constant, RK4 leaves it constant.
Forecast: Exact is , so . The trap: seeing and wrongly concluding " doesn't change". It does — later stages sample nonzero slopes.

Figure 5 (Cell E2): the parabola ; the left-edge arrow is perfectly flat (), yet the midpoint and right-edge arrows tilt up — the curve climbs from to despite the flat start.
- . Why? Slope at the left edge — genuinely flat here.
- . Why? Midpoint ; the -shift is irrelevant since has no , but has moved so the slope is now .
- . Why? Same midpoint ; equals (pure- integrand).
- . Why? Right edge , slope .
Verify: Exact . Error (pure-, so Simpson-exact). Lesson: never stop marching just because — always compute all four stages.
Cell F — multi-step march
Forecast: Same ODE as Ex 2 but reached in two small steps. Two steps of should beat one step of (Ex 2 result ). Predict and slightly more accurate.

Figure 6 (Cell F): two consecutive RK4 steps stitched along ; the first step lands at , and the second starts from that point to reach — the picture of errors chaining step to step.
Step 1 (from the parent note's Worked Example 1): at . Why reuse? Identical arithmetic to the parent; we start the second step from here.
Step 2 (from , , ):
- . Why? New left edge.
- . Why? Midpoint .
- . Why? Refined midpoint.
- . Why? Right edge .
Verify: Exact . Two small steps land essentially bang-on. Lesson: halving shrinks global error by — the "4th order" promise (see Local vs Global Truncation Error).
Cell G — large step / limiting behaviour
Forecast: Exact is . Euler would give . RK4 with a huge step — guess it still gets within ~1%.
- . Why? Slope .
- . Why? Midpoint .
- . Why? Refined midpoint.
- . Why? Right edge .
Verify: ; error . And the beautiful identity: the first five terms of at . RK4 reproduces the Taylor series through the term exactly — this is why it is "4th order" (compare Taylor Series Methods). The missing piece is precisely the local error, visible because is large.

Figure 7 (Cell G): the true (dashed navy) against Euler's single left-slope line (orange, landing at ) and RK4's four sampled slopes (magenta dots) that bend the path up to — a labelled snapshot of why sampling many slopes wins.
Cell H — real-world word problem
Forecast: Coffee cools toward . Exact: , so . Predict RK4 close to .

Figure 8 (Cell H): the cooling curve dropping from toward the dashed room-temperature line at ; the four slope samples show cooling slowing as approaches the room — the curve never crosses below .
Here , units ; each has units (slope minutes).
- . Why? Left slope: hot coffee cools fast.
- . Why? Midpoint .
- . Why? Refined midpoint .
- . Why? Right edge .
Verify: Exact ; error . Units check: every is in , the update adds to ✓. Physically sound: temperature dropped but stayed well above room's .
Cell I — exam-style twist
Forecast: Slope is positive (both ), so grows. Rough guess: , so over minutes rises ~-ish beyond simple estimate — expect .

Figure 9 (Cell I): the exact solution climbing from to ; the four slope arrows (all upward) grow because both and increase across the step.
- . Why? Left edge , .
- . Why? Midpoint , .
- . Why? Refined midpoint .
- . Why? Right edge , .
Verify: Separable exact solution: . At : . At : . Our RK4 gives — matches to 4 decimals. Forecast of was in the right ballpark. ✓
The matrix, all green
Every cell A–I now has a fully worked, verified example (with E split into E1 and E2). Sign flips (C), zeros both total and partial (E1, E2), nonlinearity (D, I), chaining (F), stress steps (G), and a units-bearing story (H) are all covered — you should never meet an RK4 scenario this page did not rehearse.
Recall Self-test before you close
Which cell tests that RK4 = Simpson? ::: Cell A (pure- integrand, Ex 1). Why must you keep computing when ? ::: Later stages () may sample nonzero slopes — see Ex 5b where climbs despite . Why did the coffee stay above ? ::: The slope as ; cooling slows near room temperature. In Ex 7, what do represent? ::: The first five Taylor terms of — proof RK4 matches Taylor through . Halving improves global error by what factor? ::: About (4th-order convergence).
Connections
- Euler's Method — the undershooting single-slope baseline (Ex 3, Ex 7).
- Modified Euler / Heun's Method — 2nd-order sibling for comparison.
- Simpson's Rule — exactly what Cell A / Ex 1 reduces to.
- Taylor Series Methods — the target series Ex 7 reproduces.
- Local vs Global Truncation Error — the rule in Ex 6.
- Adaptive Step Size (RKF45) — how to pick automatically for cells like G.