[Math] Euler’s method for second order differential equation

numerical methodsordinary differential equations

Not really homework but sample exam.

The question is to use Euler's Method to approximate Y:

$Y''(t) = Y'(t) – 2Y(t)$
$Y'(0) = Y(0) = 1$

with $t_0 = 0$ and $h=0.2$


So what I did:

First iteration:
$t_1 = 0.2$
$y(t_1) = y(t_0)+h \cdot y'(t_0) = 1 + 0.2 \times 1 = 1.2$
$y'(t_1) = y'(t_0) + h \cdot (y'(t_0) – 2y(t_0)) = 1 + 0.2 \times (1-2\times1) = 0.8$

Second iteration:
$t_2 = 0.4$
$y(t_2) = y(t_1)+h \cdot y'(t_1) = 1.2 + 0.2 \times 0.8 = 1.36$
$y'(t_2) = y'(t_1) + h \cdot (y'(t_1) – 2y(t_1)) = 0.8 + 0.2 \times (0.8-2\times1.2) = -2.4$

Correct?

Best Answer

There is an arithmetical mistake at the very last step. I get $y'(t_2)=0.48$.

Such problems are easy to code in a spreadsheet.

A     B       C
0     1       1
0.2   1.2     0.8
0.4   1.36    0.48
0.6   1.456   0.032

Here A is for $t$, B is for $y(t)$, and C is for $y'(t)$. The top row are initial values A1=0, B1=1, C1=1. The second row is the Euler step: A2=A1+0.2 , B2=B1+0.2*C1, C2=C1+0.2*(C1-2*B1). Then drag down for as many rows as you wish.

If for some odd reason you can't use spreadsheet software during an exam, at least it gives a way to check your hand computations.