Runge-Kutta (RK4)
The Runge-Kutta (RK4) methods are used to solve the solution of the non-liner ordinary differential equation. Here, we will simply summary this method.
Assume the Intial Value Piont (IVP) is satisfied:
y
′
=
f
(
t
,
y
)
,
y
(
t
0
)
=
y
0
(
1
)
y\prime = f(t,y), \quad y(t_0)=y_0 \quad \quad (1)
y′=f(t,y),y(t0)=y0(1)
The formulation of RK4 is given by:
y
(
n
+
1
)
=
y
n
+
h
6
(
k
1
+
2
k
2
+
2
k
3
+
k
4
)
(
2
)
y_(n+1) = y_n + \frac{h}{6} (k_1+2k_2+2k_3+k_4) \quad \quad (2)
y(n+1)=yn+6h(k1+2k2+2k3+k4)(2)
where,
k
1
=
f
(
t
n
,
y
n
)
k
2
=
f
(
t
n
+
h
2
,
y
n
+
h
2
k
1
)
k
3
=
f
(
t
n
+
h
2
,
y
n
+
h
2
k
2
)
k
4
=
f
(
t
n
+
h
,
y
n
+
h
k
3
)
k_1=f(t_n,y_n) \\ \quad \\ k_2=f(t_n+\frac{h}{2}, y_n+\frac{h}{2} k_1) \\ \quad \\ k_3=f(t_n+\frac{h}{2}, y_n+\frac{h}{2} k_2) \\ \quad \\ k_4=f(t_n+h,y_n+hk_3)
k1=f(tn,yn)k2=f(tn+2h,yn+2hk1)k3=f(tn+2h,yn+2hk2)k4=f(tn+h,yn+hk3)
Here, the
k
i
k_i
ki represent the slope of middle points of the variable time
t
t
t. Will, the Runge-Kutta methods just be generalized by RK4.
In this equation,the next value
y
n
+
1
y_{n+1}
yn+1 is decided by the current value
y
n
y_n
yn adds the time interval
h
h
h and multiply an estimated middle point slope
k
k
k weight averaged by the slope
k
i
k_i
ki:
下一个值
y
n
+
1
y_{n+1}
yn+1 由现在的值
y
n
y_n
yn 加上时间间隔
h
h
h 和一个估算的斜率的乘积所决定。该斜率是以下斜率的加权平均:和一个估算的斜率
k
k
k 的乘积所决定。该斜率是以下斜率的加权平均:
k
=
k
1
+
2
k
2
+
2
k
3
+
k
4
6
(
3
)
k= \frac{k_1+2k_2+2k_3+k_4}{6} \quad \quad (3)
k=6k1+2k2+2k3+k4(3)
k
1
k_1
k1 is the slope of the time beginning. (时间段开始时的斜率)
k
2
k_2
k2 is the slope of the middle time point.
时间段中点的斜率,通过欧拉法采用斜率
k
1
k_1
k1 来决定
y
y
y 在点
t
n
+
h
/
2
t_n+h/2
tn+h/2 的值;
k
3
k_3
k3 is also the slope of the middle time point who’s calculated by slope
k
2
k_2
k2 and the intial value
y
y
y. (也是中点的斜率,但是这次采用斜率
k
2
k_2
k2 决定
y
y
y 值。)
k
4
k_4
k4 is the slope of the time ending. 时间段终点的斜率,其
y
y
y 值用
k
3
k_3
k3决定。
RK4 法是四阶方法,也就是说每步的误差是 h 阶,而总积累误差为 h 阶。
注意 上述公式对于标量或者向量函数(y可以是向量)都适用。
Generalization (推广)
The Runge-Kutta methods are generalized by RK4, which can be formulated as:
y
n
+
1
=
y
n
+
h
∑
i
=
1
n
b
i
k
i
(
4
)
y_{n+1}=y_n+h \sum_{i=1}^{n} b_i k_i \quad \quad (4)
yn+1=yn+hi=1∑nbiki(4)
where,
given the specific problem, the progression
s
s
s and the coefficient
a
i
j
a_{ij}
aij and
c
i
c_i
ci must be provided.
对于给定的一个特定的方法,必须提供整数 s s s(级数),以及系数 a i j a_{ij} aij(对于 1 ≤ j < i ≤ s 1 ≤j<i≤s 1≤j<i≤s), b i b_i bi(对于 i = 1 , 2 , . . . , s i= 1, 2, ...,s i=1,2,...,s)和 c i c_i ci(对于 i = 2 , 3 , . . . , s i= 2, 3, ...,s i=2,3,...,s)。
The Runge-Kutta methods is self-consistent, if:
龙格库塔法是自洽的,如果:
∑
j
=
1
i
−
1
a
i
j
=
c
i
f
o
r
i
=
2
,
…
,
s
.
(
5
)
\sum_{j=1}^{i-1}a_{ij}=c_i \quad for \quad i=2,\dots,s. \quad (5)
j=1∑i−1aij=cifori=2,…,s.(5)