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}}=2+(3(1)-2(3))(0.5)=0.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

Differential Equations

Differential Equations 1

The next several posts will cover the fundamentals of the topic of differential equations at least as far as is needed for an AP Calculus course. We will begin at the beginning.

What is a differential equation?

A differential equation is an equation with one or more derivatives in it. It may be very simple such as \displaystyle \frac{dy}{dx}=2x, or more complicated such as \displaystyle \frac{{{d}^{2}}y}{d{{x}^{2}}}+3\frac{dy}{dx}-4y=\cos \left( x \right) or even more complicated.

Why do we need differential equations?

It is often not possible to determine directly a regular function that applies to a real situation. However, we may be able to measure how something is changing with respect to time. The change with respect to time is a derivative and gives us a differential equation. Once in college, as you may remember, there are entire courses devoted to using and solving differential equations. Power series (a BC topic) are often used to approximate or find the solution to a differential equation.

What is the solution to a differential equation?

The solution of a differential equation is not a number. For the first equations we will consider the short answer is that a solution is a function that when substituted into the differential equation along with its derivatives produces a true statement (an identity).

As you may suspect differential equations, at least the easy ones, are solved by integrating. Thus the solution of \frac{dy}{dx}=2x  first appears to be y={{x}^{2}}. But we quickly realize that y={{x}^{2}}+17 and  also y={{x}^{2}}+2\pi  check when substituted into the given equation. In fact any equation with the form y={{x}^{2}}+C, where C is any constant will check. Because of this we first define the general solution of a differential equation as a function with one or more constants that satisfies the given differential equation.

In order to evaluate the constant(s) we are often given an initial condition. An initial condition is the value of the solution function for a particular value of the independent variable, in other words, a point on the solution’s graph. Once the constant is evaluated, we have what’s called a particular solution.

So if the solution of \frac{dy}{dx}=2x contains the point (4, 7), then the particular solution is y={{x}^{2}}-9. A differential equation with an initial condition is called an initial value problem or an IVP.

How do you solve a differential equation?

There is no one method that will let you solve any differential equation. They are not all as simple as the example above. That’s why entire courses are devoted to solving differential equations. AP Calculus students are expected to know only one of the many methods. (This is because there is only time for the briefest introduction of the topic.) The method is called separation of variables. Not all differential equations can be solved by this method; the second example at the top for example requires a much different approach (that is not tested on the AP calculus exams).

To use the method of separation of variables follow these steps:

(1) by multiplying and dividing rewrite, the equation with the x and dx factors on one side and the y and dy factors on the other side.

(2) Then integrate both sides and

(3) Include a constant of integration.

(4) Use the initial condition to evaluate the constant and

(5) Give the particular solution solved for y.

Example 1: For the very simple example we have been using the work looks like this:

Step 1 Separate the variables: dy=2xdx

Steps 2 and 3 Integrate and include the constant of integration. Note that there is a different constant on both sides, but they are immediately combined into one constant that is usually put with the x-terms: y={{x}^{2}}+C

Step 4 Use the initial condition to find C7={{4}^{2}}+C;\quad C=-9

Stem 5 Write the solution by solving for yy={{x}^{2}}-9

Example 2: An average difficulty question. Find the particular solution of the differential equation \displaystyle \frac{dy}{dx}=-\frac{x}{y} such that the point (4, –3) lies on the solution.

Step 1: ydy=-xdx

Step 2 and 3: \displaystyle \frac{1}{2}{{y}^{2}}=-\frac{1}{2}{{x}^{2}}+C  or {{y}^{2}}=-{{x}^{2}}+C.  Multiplying by 2 to simplify things, The constant in the second form is not the same as in the first. However, it is just another constant so it is okay to call it C again.

Step 4: {{(-3)}^{3}}=-{{\left( 4 \right)}^{2}}+C so C=25

Step 5: {{y}^{2}}=-{{x}^{2}}+25 and y=-\sqrt{25-{{x}^{2}}}

Since the solution must be a function it is necessary to solve for y by taking the square root of both sides. The negative sign is chosen because the initial condition requires a negative value for y. The solution is a semi-circle, the bottom half of the full circle.

Example 3: A bit more difficult, but the steps are the same. Find the particular solution of the differential equation \displaystyle \frac{dy}{dx}=\frac{y-1}{{{x}^{2}}} with the initial condition f\left( 2 \right)=0. (From the 2008 AB calculus exam question 5c.)

Step 1:\displaystyle \frac{dy}{y-1}=\frac{dx}{{{x}^{2}}}

Steps 2 and 3: \displaystyle \ln \left| y-1 \right|=-\frac{1}{x}+C

Step 4: When x = 2, y =0  so \displaystyle \ln \left| 0-1 \right|=-\frac{1}{2}+C;\quad C=\frac{1}{2}

Step 5: Solve for y: \displaystyle \ln \left| y-1 \right|=-\frac{1}{x}+\frac{1}{2}

Raise e to the power on each side to remove the natural logarithm. (Students like to call this “E-ing.”)

\displaystyle {{e}^{\ln }}^{\left| y-1 \right|}={{e}^{-\frac{1}{x}+\frac{1}{2}}}

\displaystyle \left| y-1 \right|={{e}^{-\frac{1}{x}+\frac{1}{2}}}

Near the initial point (2, 0) \left( y-1 \right)<0, so \left| y-1 \right|=-\left( y-1 \right)=1-y, so

\displaystyle 1-y={{e}^{-\frac{1}{x}+\frac{1}{2}}}

\displaystyle y=1-{{e}^{-\frac{1}{x}+\frac{1}{2}}}

The graph of the solution is the part of the graph shown below for which x>0. See note 2 below:

DEq graph

Two final notes:

  1. The business with the absolute values is important. Students seem to prefer just ignoring the absolute values, but of course you cannot do that. A similar thing occurred in example 2: since you need the square root of one side you must decide, based on the initial condition, whether to use a plus or a minus sign with the radical. Some practice with both these situations is needed.
  2. Since \left( y-1 \right)<0,\quad y<1. In order to make this so, x>0. This is the domain of the solution. Technically, the domain of the particular solution of a differential equation must be an open interval that contains the initial condition, and on which the differential equation is true. Practically, this means that the graph must go through the initial condition point but may not cross an asymptote or contain a point where the function is not defined. The solution in the example is undefined at x = 0. It approaches the y-axis as a vertical asymptote from the left and approaches the point (0,1) from the right. AP students were not required to sort all this out, but a simple graph of the solution will show what’s happening. For more on the domain (which is not really tested) click here.
  3. For you techies: The graph was made on an iPad using an app called Good Grapher Pro. This is an excellent grapher for 2D and 2D graphs that zoom easily by pinching the screen (of course).

 

Differential Equations

AP Type Questions 6

Differential equations are tested every year. The actual solving of the differential equation is usually the main part of the problem, but it is accompanied by a question about its slope field or a tangent line approximation or something else related. BC students may also be asked to approximate using Euler’s Method. Large parts of the BC questions are often suitable for AB students and contribute to the AB subscore of the BC exam.

What students should be able to do

  • Find the general solution of a differential equation using the method of separation of variables (this is the only method tested).
  • Find a particular solution using the initial condition to evaluate the constant of integration – initial value problem (IVP).
  • Understand that proposed solution of a differential equation is a function (not a number) and if it and its derivative are substituted into the given differential equation the resulting equation is true. This may be part of doing the problem even if solving the differential equation is not required (see 2002 BC 5 – parts a, b and d are suitable for AB)
  • Growth-decay problems.
  • Draw a slope field by hand.
  • Sketch a particular solution on a (given) slope field.
  • Interpret a slope field.
  • Use the given derivative to analyze a function such as finding extreme values
  • For BC only: Use Euler’s Method to approximate a solution.
  • For BC only: use the method of partial fractions to find the antiderivative after separating the variables.
  • For BC only: understand the logistic growth model, its asymptotes, meaning, etc. The exams have never asked students to actually solve a logistic equation IVP.

Shorter questions on this concept appear in the multiple-choice sections. As always, look over as many questions of this kind from past exams as you can find.

For some previous posts on this subject see November 26, 2012,  January 21, 2013 February 1, 6, 2013

Accumulation and Differential Equations

Accumulation 6: Differential equations

When students first learn about antiderivatives, they are given simple initial value problems to solve such as \frac{dy}{dx}=3-2x,\quad y\left( 1 \right)=-5. They are instructed to find the antiderivative, then tack on a +C , then substitute in the initial condition, then solve for C and finally write the particular solution. So we hope to see:

 \frac{dy}{dx}=3-2x

y=3x-{{x}^{2}}+C

-5=3(1)-{{1}^{2}}+C

-7=C

y=3x-{{x}^{2}}-7

But thinking of it as an accumulation problem you can write

\displaystyle y=-5+\int_{1}^{x}{3-2t\,dt}

y=-5+\left. \left( 3t-{{t}^{2}} \right) \right|_{1}^{x}

 y=-5+\left( 3x-{{x}^{2}} \right)-\left( 3(1)-{{1}^{2}} \right)

y=3x-{{x}^{2}}-7

Now I’ll admit there is not too much difference in the amount of work involved there, but once the first line is on the paper there is not much to remember in what to do from there on. Common student mistakes in the first method include entirely forgetting the +C and not using the initial condition correctly.

A differential equation in which dy/dx can be written as a function of x only, \frac{dy}{dx}={f}'\left( x \right), with an initial condition \left( a,f\left( a \right) \right) has the solution

\displaystyle f\left( x \right)=f\left( a \right)+\int_{a}^{x}{{f}'\left( t \right)dt}

Look familiar? Yes, that’s my favorite accumulation equation.

Furthermore, if all you need is some function values, this expression can be entered into a graphing calculator and the values calculated without finding an antiderivative.

In my first post on accumulation, I discussed the AP exam question 2000 AB 4. The solution to part (a) looks like this

\displaystyle \int_{0}^{3}{\sqrt{t+1}dt}=\left. \tfrac{2}{3}{{\left( t+1 \right)}^{3/2}} \right|_{0}^{3}=\tfrac{2}{3}\left( {{4}^{3/2}}-{{0}^{3/2}} \right)=\tfrac{14}{3}\text{ gallons}

The scoring standard included a second method that went this way:

L(t)=\text{ gallons leaked in first }t\text{ minutes}

\frac{dL}{dt}=\sqrt{t+1};\quad L\left( t \right)=\tfrac{2}{3}{{\left( t+1 \right)}^{3/2}}+C

L(0)=0;\quad C=-\tfrac{2}{3}

L(t)=\tfrac{2}{3}{{\left( t+1 \right)}^{3/2}}-\tfrac{2}{3};\quad L(3)=\tfrac{14}{3}

You decide which is easier. If you’re still not sure compare the two methods shown for part (c) on the scoring standard.