- calculate $y(3)$ using step size $h=1$ given $y(0)=5$ via euler method
- solve the differential equation
- calculate the error between the approximation and actual value of $y(3)$
I got,
- $y(3)= 3.2282$
- $c=10$
- error of $0.5884$
If anybody could verify my answers that would be great, thanks.
(a) Euler's Method with $f(x,y)=3e^{-x}-0.4y$, $h=1$, $x_0=0$, $y_0=5$, $x_n=x_0+n h$, $y_n=y_{n-1}+hf(x_{n-1},y_{n-1})$ after three steps yields $y(3)\approx 3.22819$
(b) Solve this first order linear equation using the integrating factor $e^{\int 0.4\,dx}=e^{0.4x}$ which yields the general solution $$y(x)=-5e^{-x}+Ce^{-0.4x}.$$ Applying the initial condition $y(0)=5$ yields $$y(0)=-5+C=5\implies C=10$$ so $$y(x)=-5e^{-x}+10e^{-0.4x}.$$
(c) $|y_{\text{euler}}(3)-y(3)|=|3.22819-2.76301|=0.465183$.