# Euler's Numerical method help

Consider this differential equation,

$dy/dx = x + \sin(y)$

with initial condition $y = 0.5$ when $x = 1.2$:

1. Write down the recurrence relation for Euler's numerical method applied above.
2. With step size h = 0.1, calculate the approximations to y(1.3) and y(1.4).

$$Y_i+1 = Y_i + 0.1(X_i + \sin(Y_i))$$

2. I have problem solving this one...

From my txtbk reference, I sub $i = 1$ into the eqn thus giving me

$Y_1 = Y_0 + 0.1(1.2 + \sin(0.5)) = 0.1679$

Then, $i = 2$

$Y_2 = Y_1 + 0.1(1.3 + \sin(0.6)$

Im sure my method in part 2 is wrong and I don't really understand how to solve it via my txtbk.

-
The method y(i+1)=y(i)+hf(x(i),y(i)),where dy/dx=f(x,y), you applied, seems to be correct at first sight, provided the calculations are correct of course! However using Taylor series expansion, one can show that the error term e(i)= 1+h(del f /del y) at (x(i),y(i)) (here del stands for partial derivative), whose absolute value must be <1 for successive errors to damp out. So please check whether that condition is satisfied, else take into consideration the error terms in each iteration. – Somabha Mukherjee May 19 '12 at 5:21
Do you really intend the "project-euler" tag? Project Euler $\ne$ Euler's method! – Gerry Myerson May 19 '12 at 6:44

We have the differential equation $y'(x) = x + \sin(y)$ with initial condition $y(1.2) = 0.5$.

Euler's method states that we may approximate the value of the function at $y(x+\delta x)$ for some 'small step' $\delta x$ by assuming the function is approximately linear between $x$ and $x+\delta x$. I.e:

$$y(x+\delta x) \approx y(x) + y'(x)\cdot \delta x$$

Thus, for a step size of $\delta x = 0.1$, starting at $x=1.2$ we would have:

$$y(1.2+0.1) \approx y(1.2) + y'(1.2)\cdot 0.1$$ $$y(1.3) = 0.5 + (1.2+\sin(0.5))\cdot 0.1$$ $$= 0.5 + 0.167942554$$

So you dropped the $0.5$ term in your calculation, i.e - what you call $Y_0$. Hopefully this makes things clearer for you. Can you figure out $y(1.4)$ now?

-
y(1.3+0.1)≈y(1.3)+y′(1.3)⋅0.1 y(1.4)=0.6679+0.1(1.3+sin(0.6679)) =0.859880 – JamesK May 19 '12 at 6:19
Thanks @DanielPietrobon – JamesK May 19 '12 at 6:20
@JamesK: You can even upvote and accept this answer if it helped you! – Gigili May 19 '12 at 6:22
@Gigili, I think upvoting takes some number of points, but accepting is certainly an option. – Gerry Myerson May 19 '12 at 6:46