Originally Posted by
HallsofIvy I frankly don't understand what you are doing. One of us is very confused! The problem asks you to numerically solve several differential equations using "Euler's method" with different step lengths. But you start by analytically solving the equation, not using "Euler's method".
"Euler's method" is the very simplest method for numerically solving differential equations. It replaces the derivative, $\displaystyle \frac{dy}{dt}$ by the fraction $\displaystyle \frac{\Delta y}{\Delta t}$ where $\displaystyle \Delta y$ and $\displaystyle \Delta t$ are small changes in y and t respectively.
In the first problem you are given that $\displaystyle y'= 3+ t- y$ with initial value y(0)= 1. Using Euler's method, we approximate that by $\displaystyle \frac{\Delta y}{\Delta t}= 3+ t- y$ or $\displaystyle \Delta y= (3+ t- y)\Delta t$. In (a) we are asked to use a step length of h (my $\displaystyle \Delta x$) equal to 0.1 to find y(0.1), y(0.2), y(0.3), and y(0.4).
When t= 0, y= 1 so we have $\displaystyle \Delta y= (3+ 0- 1)(0.1)= 2(0.1)= 0.2$. When $\displaystyle t= 0+ 0.1= 0.1$, $\displaystyle y= 1+ 0.2= 1.2$.
Now when t= 0.1 we have $\displaystyle \Delta y= (3+ 0.1- 1.2)(0.1)= 0.19$. When $\displaystyle t= 0.1+ 0.1= 0.2$, $\displaystyle y= 1.2+ 0.19= 1.39$.
Now when t= 0.2 we have $\displaystyle \Delta y= (3+ 0.2- 1.39)(0.1)= 0.181$. When $\displaystyle t= 0.2+ 0.1= 0.3$, $\displaystyle y= 1.39+ 0.181= 1.571$.
Now when t= 0.3 we have $\displaystyle \Delta y= (3+ 0.3- 1.571)(0.1)= 0.1729$. When $\displaystyle t= 0.3+ 0.1= 0.4$, $\displaystyle y= 1.571+ 0.1729= 1.7439$.
That is what you should have for (a).
In (b) we are asked to take h to be 0.05 and compare to part (a).
Initially t= 0 and y= 1. $\displaystyle \Delta y= (3+ 0- 1)(0.05)= 2(0.05)= 0.10$ so the next step has t= 0+ 0.05= 0.05 and y= 1+ 0.10= 1.1.
Now $\displaystyle \Delta y= (3+ 0.05- 1.10)(0.05)= 1.95(0.05)= 0.0975$ so the next step has t= 0.05+ 0.05= 0.10 and y= 1.1+ 0.0975= 1.1975. Compare that to y= 1.2 above.
Now $\displaystyle \Delta y= (3+ 0.10- 1.1975)(0.05)= 1.9025(0.05)= 0.095125$ so the next step has t= 0.10+ 0.05= 0.15 and y= 1.1975+ 0.095125= 1.292625.
Now $\displaystyle \Delta y= (3+ 0.15- 1.292625)(0.05)= 1.857375(0.05)= 0.09286875$ so the next step has t= 0.15+ 0.05= 0.20 and y= 1.292625+ 0.09286875= 1.38549375. Compare that to 1.571 above.
Continue!