Overview
Test Series
The Runge-Kutta method is a popular and effective way to solve ordinary differential equations (ODEs), especially when we know the starting value (initial value problem). It gives more accurate results than simple methods like Euler’s method and does not need complicated higher-order derivatives.
Among the different Runge-Kutta methods, the 4th order Runge-Kutta method (often called RK4) is the most widely used. It works by estimating four different slopes (or values of the function’s rate of change) at each step. These slopes are then combined in a smart way to give a better estimate of the next value. This makes the method both accurate and easy to apply using just the original function, without needing its higher derivatives.
Maths Notes Free PDFs
Topic | PDF Link |
---|---|
Class 12 Maths Important Topics Free Notes PDF | Download PDF |
Class 10, 11 Mathematics Study Notes | Download PDF |
Most Asked Maths Questions in Exams | Download PDF |
Increasing and Decreasing Function in Maths | Download PDF |
The Taylor series method needs you to find higher-order derivatives (like second, third, and so on) of a function. This can be hard and take a lot of time, especially for complex equations.
The Runge-Kutta method makes things easier. It turns the problem into a series of simple first-order equations and uses step-by-step calculations to find the solution at different points.
There are different levels (or orders) of the Runge-Kutta method:
1st Order:
\(y_{n+1} = y_n + hf(x_n, y_n)\)
2nd Order:
\(y_{n+1} = y_n + hf\left(x_n + \frac{h}{2}, y_n + \frac{h}{2}f(x_n, y_n)\right)\)
3rd Order:
\(y_{n+1} = y_n + \frac{h}{6}\left(k_1 + 4k_2 + k_3\right)\)
where \(h\) represents the step size, \(x_n\) and \(y_n\) are the values of the independent and dependent variables at the current step, \(f(x_n, y_n)\) is the derivative function, and \(k_1\), \(k_2\), and \(k_3\) are intermediate calculations based on the derivative function.
The 4th order Runge-Kutta method approximates the curve of the function f between two points by a 4th degree polynomial. It requires 4 slope estimates at each step.
Geometrically, we can visualize the curve between two points as part of a 4th degree polynomial. The 4th order Runge-Kutta method finds 4 tangents to this curve at evenly spaced points, and uses the average of their slopes as an approximation of the entire curve between the two points.
The formula for Runge-kutta 4th order is: \( y_{n+1} = y_n + \frac{h}{6} \left(k_1 + 2k_2 + 2k_3 + k_4\right) \)
Where,
\(k_1 = hf(x_n, y_n)\)
\(k_2 = hf\left(x_n + \frac{h}{2}, y_n + \frac{k_1}{2}\right)\)
\(k_3 = hf\left(x_n + \frac{h}{2}, y_n + \frac{k_2}{2}\right)\)
\(k_4 = hf(x_n + h, y_n + k_3)\)
The slope estimates \(k_1, k_2, k_3\) and \(k_4\) correspond to tangents at the beginning, middle and end of the interval respectively. Taking the average of these 4 slopes gives a good approximation of the entire curve between the two points.
Runge kutta 4th order method algorithm is as follows
Step : 1 Start
Step : 2 Now describe the function f (x,y)
Step : 3 Read the starting condition values \(x_{0},y_{0}\) the number of steps (n), and the calculation point. \(x_{n}\)
Step : 4 Calculate the size step \((h)= \frac{(x_{n} - x_{0})}{n}\)
Step : 5 Set, i = 0
Step : 6 Loop
\(k_{1} = h \ast f (x_{0},y_{0})\)
\(k_2 = {-b \pm \sqrt{b^2-4ac} \over 2a}\)
\(k_3 = {-b \pm \sqrt{b^2-4ac} \over 2a}\)
\(k_{4} = h\ast f(x_{0} + h, y_{0} + k_{3})\)
\(k = \frac{(k_{1} + 2\ast k_{2} + 2\ast k_{3}+k_{4})}{6}\)
\(y_{n} = y_{0} + k\)
i = i +1
\(x_{0} = x_{0} + h\)
\(y_{0} = y_{n}\)
Step : 7 Show \(y_{n}\) as the outcome.
Step : 8 Stop
#include <stdio.h>
/ Function to calculate the derivative dy/dx
double derivative(double x, double y) {
/ Define the derivative function here
double dy_dx = /* Insert the expression for dy/dx */;
return dy_dx;
}
/ Function to implement the fourth-order Runge-Kutta method
double rungeKutta(double x0, double y0, double x, double h) {
int n = (int)((x - x0) / h); / Number of iterations
double y = y0;
for (int i = 1; i <= n; i++) {
double k1 = h * derivative(x0, y);
double k2 = h * derivative(x0 + 0.5 * h, y + 0.5 * k1);
double k3 = h * derivative(x0 + 0.5 * h, y + 0.5 * k2);
double k4 = h * derivative(x0 + h, y + k3);
/ Calculate the next value of y
y = y + (1.0 / 6.0) * (k1 + 2 * k2 + 2 * k3 + k4);
x0 = x0 + h; / Increment x
}
return y;
}
}
This C program calculates the value of y at a given x using the fourth-order Runge-Kutta method.
The Runge-Kutta method offers several advantages in numerical computations for solving ordinary differential equations (ODEs). These advantages include:
Parameter |
Runge-Kutta 3rd Order |
Runge-Kutta 4th Order |
Formula |
\(k_1 = h \cdot f(t_n, y_n)\) <br> \(k_2 = h \cdot f(t_n + \frac{h}{2}, y_n + \frac{k_1}{2})\) <br> \(k_3 = h \cdot f(t_n + h, y_n - k_1 + 2k_2)\) <br> \(y_{n+1} = y_n + \frac{k_1 + 4k_2 + k_3}{6}\) |
\(k_1 = h \cdot f(t_n, y_n)\) <br> \(k_2 = h \cdot f(t_n + \frac{h}{2}, y_n + \frac{k_1}{2})\) <br> \(k_3 = h \cdot f(t_n + \frac{h}{2}, y_n + \frac{k_2}{2})\) <br> \(k_4 = h \cdot f(t_n + h, y_n + k_3)\) <br> \(y_{n+1} = y_n + \frac{k_1 + 2k_2 + 2k_3 + k_4}{6}\) |
Accuracy |
Less accurate compared to the fourth order |
More accurate, provides better approximations |
Number of Function Evaluations |
Requires three function evaluations at each step |
Requires four function evaluations at each step |
Computational Complexity |
Less computationally expensive |
Slightly more computationally expensive |
Stability |
Less stable for stiff systems |
More stable for a wider range of systems |
Error Control |
Limited error control capabilities |
Allows for adaptive step size control and error estimation |
Applications |
Suitable for general-purpose problems |
Preferred for problems requiring high accuracy |
Example 1: Find the value of k₁ using the Runge-Kutta 4th order method, if
dy/dx = x + 2y², and y(0.2) = 1.05, with step size h = 0.1.
Solution:
We are given:
Step 1: Identify the function
f(x, y) = x + 2y²
Step 2: Apply the Runge-Kutta formula to find k₁
k₁ = h × f(x₀, y₀)
Substitute the values:
k₁ = 0.1 × f(0.2, 1.05)
= 0.1 × [0.2 + 2 × (1.05)²]
= 0.1 × [0.2 + 2 × 1.1025]
= 0.1 × [0.2 + 2.205]
= 0.1 × 2.405
= 0.2405
Answer: The value of k₁ is 0.2405.
Example 2: Find the value of k₁ using the Runge-Kutta 4th order method, if
dy/dx = x² + y, and y(0.5) = 1.2, with step size h = 0.1.
Solution:
We are given:
Step 1: Identify the function
f(x, y) = x² + y
Step 2: Apply the Runge-Kutta formula to find k₁
k₁ = h × f(x₀, y₀)
Substitute the values:
k₁ = 0.1 × f(0.5, 1.2)
= 0.1 × [(0.5)² + 1.2]
= 0.1 × [0.25 + 1.2]
= 0.1 × 1.45
= 0.145
Answer:The value of k₁ is 0.145
If you want to score well in your math exam then you are at the right place. Here you will get weekly test preparation, live classes, and exam series. Download the Testbook App now to prepare a smart and high-ranking strategy for the exam.
Download the Testbook APP & Get Pass Pro Max FREE for 7 Days
Download the testbook app and unlock advanced analytics.