请求证明四阶龙格-库塔法(RK4)为四阶方法
Hey there! Let's dig into why the classic RK4 method is a 4th-order scheme—totally get why deriving the error bound can trip you up, since it involves a lot of Taylor expansions and easy-to-miss cross terms. Let's break this down step by step, focusing on where you might have gone wrong in your initial derivation.
You started with the first two $k$ terms, so let's write out the complete method for clarity:
$$
\begin{align*}
k_1 &= f(t_n, x(t_n)) \
k_2 &= f\left(t_n + \frac{h}{2}, x(t_n) + \frac{h}{2}k_1\right) \
k_3 &= f\left(t_n + \frac{h}{2}, x(t_n) + \frac{h}{2}k_2\right) \
k_4 &= f\left(t_n + h, x(t_n) + hk_3\right) \
x_{n+1} &= x_n + \frac{h}{6}\left(k_1 + 2k_2 + 2k_3 + k_4\right)
\end{align*}
$$
To prove RK4 is 4th-order, we need to:
- Expand the true solution $x(t_{n+1}) = x(t_n + h)$ into its Taylor series up to $h^4$ terms.
- Expand each $k_i$ and the RK4 update formula $x_{n+1}$ up to $h^4$ terms.
- Show that the two expansions are identical for all terms up to $h^4$. This means the local truncation error is $O(h^5)$, making the method 4th-order (global error is $O(h^4)$).
Step 1: Taylor Series of the True Solution
First, let's write out the true solution's expansion using chain rule for derivatives of $x(t)$ (since $x' = f(t,x)$):
$$
x(t_n + h) = x_n + hx_n' + \frac{h^2}{2}x_n'' + \frac{h^3}{6}x_n''' + \frac{h^4}{24}x_n'''' + O(h^5)
$$
Where:
- $x_n' = f(t_n, x_n)$
- $x_n'' = f_t + f f_x$ (partial derivatives of $f$)
- $x_n''' = f_{tt} + 2f f_{tx} + f^2 f_{xx} + f_x(f_t + f f_x)$
- $x_n''''$ is a more complex combination of higher partial derivatives, which we'll match later.
Step 2: Expand Each $k_i$ to $h^3$ Terms
This is where most mistakes happen—missing cross terms when substituting lower-order $k$ values into higher ones. Let's go one by one:
Expand $k_2$
Using the Taylor expansion of a binary function around $(t_n, x_n)$:
$$
k_2 = f_n + \frac{h}{2}(f_t)n + \frac{h}{2}k_1(f_x)n + \frac{h^2}{8}(f{tt} + 2f f{tx} + f^2 f_{xx})n + \frac{h^3}{48}(f{ttt} + 3f f_{ttx} + 3f^2 f_{txx} + f^3 f_{xxx})_n + O(h^4)
$$
Substitute $k_1 = f_n$ here—this part is straightforward.
Expand $k_3$
Now, substitute $k_2$ into the expansion for $k_3$. The key here is that $k_2$ already has $h$ terms, so when we plug it in, we generate extra $h^3$ terms that are easy to overlook:
$$
k_3 = f_n + \frac{h}{2}(f_t)n + \frac{h}{2}k_2(f_x)n + \frac{h^2}{8}(f{tt} + 2k_2 f{tx} + k_2^2 f_{xx})n + O(h^4)
$$
After substituting $k_2$'s full expression and combining like terms, we get:
$$
k_3 = f_n + \frac{h}{2}(f_t + f f_x)n + \frac{h^2}{8}(f{tt} + 2f f{tx} + f^2 f_{xx})n + \frac{h^3}{48}\left(f{ttt} + 3f f_{ttx} + 3f^2 f_{txx} + f^3 f_{xxx} + 3f_x(f_t + f f_x)\right)_n + O(h^4)
$$
That extra $3f_x(f_t + f f_x)$ term is crucial—if you skipped this, you'd lose part of the $h^3$ contribution, throwing off the higher-order terms later.
Expand $k_4$
Finally, expand $k_4$ using $k_3$'s expression. Again, substituting the full $k_3$ (including its $h$ and $h^2$ terms) will generate additional $h^4$ terms that are necessary to match the true solution's expansion:
$$
k_4 = f_n + h(f_t + f f_x)n + \frac{h^2}{2}\left(f{tt} + 2f f_{tx} + f^2 f_{xx} + 2f_x(f_t + f f_x)\right)n + \frac{h^3}{6}\left(f{ttt} + 3f f_{ttx} + 3f^2 f_{txx} + f^3 f_{xxx} + 3f_x(f_{tt} + 2f f_{tx} + f^2 f_{xx}) + 3f_x^2(f_t + f f_x)\right)_n + O(h^4)
$$
Step 3: Combine All Terms in the RK4 Update
Now plug $k_1, k_2, k_3, k_4$ into $x_{n+1} = x_n + \frac{h}{6}(k_1 + 2k_2 + 2k_3 + k_4)$ and compute each order of $h$:
- $h^1$ term: $\frac{h}{6}(f_n + 2f_n + 2f_n + f_n) = hf_n$, which matches $hx_n'$.
- $h^2$ term: $\frac{h}{6}\left(0 + 2*\frac{h}{2}(f_t + f f_x) + 2*\frac{h}{2}(f_t + f f_x) + h(f_t + f f_x)\right) = \frac{h^2}{2}(f_t + f f_x)$, matching $\frac{h^2}{2}x_n''$.
- $h^3$ term: After combining coefficients, this equals $\frac{h^3}{6}x_n'''$, exactly matching the true solution.
- $h^4$ term: This is the make-or-break part. When you carefully add up all the contributions from each $k_i$, you'll find the coefficient matches $\frac{h^4}{24}x_n''''$ perfectly.
Almost certainly, you missed one or more of the cross terms when expanding $k_3$ or $k_4$. For example, when substituting $k_2$ into $k_3$, the $h$ term in $k_2$ multiplies with the $h^2$ term in the Taylor expansion to create an $h^3$ term that's easy to overlook. Without those, your $h^4$ coefficient would not match the true solution, leading you to think the error is third-order.
Once all cross terms are accounted for, the RK4 update formula matches the true solution's Taylor series up to the $h^4$ term. This means the local truncation error is $O(h^5)$, so the method is 4th-order (global error scales with $h^4$).
内容的提问来源于stack exchange,提问作者Dani_5040

