# 龙格－库塔法

## 经典四阶龙格库塔法

$y' = f(t, y), \quad y(t_0) = y_0$

$y_{n+1} = y_n + {h \over 6} (k_1 + 2k_2 + 2k_3 + k_4)$

$k_1 = f \left( t_n, y_n \right)$
$k_2 = f \left( t_n + {h \over 2}, y_n + {h \over 2} k_1 \right)$
$k_3 = f \left( t_n + {h \over 2}, y_n + {h \over 2} k_2 \right)$
$k_4 = f \left( t_n + h, y_n + hk_3 \right)$

• k1是时间段开始时的斜率；
• k2是时间段中点的斜率，通过欧拉法采用斜率k1来决定y在点tn + h/2的值；
• k3也是中点的斜率，但是这次采用斜率k2决定y值；
• k4是时间段终点的斜率，其y值用k3决定。

$\mbox{slope} = \frac{k_1 + 2k_2 + 2k_3 + k_4}{6}.$

RK4法是四阶方法，也就是说每步的误差是h5，而总积累误差为h4阶。

## 显式龙格库塔法

$y_{n+1} = y_n + h\sum_{i=1}^s b_i k_i,$

$k_1 = f(t_n, y_n), \,$
$k_2 = f(t_n+c_2h, y_n+a_{21}hk_1), \,$
$k_3 = f(t_n+c_3h, y_n+a_{31}hk_1+a_{32}hk_2), \,$
$\vdots$
$k_s = f(t_n+c_sh, y_n+a_{s1}hk_1+a_{s2}hk_2+\cdots+a_{s,s-1}hk_{s-1}).$

(注意：上述方程在不同著述中有不同但却等价的定义)。

 0 $c_2$ $a_{21}$ $c_3$ $a_{31}$ $a_{32}$ $\vdots$ $\vdots$ $\ddots$ $c_s$ $a_{s1}$ $a_{s2}$ $\cdots$ $a_{s,s-1}$ $b_1$ $b_2$ $\cdots$ $b_{s-1}$ $b_s$

$\sum_{j=1}^{i-1} a_{ij} = c_i\ \mathrm{for}\ i=2, \ldots, s.$

### 例子

RK4法处于这个框架之内。其表为：

 0 1/2 1/2 1/2 0 1/2 1 0 0 1 1/6 1/3 1/3 1/6

 0 1

## 隐式龙格库塔方法

$y_{n+1} = y_n + \sum_{i=1}^s b_i k_i,$

where

$k_i = hf\left( t_n + c_i h, y_n + \sum_{j=1}^s a_{ij} k_j \right), \quad i = 1, \ldots, s.$

$\begin{array}{c|cccc} c_1 & a_{11} & a_{12}& \dots & a_{1s}\\ c_2 & a_{21} & a_{22}& \dots & a_{2s}\\ \vdots & \vdots & \vdots& \ddots& \vdots\\ c_s & a_{s1} & a_{s2}& \dots & a_{ss} \\ \hline & b_1 & b_2 & \dots & b_s\\ \end{array} = \begin{array}{c|c} \mathbf{c}& A\\ \hline & \mathbf{b^T} \\ \end{array}$

## 参考

• George E. Forsythe, Michael A. Malcolm, and Cleve B. Moler. Computer Methods for Mathematical Computations. Englewood Cliffs, NJ: Prentice-Hall, 1977. (See Chapter 6.)
• Ernst Hairer, Syvert Paul Nørsett, and Gerhard Wanner. Solving ordinary differential equations I: Nonstiff problems, second edition. Berlin: Springer Verlag, 1993. ISBN 3-540-56670-8.
• William H. Press, Brian P. Flannery, Saul A. Teukolsky, William T. Vetterling. Numerical Recipes in C. Cambridge, UK: Cambridge University Press, 1988. (See Sections 16.1 and 16.2.)