# 龙格－库塔法

## 四阶龙格－库塔法

${\displaystyle y'=f(t,y),\quad y(t_{0})=y_{0}}$

${\displaystyle y_{n+1}=y_{n}+{h \over 6}(k_{1}+2k_{2}+2k_{3}+k_{4})}$

${\displaystyle k_{1}=f\left(t_{n},y_{n}\right)}$
${\displaystyle k_{2}=f\left(t_{n}+{h \over 2},y_{n}+{h \over 2}k_{1}\right)}$
${\displaystyle k_{3}=f\left(t_{n}+{h \over 2},y_{n}+{h \over 2}k_{2}\right)}$
${\displaystyle 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决定。

${\displaystyle {\mbox{slope}}={\frac {k_{1}+2k_{2}+2k_{3}+k_{4}}{6}}.}$

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

## 显式龙格－库塔法

${\displaystyle y_{n+1}=y_{n}+h\sum _{i=1}^{s}b_{i}k_{i},}$

${\displaystyle k_{1}=f(t_{n},y_{n}),\,}$
${\displaystyle k_{2}=f(t_{n}+c_{2}h,y_{n}+a_{21}hk_{1}),\,}$
${\displaystyle k_{3}=f(t_{n}+c_{3}h,y_{n}+a_{31}hk_{1}+a_{32}hk_{2}),\,}$
${\displaystyle \vdots }$
${\displaystyle k_{s}=f(t_{n}+c_{s}h,y_{n}+a_{s1}hk_{1}+a_{s2}hk_{2}+\cdots +a_{s,s-1}hk_{s-1}).}$

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

 0 ${\displaystyle c_{2}}$ ${\displaystyle a_{21}}$ ${\displaystyle c_{3}}$ ${\displaystyle a_{31}}$ ${\displaystyle a_{32}}$ ${\displaystyle \vdots }$ ${\displaystyle \vdots }$ ${\displaystyle \ddots }$ ${\displaystyle c_{s}}$ ${\displaystyle a_{s1}}$ ${\displaystyle a_{s2}}$ ${\displaystyle \cdots }$ ${\displaystyle a_{s,s-1}}$ ${\displaystyle b_{1}}$ ${\displaystyle b_{2}}$ ${\displaystyle \cdots }$ ${\displaystyle b_{s-1}}$ ${\displaystyle b_{s}}$

${\displaystyle \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

## 隐式龙格－库塔法

${\displaystyle y_{n+1}=y_{n}+h\sum _{i=1}^{s}b_{i}k_{i},}$

${\displaystyle k_{i}=f\left(t_{n}+c_{i}h,y_{n}+h\sum _{j=1}^{s}a_{ij}k_{j}\right),\quad i=1,\ldots ,s.}$

${\displaystyle {\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.)