Skip to content

Commit 0e6cd9c

Browse files
authored
Update runge_kutta.md
1 parent 05387a0 commit 0e6cd9c

File tree

1 file changed

+23
-23
lines changed

1 file changed

+23
-23
lines changed

notes/7_ordinary_differential_equations/runge_kutta.md

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -6,51 +6,51 @@ The Runge-Kutta method is part of a family of iterative methods, both implicit a
66

77
The first-order ODE that is typically used in the Runge-Kutta methods takes the following form:
88

9-
$$ \frac{du}{dt} = f(t, u), $$
9+
$$ \frac{du}{dt} = f(t, u)$$
1010

1111
In this equation, $u$ is the unknown function of time $t$ that we are aiming to solve for, and $f$ is a function of $t$ and $u$.
1212

1313
The general formulation of the 4th order Runge-Kutta method is presented below:
1414

15-
$$k_1 = \Delta t \cdot f(t, u),$$
15+
$$k_1 = \Delta t \cdot f(t, u)$$
1616

17-
$$k_2 = \Delta t \cdot f\left(t + \frac{\Delta t}{2}, u + \frac{k_1}{2}\right),$$
17+
$$k_2 = \Delta t \cdot f\left(t + \frac{\Delta t}{2}, u + \frac{k_1}{2}\right)$$
1818

19-
$$k_3 = \Delta t \cdot f\left(t + \frac{\Delta t}{2}, u + \frac{k_2}{2}\right),$$
19+
$$k_3 = \Delta t \cdot f\left(t + \frac{\Delta t}{2}, u + \frac{k_2}{2}\right)$$
2020

21-
$$k_4 = \Delta t \cdot f(t + \Delta t, u + k_3),$$
21+
$$k_4 = \Delta t \cdot f(t + \Delta t, u + k_3)$$
2222

23-
$$u(t + \Delta t) = u(t) + \frac{1}{6}(k_1 + 2k_2 + 2k_3 + k_4).$$
23+
$$u(t + \Delta t) = u(t) + \frac{1}{6}(k_1 + 2k_2 + 2k_3 + k_4)$$
2424

2525
### Derivation of Runge-Kutta Method
2626

2727
The derivation of the Runge-Kutta methods, especially the 4th order Runge-Kutta method, begins with an initial condition and attempts to estimate the solution value after a small step $\Delta t$. This is achieved by taking weighted averages of increments at the beginning, middle, and end of the interval. The purpose is to imitate a Taylor series expansion, but without the necessity of computing higher derivatives.
2828

2929
Starting with a Taylor series expansion, we get:
3030

31-
$$u(t+\Delta t) = u(t) + \Delta t u'(t) + \frac{\Delta t^2}{2!} u''(t) + \frac{\Delta t^3}{3!} u'''(t) + \frac{\Delta t^4}{4!} u''''(t) + O(\Delta t^5).$$
31+
$$u(t+\Delta t) = u(t) + \Delta t u'(t) + \frac{\Delta t^2}{2!} u''(t) + \frac{\Delta t^3}{3!} u'''(t) + \frac{\Delta t^4}{4!} u''''(t) + O(\Delta t^5)$$
3232

3333
The first derivative $u'(t)$ is already provided by the ODE:
3434

35-
$$u'(t) = f(t, u).$$
35+
$$u'(t) = f(t, u)$$
3636

3737
Higher-order derivatives can also be represented in terms of $f(t, u)$ and its derivatives:
3838

39-
$$u''(t) = \frac{df}{dt} = \frac{\partial f}{\partial t} + \frac{\partial f}{\partial u} \frac{du}{dt} = \frac{\partial f}{\partial t} + \frac{\partial f}{\partial u} f,$$
39+
$$u''(t) = \frac{df}{dt} = \frac{\partial f}{\partial t} + \frac{\partial f}{\partial u} \frac{du}{dt} = \frac{\partial f}{\partial t} + \frac{\partial f}{\partial u} f$$
4040

4141
The Runge-Kutta method is designed to mimic the above Taylor series expansion by taking a suitable weighted average of increments at the start, middle, and end of the interval. It avoids explicitly calculating higher derivatives of $f(t, u)$, instead approximating these increments by evaluating $f(t, u)$ at several points within the interval.
4242

4343
The 4th order Runge-Kutta method is thus given by:
4444

45-
$$k_1 = \Delta t \cdot f(t, u),$$
45+
$$k_1 = \Delta t \cdot f(t, u)$$
4646

47-
$$k_2 = \Delta t \cdot f\left(t + \frac{\Delta t}{2}, u + \frac{k_1}{2}\right),$$
47+
$$k_2 = \Delta t \cdot f\left(t + \frac{\Delta t}{2}, u + \frac{k_1}{2}\right)$$
4848

49-
$$k_3 = \Delta t \cdot f\left(t + \frac{\Delta t}{2}, u + \frac{k_2}{2}\right),$$
49+
$$k_3 = \Delta t \cdot f\left(t + \frac{\Delta t}{2}, u + \frac{k_2}{2}\right)$$
5050

51-
$$k_4 = \Delta t \cdot f(t + \Delta t, u + k_3),$$
51+
$$k_4 = \Delta t \cdot f(t + \Delta t, u + k_3)$$
5252

53-
$$u(t + \Delta t) = u(t) + \frac{1}{6}(k_1 + 2k_2 + 2k_3 + k_4),$$
53+
$$u(t + \Delta t) = u(t) + \frac{1}{6}(k_1 + 2k_2 + 2k_3 + k_4)$$
5454

5555
In this method, the weights of $k_1, k_2, k_3, k_4$ (1/6, 1/3, 1/3, 1/6) are chosen such that the error term is $O(\Delta t^5)$, indicating that the local truncation error at each step is proportional to the fifth power of the step size, and the global truncation error (after $N$ steps) is proportional to the fourth power of the step size.
5656

@@ -73,13 +73,13 @@ with the initial condition $u(0)=1$. We want to estimate the value of $u$ at $t
7373

7474
First, we calculate the four increments:
7575

76-
$$k_1 = \Delta t \cdot f(t, u) = 0.05 \cdot 1 = 0.05,$$
76+
$$k_1 = \Delta t \cdot f(t, u) = 0.05 \cdot 1 = 0.05$$
7777

78-
$$k_2 = \Delta t \cdot f\left(t + \frac{\Delta t}{2}, u + \frac{k_1}{2}\right) = 0.05 \cdot (1 + 0.05/2) = 0.05125,$$
78+
$$k_2 = \Delta t \cdot f\left(t + \frac{\Delta t}{2}, u + \frac{k_1}{2}\right) = 0.05 \cdot (1 + 0.05/2) = 0.05125$$
7979

80-
$$k_3 = \Delta t \cdot f\left(t + \frac{\Delta t}{2}, u + \frac{k_2}{2}\right) = 0.05 \cdot (1 + 0.05125/2) = 0.0515625,$$
80+
$$k_3 = \Delta t \cdot f\left(t + \frac{\Delta t}{2}, u + \frac{k_2}{2}\right) = 0.05 \cdot (1 + 0.05125/2) = 0.0515625$$
8181

82-
$$k_4 = \Delta t \cdot f(t + \Delta t, u + k_3) = 0.05 \cdot (1 + 0.0515625) = 0.052578125.$$
82+
$$k_4 = \Delta t \cdot f(t + \Delta t, u + k_3) = 0.05 \cdot (1 + 0.0515625) = 0.052578125$$
8383

8484
Then, we calculate the next value of $u$:
8585

@@ -93,21 +93,21 @@ $$u(0.05) = 1.05104166667.$$
9393

9494
Similarly, we first calculate the four increments:
9595

96-
$$k_1 = \Delta t \cdot f(t, u) = 0.05 \cdot 1.05104166667 = 0.0525520833335,$$
96+
$$k_1 = \Delta t \cdot f(t, u) = 0.05 \cdot 1.05104166667 = 0.0525520833335$$
9797

98-
$$k_2 = \Delta t \cdot f\left(t + \frac{\Delta t}{2}, u + \frac{k_1}{2}\right) = 0.05 \cdot (1.05104166667 + 0.0525520833335/2) = 0.0531899049680,$$
98+
$$k_2 = \Delta t \cdot f\left(t + \frac{\Delta t}{2}, u + \frac{k_1}{2}\right) = 0.05 \cdot (1.05104166667 + 0.0525520833335/2) = 0.0531899049680$$
9999

100-
$$k_3 = \Delta t \cdot f\left(t + \frac{\Delta t}{2}, u + \frac{k_2}{2}\right) = 0.05 \cdot (1.05104166667 + 0.0531899049680/2) = 0.0533905595735,$$
100+
$$k_3 = \Delta t \cdot f\left(t + \frac{\Delta t}{2}, u + \frac{k_2}{2}\right) = 0.05 \cdot (1.05104166667 + 0.0531899049680/2) = 0.0533905595735$$
101101

102-
$$k_4 = \Delta t \cdot f(t + \Delta t, u + k_3) = 0.05 \cdot (1.05104166667 + 0.0533905595735) = 0.0552220602058.$$
102+
$$k_4 = \Delta t \cdot f(t + \Delta t, u + k_3) = 0.05 \cdot (1.05104166667 + 0.0533905595735) = 0.0552220602058$$
103103

104104
Then, we calculate the next value of $u$:
105105

106106
$$u(0.1) = u(0.05) + \frac{1}{6}(k_1 + 2k_2 + 2k_3 + k_4)$$
107107

108108
$$u(0.1) = 1.05104166667 + \frac{1}{6}(0.0525520833335 + 2 \cdot 0.0531899049680 + 2 \cdot 0.0533905595735 + 0.0552220602058)$$
109109

110-
$$u(0.1) = 1.10517087727.$$
110+
$$u(0.1) = 1.10517087727$$
111111

112112
### Advantages
113113

0 commit comments

Comments
 (0)