Heun (which is the improved Euler's method), 2nd order Taylor and Trapezoidal methods
I am a bit confused because I read two different things about the Heun's method and Trapezoidal method.
I cannot understand the difference between them, as I saw that in some places the Hen's method is the same as the explicit Trapezoidal method and in other place I saw that they are just very similar.
I am trying to find the explicit formula of the Trapezoidal method for $Y_{n+1}$
in terms of $t_n,t_{n+1},Y_n$ that uses the RHS of a certain function.
I have the function: $f(t,y)= \frac{8 \cos(4t)+y}{4}$
I found that the formula for the explicit Trapezoidal method is:
$Y_{n+1}=Y_n+\frac{h}{2}f(t_n,Y_n)+ \frac{h}{2}f(t_{n+1},Y_n+hf(t_n,Y_n)$
Because we use Euler's method to replace $Y_{n+1}$ on the RHS by:$ Y_{n+1}=Y_n+hf(t_n,Y_n) $ ( so, by doing this we will obtain the above formula)
Applying this formula in my function the answer will be :
$Y_{n+1}= Y_n+\frac{h}{2}[(\frac{8cos(4t_n)+Y_n}{4})+\frac{h}{2}(\frac{8cos(4t_{n+1})+Y_n}{4}+h(\frac{8cos(4t_n+Y_n}{4})]$
Now I need to know the formula for the Heun's method giving an explicit formula for $Y_{n+1}$ again in terms of $t_n,t_{n+1},Y_n$ that uses the RHS of the same function and I do not know how to do that.
In terms of the Euler's method, it is a explicit method so the formula is given by:
$Y_{n+1}=Y_n+hf(t_n,Y_n)$ which is already in the explicit formula and for my function I will obtain:
$Y_{n+1}=Y_n+h(\frac{8 \cos(4t_n)+y_n}{4})$
For the 2nd order Taylor method I really do not understand this method.
Can anyone help me on this and point me to a website where I can find more information about these methods?
Thanks
Best Answer
Both Explicit Trapezoid method and Heun's method are 2nd order Runge Kutta methods in this form:
$$y_{n+1}=y_n+b_1hf(t_n,y_n)+b_2hf(t_i+c_2h,y_n+a_{21}hf(t_n,y_n)).$$
For them to be second order, they need to satisfy: $$b_1+b_2=1, b_2c_1=1/2, a_{21}b_2=1/2.$$
For Explicit Trapezoid, we have
$$b_1=b_2=1/2, c_2=1, a_{21}=1.$$
For Heun's, we have $$b_1=1/4, b_2=3/4, c_2=2/3, a_{21}=1.$$
For your example, Heun's method gives:
$$y_n+\frac{h}{4}\cdot\frac{8\cos(4t_n)+y_n}{4}+\frac{3h}{4}\frac{8\cos(4(t_n+\frac{2}{3}h))+y_n+h\cdot\frac{8\cos(4t_n)+y_n}{4}}{4}.$$
I think you can find this in any Numerical Analysis book.
Your Trapezoid method formula is correct, but you didn't apply it correctly in your example. It should be:
$$y_n+\frac{h}{2}\frac{8\cos(4t_n)+y_n}{4}+\frac{h}{2}\frac{8\cos(4(t_n+h))+h\frac{8\cos(4t_n)+y_n}{4}}{4}.$$
The 2nd order Taylor method is a totally different method. It uses Taylor expansion, so requires more partial derivatives of $f$:
$$y_{n+1}=y_n+hf(t_n,y_n)+\frac{h^2}{2}\left(\frac{\partial f}{\partial t}(t_n,y_n)+\frac{\partial f}{\partial y}(t_n,y_n)f(t_n,y_n)\right).$$
Applying to your example, we get $$y_{n+1}=y_n+h\frac{8\cos(4t_n)+y_n}{4}+\frac{h^2}{2}\left(-8\sin(4t_n)+\frac{1}{4}\frac{8\cos(4t_n)+y_n}{4}\right).$$