The workhorse of numerical differential equations
Why Runge-Kutta? The RK4 method is considered the workhorse of numerical methods in science and engineering. It provides exceptional accuracy with manageable computational cost. You will encounter RK4 in:
Euler's method uses a single slope evaluation at the beginning of each step, giving accuracy. Runge-Kutta methods use multiple slope evaluations at strategic points to achieve higher-order accuracy. The 4th-order method (RK4) uses four slope evaluations to achieve accuracy.
Definition: Fourth-Order Runge-Kutta (RK4)
Given with initial condition and step size , the RK4 step is:
: Slope at the start of the interval:
: Slope at the midpoint using to estimate the midpoint value
: Slope at the midpoint using (a refined estimate)
: Slope at the end of the interval using
The final update uses a weighted average of these four slopes:
This weighting (Simpson's rule-like) gives extraordinary accuracy by sampling the slope in a strategic pattern.
Theorem: RK4 Error
Local Truncation Error:
Global Error:
RK4 is a fourth-order method. To reduce error by a factor of 16, halve the step size .
Quick Reference: Comparing Numerical Methods
| Method | Order | Evaluations per Step | Typical Use |
|---|---|---|---|
| Euler | 1 | Quick sketches, educational purposes | |
| Improved Euler (RK2) | 2 | Better accuracy, simple code | |
| RK4 | 4 | Standard default for production code |
Problem: Solve , , with . Find .
Setup: , , ,
| Step | Calculation | Value |
|---|---|---|
| 1 | ||
| 1.05 | ||
| 1.0525 | ||
| 1.10525 |
RK4 Update:
Exact solution: , so
Error: (microscopic!)
Compare with Euler: Euler gives with error — about 59,000 times larger!
Problem: Solve , , with . Find .
We compute 5 steps, each with the full RK4 formula. Here's a summary table:
| 0 | 0.0 | 1.0000 | 1.0000 | 1.2000 | 1.2200 | 1.4440 |
| 1 | 0.2 | 1.2428 | 1.4428 | 1.6871 | 1.7115 | 1.9851 |
| 2 | 0.4 | 1.5836 | 1.9836 | 2.2820 | 2.3118 | 2.6460 |
| 3 | 0.6 | 2.0442 | 2.6442 | 3.0086 | 3.0451 | 3.4532 |
| 4 | 0.8 | 2.6510 | 3.4510 | 3.8961 | 3.9407 | 4.4392 |
| 5 | 1.0 | 3.4365 | — | — | — | — |
RK4 Result:
Exact solution: , so
Error: (excellent accuracy for 5 steps with )
Problem: Solve , , with . Find .
This problem has an exact solution: , so
Using RK4 with only 4 steps ():
| Step | RK4 | Exact | Error | |
|---|---|---|---|---|
| 0 | 0.0 | 1.00000 | 1.00000 | 0.00000 |
| 1 | 0.25 | 0.93941 | 0.93941 | 0.00000 |
| 2 | 0.50 | 0.77848 | 0.77880 | 0.00032 |
| 3 | 0.75 | 0.55383 | 0.55432 | 0.00049 |
| 4 | 1.0 | 0.36779 | 0.36788 | 0.00009 |
Result: RK4 with just 4 steps gives , accurate to 4 decimal places! The error is only .
Problem: Solve , to with . Compare three methods.
Exact solution:
| Method | Error | Functions Called | |
|---|---|---|---|
| Euler | 2.2500 | 0.4683 | 2 |
| Improved Euler (RK2) | 2.6406 | 0.0777 | 4 |
| RK4 | 2.71735 | 0.00093 | 8 |
| Exact | 2.71828 | — | — |
Observation: RK4 with 8 function evaluations gives error , while Euler with 2 evaluations gives error — RK4 is 500 times more accurate for the same computational work!
Problem: Solve the system:
with . Compute one step.
For systems, RK4 uses vector slopes. Let and .
At step 0: ,
| Slope | (for ) | (for ) |
|---|---|---|
RK4 Updates:
Result:
Exact solution: , (unit circle)
At :
Error: Tiny! RK4 perfectly captures circular motion.
Test your understanding with these multiple-choice questions. Click a choice to check your answer.
0 / 6 correct
For , , what is ?
In RK4, is evaluated at which point?
The RK4 update formula uses the weight . What is the coefficient of in this formula?
What is the global error order of the RK4 method?
To reduce the global error by a factor of 256, by what factor should you decrease in RK4?
Which of the following is not a common application of RK4?
RK4 Formula at a Glance
Key Facts