For \(y'=-y+t\), \(y(0)=1\), with \(h=0.5\), compute \(y_2\) and compare with the exact solution \(y(t)=t-1+2e^{-t}\). What is the absolute error at \(t=1\)?
With \(y_1=1+0.5(-1)=0.5\) and \(y_2=0.5+0.5(-0.5+0.5)=0.5\), the error against \(y(1)=2e^{-1}\approx 0.7358\) is \(|0.5-0.7358|\approx 0.2358\). Using \(t_2\) instead of \(t_1\) gives \(y_2=0.75\) and changes the result.
Euler's method approximates the solution of an initial value problem \(y'=f(t,y)\), \(y(t_0)=y_0\), advancing in steps of size \(h\) using the slope at the current point.