#Euler's Method
Euler's Method is an algorithm used to construct approximate solutions to a differential equation of the form starting at an initial point .
Since the differential equation tells us the slope of the tangent line at any point on the xy-plane, we can find the slope at and move along the tangent line some distance to a point . Since the solution curve is close to its tangent line (as long as we're not too far from the point of tangency), the point is almost on the solution curve.
Now we repeat the process. Find the tangent line at using the differential equation, follow it for a short distance, and find a new point . This point is also close to the solution curve.
Repeat the process as many times as you like.
The process is the same each time, so we can develop an iterated formula and automate the process.
Let's determine how to get from to .
First, we need to find the tangent line at .
In general, the tangent line to a function at a the point has equation .
In this case, the derivative is given by the differential equation, , and , so we have .
Therefore,
We will move along the tangent line the same horizontal distance each step of the process. In other words, is a constant, called the “step size.” We will call this .
####Euler’s Formula
###Example 1
Use Euler's Method to approximate the solution curve to the differential equation that passes through the point . Plot the approximation for .
We'll start with a small example by hand, and then we'll let the computer do the work.
We will use just 5 steps. That means the step size is .
We'll start with and , and then we will calculate new x-coordinates with and new y-coordinates with .
So and ,
and and ,
and and ,
and and ,
and and .
Now let's plot these six points.
The six points above are approximately on the solution curve. If we connect the points with straight lines, we will have an approximate solution curve.
Of course, just 5 steps is not enough to get a good approximation, so we'll use the computer with many more steps.
Here is a plot of our approximation (blue) along with the actual solution (red).
We can make the approximation better by increasing (this decreases the step size).
If we want to plot the approximation past , then we can change x_end. The approximation in this problem gets worse when we are farther away from our starting point.
The interactive box below allows us to change and x_end. Experiment with different values.
###Example 2
Consider the initial value problem .
Use Euler's Method to approximate .
Modifying the routine from Example 1:
A Discussion About Error
Let’s look at how the error of Euler’s method changes depending on how many iterations we perform on a certain problem. In particular, how the error changes depending on how many iterations we utilize. We consider the same initial value problem as above, with . How much error is there at ? We know the exact solution is , and thus the value at is , We use Euler’s method to approximate the solution numerically using , , , , , and iterations.
What do you notice about the size of the error as we keep doubling the number of iterations? (Double iterations -> Half the error) This is actually expected! Euler's method to approximate the solution of an initial value problem is called a first order method. Meaning that each doubling of iterations, halves the error. A second order method (and they are out there) would mean doubling the iterations quarters the error . A common numerical method is called the Runge-Kutta method. This scheme is fourth order. Doubling the iterations decreases the error by a factor of . However, there is a tradeoff, these iterations are more invloved and take more time computationally.
###Interactive Euler's Method
The Sage code below will perform Euler's Method with interactive input. For your assignment, you may use this interact or copy and paste the code we used in the examples above.
#Euler's Method Assignment
###Question 1
Use Euler's Method to graph an approximate solution curve to with initial value . Graph on the interval from to and use steps.
###Question 2
Consider the initial value problem .
####Part a
Use Euler's Method with steps to graph an approximate solution curve on the interval from to .
####Part b
The exact solution of this differential equation is . Add a graph of this curve to your graph in part a.
###Question 3
Consider the initial value problem .
####Part a
Approximate using Euler's Method with (round to 10 decimal places).
####Part b
Use separation of variables to solve the differential equation for .
####Part c
Plug and into your solution and solve for the constant .
####Part d
Find the exact value of .
####Part e
Subtract your approximation (part a) from the exact value. This is the error.
####Part f
Approximate using Euler's Method with (round to 10 decimal places).
####Part g
Calculate the new error. [This should be smaller than the error in part e.]