# ODE with Euler Method

I have to solve the following ODE: $$y'(t)=y(t)+t$$, $$y(0)=0$$ with Eulers Method in two steps, where $$h=0.1$$. I tried the following: $$y'(0)=y(0)+0=0$$ and then I get $$y(0.1)=y(0)+h*y'(0)=0$$ but then everything will be 0. I do not get how to solve this.

• $y=0$ is the solution for initial condition $y(0)=0$. Choose a more interesting initial condition e.g. $y(0)=1$ and try again. – xidgel Jan 23 at 18:56
• @xidgel : No, there is a non-zero forcing term, the general solution is $y(t)=ce^t-1-t$ and $c=1$ for $y(0)=0$. – LutzL Jan 23 at 19:14
• @LutzL Thanks for catching that. – xidgel Jan 23 at 19:16

In the next step you get $$f(0.1, 0)=0.1$$ so that you get a non-zero value for the approximation at $$0.2$$.
The leading error coefficient in $$y_k=y(t_k)+c(t_k)h+O(h^2)$$ is a solution of $$c'(t)=f_y(t,y)c-\frac12y''=c-\frac12e^t, \\~~\text{ so that }~~ (e^{-t}c)'=-\frac12\implies c(t)=-\frac12te^t$$
Plotting the actual error coefficient $$\frac{y_k-y(t_k)}h$$ against this first term curve for several values of $$h$$ gives the image
So that indeed the Euler points are below the exact solution, for large $$h$$ this can be a large error, and for $$h=0.1$$ the error is as large as the value of the solution.