Euler’s Method for Making Money

Chip Rollinson is a teacher at Buckingham Browne & Nichols School in Cambridge, Massachusetts. Today’s post is a note he sent to the AP Calculus Community bulletin board that I found interesting. I will share it with you with his permission. I made some minor edits. Chip wrote on February 5, 2015:

I had an epiphany today about the relationship between Euler’s Method and compounding growth. I had never made the connection before. I thought it was cool so I decided I needed to share it.

Consider the differential equation \frac{dA}{dt}=rA with the condition A(0) = P. Solving this equation gives A\left( t \right)=P{{e}^{rt}}, but let’s ignore this for now.

Let’s look at this differential equation using Euler’s Method.

Leonhard Euler1707 - 1783

Leonhard Euler
1707 – 1783

Let’s start with a step size of \tfrac{1}{12} and use (0, P) as the “starting point.”

After one step, you arrive at the point \displaystyle \left( \tfrac{1}{12},P+\tfrac{r}{12}P \right)=\left( \tfrac{1}{12},P\left( 1+\tfrac{r}{12} \right) \right)

After 2 steps, you arrive at the point \displaystyle \left( \tfrac{2}{12},P+\tfrac{2}{12}P+\tfrac{{{r}^{2}}}{144}P \right)=\left( \tfrac{2}{12},P{{\left( 1+\tfrac{r}{12} \right)}^{2}} \right)

After 3 steps, you arrive at the point \displaystyle \left( \tfrac{3}{12},P+\tfrac{3}{12}rP+\tfrac{3}{144}{{r}^{2}}P+P\tfrac{3}{1728}{{r}^{3}} \right)=\left( \tfrac{3}{12},P{{\left( 1+\tfrac{r}{12} \right)}^{3}} \right)

After 4 steps, you arrive at the point \displaystyle \left( \tfrac{4}{12},P{{\left( 1+\tfrac{r}{12} \right)}^{4}} \right)

And so on …

After 12 steps, you arrive at the point \displaystyle \left( 1,P{{\left( 1+\tfrac{r}{12} \right)}^{12}} \right)

After 120 steps, you arrive at the point \displaystyle \left( 10,P{{\left( 1+\tfrac{r}{12} \right)}^{120}} \right)

After 12t steps, you arrive at the point \displaystyle \left( t,P{{\left( 1+\tfrac{r}{12} \right)}^{12t}} \right)

Do these y-values look familiar? It’s the amount you’d have if you were compounding monthly with a yearly interest rate of r for a year, 10 years, and t years.

If the step size were \displaystyle \tfrac{1}{365} instead, you would arrive at the points

\displaystyle \left( 1,P{{\left( 1+\tfrac{r}{365} \right)}^{365}} \right), and \left( 10,P{{\left( 1+\tfrac{r}{365} \right)}^{3650}} \right), and \displaystyle \left( t,P{{\left( 1+\tfrac{r}{365} \right)}^{365t}} \right).

These y-values are the amount you’d have if you were compounding daily for a year, 10 years, and t years.

If the step size were \tfrac{1}{n}, the point after t years is \displaystyle \left( t,P{{\left( 1+\tfrac{r}{n} \right)}^{nt}} \right)

If n went to infinity, you would arrive at the point \displaystyle \left( t,P{{e}^{rt}} \right), the y-value for continuously compounding. This is the solution of  the differential equation mentioned above.

I’d never made this connection before, but it makes perfect sense now.

The actual problem that got me thinking about all of this was:

Suppose that you now have $6000, you expect to save an additional $3000 during each year, and all of this is deposited in a bank paying 4% interest compounded continuously.

This generates the differential equation: \displaystyle \frac{dA}{dt}=0.04t+3000

This was a fun one to do out. I started with a step size of 1/12 and then made them smaller. I derived the solution from Euler’s Method!


So writes Chip Rollinson. He included the following links to his computations: here and here

Then there were some interesting comments from others.

1. Mark Howell pointed out that if \displaystyle \frac{dy}{dx}=f\left( x \right), that is if the derivative is a function of x only, then Euler’s method is the same as a left Riemann sum approximation.

This would make a good exercise for your students to show given a derivative, a starting point, and a small number of steps. Try \frac{dy}{dx}={{x}^{3}}, and use Euler’s Method with 4 steps starting at (0, 0) and then a left-Riemann sum with 4 terms to approximate \int_{0}^{1}{{{x}^{3}}dx},  (Answer: \tfrac{9}{64})

2. Dan Teague went further and pointed out that this is really the development of the Fundamental Theorem of Calculus for a particular function. He contributed this development of the concept.

So Thank You Chip for this and the several other comments you’ve contributed to other post on this blog. And thank you Mark and Dan for your contributions.


Euler’s Method

Differential Equations 3 – Euler’s Method

Since not all differential equation initial values problems (IVP) can be solved, it is often necessary to approximate the solution. There are several ways of doing this. The one that AP students are required to know is Euler’s Method.

The idea behind Euler’s Method is to first write the equation of the line tangent to the solution at the initial condition point. To find the approximate value of the solution near the initial condition, then take short steps from the initial point to the point with the x-value you need.

Since you have the initial point and the differential equation will give you the slope, it is easy to write the equation of the tangent line. You then approximate the point on the solution by using the point on this line a short distance (called the step-size or \Delta x) from the initial point. The first step is exactly the local linear approximation idea.

Next, you write the equation of another line through the approximated point using the differential equation to give you the slope at the approximated point (i.e. not the point on the curve which you do not know). This gives you a second (approximate) point.

Then you repeat the process (called iteration) until you get to the x-value you need.

The equations look like this:

x_{n}={{x}_{n-1}}+\Delta x

{{y}_{n}}={{y}_{n-1}}+{f}'({{x}_{n-1}},{{y}_{n-1}})\Delta x

The first equation says that the x-values increase by the same amount each time. \Delta x may be negative if the required value is at an x-value to the left of the initial point.

The second equation gives the y-value of a point on the line through the previous point where the slope, {f}'({{x}_{n-1}},{{y}_{n-1}}), is found by substituting the coordinates of the previous point into the differential equation. It has the form of the equation of a line.

Example: Let f be the solution of the differential equation \displaystyle \frac{dy}{dx}=3x-2y with the initial point (1, 3). Approximate the value of f(2) using Euler’s method with two steps of equal size.

Solution: At the initial point \displaystyle \frac{dy}{dx}=3(1)-2(3)=-3. Then

{{x}_{1}}=1.5 and {{y}_{1}}=3+(3(1)-2(3))(0.5)=1.5

Now using the point (1.5, 0.5) where \displaystyle \frac{dy}{dx}=3(1.5)-2(0.5)=3.5

{{x}_{2}}=2 and {{y}_{2}}=0.5+(3.5)(0.5)=2.25

Therefore, \left( 2 \right)\approx 2.25. The exact value is 2.5545. A better approximation could be found using smaller steps.

Some textbooks and some teachers make tables to organize this procedure. This is fine, but not necessary on the AP exams. Showing the computations as above will earn the credit. It is easy to remember: you are just writing the equation of a line.

There are calculator programs available on-line that will compute successive iterations of Euler’s method and others that will compute and graph the values so you can examine the approximate solution graph. Of course in real situations computers using this or more advanced techniques can produce approximate numerical solutions to initial value problems.

Here is a graphical look at what Euler’s Method does. Consider this easy IVP: \displaystyle \frac{dy}{dx}={{e}^{x}} with the initial condition y\left( 0 \right)=1. The screen is two units wide extending from x = 0 to x = 2.  The calculator graph below shows three graphs. The top graph is the particular solution y={{e}^{x}}. (I said it was easy.) The lower graph shows an approximate solution with the rather large step size of \Delta x=1 with the two points connected; look closely and you will see the two segments. The middle graph has a step size of \Delta x=0.25. There are 8 segments, but they appear to be a smooth curve approximating the solution. Notice it is closer to the actual solution graph. An even smaller step size would show an even smoother graph closer to the particular solution.Euler