Consider the differential equation with an initial value of. Use to approximate .
Step 1: Find the slope of the tangent line at the initial point
To find the tangential slope at , we simply plug it into the differential equation to get
Step 2: Find our new x-value
To find our next x-value, we add h to the initial x-value to get
Step 3: Plug in our values to obtain our new y-value approximation
So, we have:
- Step size,
- Initial y-value,
- The slope of the tangent line at the initial value,
Plugging in all of our values, we get
So, the approximation to the solution at is or
Step 4: Repeat the algorithm as many times as needed to obtain y(4)
Given that our step size is 0.2, we will have to repeat the algorithm 4 more times:
- Using :
- Using :
- Using :
- Using :
Finally, we have obtained our approximation at !
When solving multiple iterations of Euler's Method, it may be useful to construct a table for each of your values! In iterative problems such as these, tables can help to our numbers organized.
For this problem, a table might look like:
(xi, yi) | dy/dx | h = 0.2 | xi+1 | yi+1 |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
Step 5: Check the error
As this specific example can be solved directly, we can check the global error of our answer.
The direct solution to the differential equation is . Plugging in x = 4, we get
To check the percent error, we simply compute
Our error is relatively low!
We use absolute values in the percent error calculation because we don't care if our approximation is above or below the actual value, we just want to know how far away it is!
Lucky for us, all Euler's Method problems follow the same simple algorithm.