I was studying Runge-Kutta method for solving $\frac{dy}{dt}=f(t,y)$, but I don't understand how can I write $$y_{n+1}=y_n+ak_1+bk_2$$ using the Taylor series where $k_1=\Delta t f(t_n,y_n)$ and $k_2=\Delta t f(t_n+\alpha \Delta t, y_n+\beta k_1)$. The Taylor series for $y_{n+1}=y(t+\Delta t)$ is $$y_{n+1}=y_n+\Delta t f(t_n,y_n)+\Delta tf'(t_n,y_n)/2+...$$ But I don't know how to get the first equation from the Taylor series! Would you please help? This is the actual text of the textbook I'm studying:
- 23,223
- 159
- 1
- 9
-
It's important to remember that the formula $y_{n+1}=y_n+ak_1+bk_2$ is only an approximation for $y(t+\Delta t).$ You also write out the Taylor series for $k_1$ and $k_2$ and plug these into $y_{n+1}=y_n+ak_1+bk_2.$ Now you have $y_{n+1}$ as a series, and $y(t+\Delta t)$ as a series, but they are not guaranteed to be equal and (in the general case) cannot be made equal. Instead of perfect equality, you make as many terms equal as you can. In this case I think you can make the next two terms equal after the $y_n$ term. – David K Jan 13 '22 at 14:10
-
@DavidK Sorry. I still don't get that how by using Taylor series we can write $y_{n+1}=y_n+ak_1+bk_2$. – James Jan 13 '22 at 14:14
-
See https://math.stackexchange.com/questions/3345211/euler-vs-heun-numerical-methods, https://math.stackexchange.com/questions/3244493/what-kind-of-approximation-is-used-in-deriving-runge-kutta-methods, https://math.stackexchange.com/questions/2159825/taylor-expansion, https://math.stackexchange.com/questions/3957088/a-question-regarding-runge-kutta-method-of-order-3 – Lutz Lehmann Jan 13 '22 at 15:09
-
In the piece of text you quoted there is no use of a Taylor series yet. There is only a hint that there will be some Taylor series (more than one!) used later. I would expect to see a little more explanation after the quoted section. Sometimes if something doesn't make sense you need to read ahead a little bit to see where they were intending to go, and then when you go back to where you were it may make more sense. – David K Jan 14 '22 at 00:10
-
By the way, in your Taylor expansion for $y(t+\Delta t)$ you forgot to square the $\Delta t$ in the $(\Delta t)^2$ term. – David K Jan 14 '22 at 00:18
-
Which textbook is that? – Rodrigo de Azevedo May 06 '23 at 18:05
1 Answers
The Taylor formula gives you a different approximation... The Taylor method with order 2 reads $$ y_{n+1} \approx y_n + h f(t_n, y_n) + \frac{h^2}{2} f'(t_n, y_n) $$
The RK2 usual method consists in getting an approximation for the term $f'(t_n,y_n)$:
$$ f'(t_n,y_n) \approx \dfrac{f(t_{n+1},y_{n+1})-f(t_n,y_n)}{h}\approx \dfrac{f(t_{n+1},y_n + hf(t_n,y_n))-f(t_n,y_n)}{h} $$
(in the second step we just use Euler's method to approximate $y_{n+1}$). This way we get $$ y_{n+1} \approx y_n + h f(t_n,y_n) + \frac{h}{2}\left(f(t_{n+1},y_n+h f(t_n,y_n)) - f(t_n,y_n) \right) $$
or
$$ y_{n+1} = y_n + \frac{h}{2}\left(f(t_n,y_n) + f(t_n+h,y_n+h f(t_n,y_n)) \right). $$
This is equivalent to setting \begin{align*} k_1 = &f(t_n'y_n)\\ k_2 = &f(t_n + h, y_n + h k_1)\\ y_{n+1} = & y_n + \frac 12 (k_1+k_2) \end{align*}
Even though the formula corresponds to two crude approximations, it turns out to be second order accurate.
- 23,092
- 1
- 20
- 36
