Beyond the HSC: Tackling Differential Equations with the Runge-Kutta Method
In the HSC course we focus on finding exact closed‑form solutions to differential equations, but many real‑world models cannot be cracked with algebra alone. This enrichment problem walks you through the Runge‑Kutta 4th Order (RK4) method, a numerical workhorse used in engineering and physics, and shows you exactly how it matches an exact solution you already know. By working the steps side‑by‑side, you’ll see how numerical approximations are built from the very same calculus ideas you’ve been using all year, and you’ll gain a powerful tool for tackling equations that go beyond the syllabus.
Problem Statement
If you are studying HSC Mathematics Extension 1 or 2, you’ve likely encountered differential equations (DEs). You’ve learned elegant algebraic methods to find exact solutions—separating variables, integrating, and solving for .
But what happens when you hit a differential equation that can't be integrated using standard HSC techniques? In real-world physics, engineering, and computer science, exact solutions are often mathematically impossible to find. Instead, we turn to numerical methods to approximate the solution.
Today, as an enrichment extension to your HSC studies, we are going to look at the Runge-Kutta 4th Order method (RK4)—the absolute workhorse of computational mathematics.
The Problem: A Simple Decay Model
Let’s take a differential equation that we can solve using Extension 2 methods, so we have a benchmark to compare our numerical approximation against.
Consider the initial value problem:
Given the initial condition .
Our goal is to find the value of when .
Hints
Consider solving the separable differential equation analytically first to find the exact solution before applying the RK4 numerical method.
Solutions
Method 1: The Traditional (Exact) HSC Way
Because this equation is separable, we can find the exact analytical solution. We start by moving the ‑terms to one side and the ‑terms to the other.
- Separate the variables:
Now we integrate both sides. The left integral is the natural log, and the right is a simple power rule.
- Integrate both sides:
To solve for , we exponentiate both sides, allowing the constant to absorb the sign from the absolute value.
- Solve for :
We pin down the constant by substituting the given initial condition .
- Apply the initial condition ():
So, our exact solution is .
To find the exact value at :
Method 2: The RK4 Numerical Approach
Instead of integrating, numerical methods take small "steps" along the curve. The basic idea is to calculate the slope (the derivative) at your current point, and use it to step forward by a small amount, .
While simpler methods (like Euler's Method) just use one slope, RK4 takes a weighted average of four different slopes () across the interval to get an incredibly accurate next step. The first slope, , is simply the derivative at the start of the step.
Here is the RK4 formula for a step size :
Let's apply this to our DE , starting at with a step size of .
- (Slope at the start):
We use to approximate the value of halfway through the interval, then evaluate the derivative at that midpoint to get .
- (Slope at the midpoint using ):
Similarly, we re‑estimate the midpoint slope, this time using to nudge , giving us .
- (Slope at the midpoint using ):
Finally, we advance a full step using and evaluate the derivative at the end of the interval to get .
- (Slope at the end using ):
Now, plug these four slopes into the main formula to find our new value. The weighted average gives a very precise estimate of the overall slope over the step.
The Verdict: Comparing the Methods
Let's look at the results at :
- Exact Calculus Solution:
- RK4 Approximation:
With just a single step, the RK4 method matched our exact analytical solution out to the 8th decimal place.
This is exactly why RK4 is so highly regarded. While it requires more arithmetic than basic algebraic integration, it allows us to crack complex differential equations that would otherwise be impossible to solve by hand.
Takeaways
Where to Go Next
Understanding the mathematics behind RK4 is just the beginning. If you are looking to push your mathematics and problem-solving skills further before university, here is how you can expand on this:
- Compare with Euler's Method: Try solving the same equation using Euler's method. You will quickly see how much faster the error accumulates compared to RK4.
- Write a Python Script: Calculating through by hand gets tedious. This algorithm is perfectly suited for automation. Try writing a simple Python loop that calculates RK4 over 100 steps.
- Data Visualization: Once you have generated the data points in Python, use a library like
matplotlibto plot your RK4 curve against the exact solution. - Performance Analysis: Experiment with your code. What happens to your error margin if you change the step size from to ? At what point does the computational cost outweigh the gain in precision?
Conclusion
The mathematics you learn in HSC Extension 1 and 2—calculus, functions, and algebra—form the fundamental vocabulary needed for higher-level problem solving. But as you transition into university-level STEM fields, the focus shifts from finding perfectly clean, exact solutions, to building robust, algorithmic approximations. Mastering numerical methods like RK4 is your first step into the world of computational engineering and applied mathematics.
Further Readings