Numerical method for approximating the solution of an IVP. Euler Algorithm (the simplest approximation method)

Similar documents
Numerical method for approximating the solution of an IVP. Euler Algorithm (the simplest approximation method)

Section 7.2 Euler s Method

Unit #16 : Differential Equations

AP Calculus Worksheet: Chapter 2 Review Part I

2.1 Differential Equations and Solutions. Blerina Xhabli

MATH 116, LECTURE 13, 14 & 15: Derivatives

DIFFERENTIAL EQUATIONS

Constant Acceleration

MATH 200 WEEK 5 - WEDNESDAY DIRECTIONAL DERIVATIVE

dt 2 The Order of a differential equation is the order of the highest derivative that occurs in the equation. Example The differential equation

22 Approximations - the method of least squares (1)

Math Week 1 notes

We begin exploring Euler s method by looking at direction fields. Consider the direction field below.

1.1 Radical Expressions: Rationalizing Denominators

Section 2.1 Differential Equation and Solutions

Differential Equations

Section 7.4 Runge-Kutta Methods

0.1 Solution by Inspection

3. On the grid below, sketch and label graphs of the following functions: y = sin x, y = cos x, and y = sin(x π/2). π/2 π 3π/2 2π 5π/2

Chapter 2: First Order DE 2.4 Linear vs. Nonlinear DEs

2tdt 1 y = t2 + C y = which implies C = 1 and the solution is y = 1

Qualitative analysis of differential equations: Part I

Tangent Lines and Derivatives

Exercise 4) Newton's law of cooling is a model for how objects are heated or cooled by the temperature of an ambient medium surrounding them.

AP Calculus. Derivatives.

Section 4.2: The Mean Value Theorem

1.2. Direction Fields: Graphical Representation of the ODE and its Solution Let us consider a first order differential equation of the form dy

Implicit Differentiation, Related Rates. Goals: Introduce implicit differentiation. Study problems involving related rates.

KINEMATICS IN ONE DIMENSION p. 1

Introduction to Initial Value Problems

Everything Old Is New Again: Connecting Calculus To Algebra Andrew Freda

Math 1241, Spring 2014 Section 3.3. Rates of Change Average vs. Instantaneous Rates

CHAPTER 6 VECTOR CALCULUS. We ve spent a lot of time so far just looking at all the different ways you can graph

Analyzing Autonomous DEs: Spotted Owls

AP Calculus AB. Introduction. Slide 1 / 233 Slide 2 / 233. Slide 4 / 233. Slide 3 / 233. Slide 6 / 233. Slide 5 / 233. Limits & Continuity

AP Calculus AB. Slide 1 / 233. Slide 2 / 233. Slide 3 / 233. Limits & Continuity. Table of Contents

for the initial position and velocity. Find formulas for v t and x t. b) Assuming x 0 = 0 and v 0 O 0, show that the maximum value of x t is x max

18.03SC Practice Problems 2

Exam 1 Review SOLUTIONS

2.2 The Derivative Function

25. Chain Rule. Now, f is a function of t only. Expand by multiplication:

1 Antiderivatives graphically and numerically

Ch 6.2: Solution of Initial Value Problems

Calculus I Announcements

dx. Ans: y = tan x + x2 + 5x + C

Autonomous means conditions are constant in time, though they may depend on the current value of y.

Calculus for the Life Sciences II Assignment 6 solutions. f(x, y) = 3π 3 cos 2x + 2 sin 3y

M408 C Fall 2011 Dr. Jeffrey Danciger Exam 2 November 3, Section time (circle one): 11:00am 1:00pm 2:00pm

Chapter 6 Nonlinear Systems and Phenomena. Friday, November 2, 12

AP Calculus AB. Limits & Continuity.

3.5: Euler s Method (cont d) and 3.7: Population Modeling

Lecture 7 - Separable Equations

DRAFT - Math 101 Lecture Note - Dr. Said Algarni

8.1 Supplement: Differential Equations and Slope Fields

Science One Integral Calculus

Chapter 6: Messy Integrals

Slope Fields and Differential Equations. Copyright Cengage Learning. All rights reserved.

AB Calculus: Rates of Change and Tangent Lines


Math Week 1 notes

Section 2.1 (First Order) Linear DEs; Method of Integrating Factors. General first order linear DEs Standard Form; y'(t) + p(t) y = g(t)

On linear and non-linear equations. (Sect. 1.6).

Integration, differentiation, and root finding. Phys 420/580 Lecture 7

Chapter 6 - Ordinary Differential Equations

APPLICATIONS OF DIFFERENTIATION

2.1 How Do We Measure Speed? Student Notes HH6ed. Time (sec) Position (m)

Integration - Past Edexcel Exam Questions

Module 2: Reflecting on One s Problems

Infinite Limits. Infinite Limits. Infinite Limits. Previously, we discussed the limits of rational functions with the indeterminate form 0/0.

4 The Cartesian Coordinate System- Pictures of Equations

INTRODUCTION TO COMPUTER METHODS FOR O.D.E.

Approximations - the method of least squares (1)

Section 1.4 Tangents and Velocity

Slope Fields: Graphing Solutions Without the Solutions

MATH 1130 Exam 1 Review Sheet

Lecture 6, September 1, 2017

MATH 1902: Mathematics for the Physical Sciences I

For those of you who are taking Calculus AB concurrently with AP Physics, I have developed a

Chapter 1 Functions and Limits

sec x dx = ln sec x + tan x csc x dx = ln csc x cot x

Antiderivatives and Indefinite Integrals

Section 3.9. The Geometry of Graphs. Difference Equations to Differential Equations

CHAPTER 7. An Introduction to Numerical Methods for. Linear and Nonlinear ODE s

Solving Differential Equations: First Steps

Numerical methods for solving ODEs

Calculus I Practice Test Problems for Chapter 2 Page 1 of 7

WEEK 7 NOTES AND EXERCISES

LIMITS AND DERIVATIVES

. For each initial condition y(0) = y 0, there exists a. unique solution. In fact, given any point (x, y), there is a unique curve through this point,

Numerical differentiation

MATH CALCULUS I 4.1: Area and Distance

Midterm 1 Review. Distance = (x 1 x 0 ) 2 + (y 1 y 0 ) 2.

Topic 5 Notes Jeremy Orloff. 5 Homogeneous, linear, constant coefficient differential equations

Section 1.4. Meaning of Slope for Equations, Graphs, and Tables

Math 131. The Derivative and the Tangent Line Problem Larson Section 2.1

Parametric Equations, Function Composition and the Chain Rule: A Worksheet

Lesson 3-1: Solving Linear Systems by Graphing

The Detective s Hat Function

"A Sensible Approach to Calculus: Differential Equations, Estimation, and Modelling in The Fundamental Theorem."

Calculus with business applications, Lehigh U, Lecture 03 notes Summer

Transcription:

Section 2.7 Euler s Method (Computer Approximation) Key Terms/ Ideas: Numerical method for approximating the solution of an IVP Linear Approximation; Tangent Line Euler Algorithm (the simplest approximation method)

We have seen in Section 1.1 that by drawing a direction field we can visualize qualitatively the behavior of solutions of a first order DE. When the grid is fine then we obtain a direction field that can convey a sense of the behavior of solutions for various initial conditions. For example, for DE we have direction field dy = y 2-2t dt For a first order DE we can sketch a direction field and visualize the behavior of solutions once we choose an initial value for example y(a) = k. This has the advantage of being a relatively simple process, even for complicated equations. However, direction fields do not lend themselves to quantitative computations or comparisons.

By choosing different initial conditions we can see approximately how some solutions behave. So we are really considering initial value problems. Initial condition x = -2, y = -1 Initial condition x = -1, y = -1 To sketch these solutions of the IVP a numerical method was used.

For quantitative approximations of an IVP we need to consider numerical approximation schemes. Such techniques generate approximate values for the solution of the IVP at a set of discrete values of independent variable t; t 0, t 1, t 2, etc. So the output from such numerical algorithms consists of a set of ordered pairs (t k, y k ) where y k is an approximation to the true value y(t k )of the solution at t k. (y k y(t k )) One algorithm that will allow you to estimate values of the solution y is given by Euler s Method sometimes called the tangent line method. (Euler (pronounced Oiler) lived in the 18th century is considered to be one of the greatest mathematicians who ever lived.) Observe that the direction field has many tangent line segments at successive values of t that almost touch each other. It takes only a bit of imagination to consider starting at a point specified by an initial condition and linking line segments for successive values of t in the grid, thereby producing a piecewise linear graph. Such a graph would provide an approximation to the solution of the IVP.

To see how Euler s method works, recall from calculus a section called Linear Approximation. In that section you did the following: Construct the tangent line to a differentiable function f(x) at a point (a, f(a)) and approximate values of the function at nearby values of x using the equation of the tangent line. Suppose we have the point (a, f(a)) and the slope of f(x) at this point is the value m. Then the tangent line is obtained using the point-slope method for the equation of a line. Tangent line is: y f(a) = m(x a) y = f(a) + m(x a). We can estimate the value of f(x) at x = a + Δx by computing f(a) + m(a + Δx a) = f(a) +m Δx. Euler s method uses this idea applied to an initial value problem as we illustrate next.

We start Euler s approximation to the IVP at the initial point (t 0, y 0 ) and use the fact that the slope of the exact solution at the initial point is the value of f(t 0, y 0 ) so the equation of the tangent line at the initial point is y y 0 = f(t 0, y 0 ) (t t 0 ). Rewrite this as y = y 0 + f(t 0, y 0 ) (t t 0 ). The tangent line is a good approximation to the actual solution curve on a short interval over which the slope of the solution does not change appreciably from its value at the initial point. Exact solution Thus, if t 1 is close enough to t 0, we can approximate the exact solution at t = t 1 by the value y 1 determined by substituting t 1 for t in the equation of the tangent line. Doing this we get y 1 = y 0 + f(t 0, y 0 ) (t 1 t 0 ). So far we have points (t 0, y 0 ) and (t 1, y 1 ). If we connect these points with a straight line we have a linear approximation to the exact solution φ(t) over interval [t 0, t 1 ]. linear approximation

To proceed further, we can try to repeat the process. Unfortunately, we do not know the value of the exact solution value at t 1. The best we can do is to use the approximate value y 1 instead. Thus we construct the line through (t 1, y 1 ) with the slope f(t 1, y 1 ). For a point t 2 close to t 1, we approximate the exact solution at t 2 using the line passing through (t 1, y 1 ) with slope f(t 1,y 1 ). We then compute y 2 = y 1 + f(t 1, y 1 ) (t 2 t 1 ) which approximates the exact solution at t 2. So now we have three points (t 0, y 0 ),(t 1, y 1 ), and (t 2, y 2 ). Using this process at the second step we are really approximating a new IVP; As along as the integral curve for the original IVP is not much different that than the integral curve for the new IVP, we can obtain an estimate of the solution of the original IVP. This is where some error creeps in. Thus we create a discrete sequence y n of approximations to the exact solution at the discrete points t 1, t 2, t 3, : where f k = f(t k,y k ) is the slope of the tangent line at t = t k for k =0, 1,, n.

The sequence of calculations generates the sequence of points To graph an Euler approximation, we plot the points (t 0, y 0 ), (t 1, y 1 ),, (t n, y n ), and then connect these points with line segments to provide a piecewise linear approximation to the solution of the original IVP. If the discrete values t 1, t 2, t 3, are equispaced we say the step size is a fixed value often denoted by h. For a fixed step size h = t k t k-1, for each value of k. Thus Euler s formula for equispacing becomes

Example: For the initial value problem use Euler s method with h = 0.2 to approximate the solution at t = 0.2, 0.4, 0.6, 0.8, and 1.0. Index i t i y i y' i = f(t i,y i ) = f i 0 0 1 1 0.2 2 0.4 3 0.6 4 0.8 5 1.0 Slope computation y i+1 = y i + h f(t i,y i ) Estimate of soln at t i+1 Compute the slope at t 0 = 0 and use the fact that y 0 = y(0)= 1 in the Euler formula.

Example: For the initial value problem use Euler s method with h = 0.2 to approximate the solution at t = 0.2, 0.4, 0.6, 0.8, and 1.0. Index i t i y i y' i = f(t i,y i ) = f i Slope computation y i+1 =y i + h f(t i,y i ) Estimate of soln at t i+1 0 0 1 2.5 y 1 =y 0 + h f(t 0,y 0 ) = 1.5 1 0.2 2 0.4 3 0.6 4 0.8 5 1.0 y1 y0 f0 h 1 ( 3 0 0. 5) ( 0. 2) 1 2. 5( 0. 2) 1. 5 Substituted t = 0 and y = 1 into formula for f(t, y)

Example: For the initial value problem use Euler s method with h = 0.2 to approximate the solution at t = 0.2, 0.4, 0.6, 0.8, and 1.0. Index i t i y i y' I = f(t i,y i ) = f i Slope computation y i+1 =y i + h f(t i,y i ) Estimate of soln at t i+1 0 0 1 2.5 y 1 =y 0 + h f(t 0,y 0 ) = 1.5 1 0.2 1.5 2 0.4 3 0.6 4 0.8 5 1.0 y1 y0 f0 h 1 ( 3005. )( 0. 2) 1 2. 5( 0. 2) 1. 5 Compute the slope at t 1 = 0.2 and use the fact that we have the approximation y 1 = 1.5 to use in the Euler formula.

Example: For the initial value problem use Euler s method with h = 0.2 to approximate the solution at t = 0.2, 0.4, 0.6, 0.8, and 1.0. Index i t i y i y' I = f(t i,y i ) = f i y i+1 =y i + h f(t i,y i ) 0 0 1 2.5 y 1 =y 0 + h f(t 0,y 0 ) = 1.5 1 0.2 1.5 1.8500 y 2 =y 1 + h f(t 1,y 1 ) = 1.87 2 0.4 3 0.6 4 0.8 5 1.0 y1 y0 f0 h 1 ( 3 0 0. 5) ( 0. 2) 1 2. 5( 0. 2) 1. 5... y2 y1 f1 h 15. 3 2 0 2 0 5 15 ( 0. 2) 1. 87 Substituted t = 0.2 and y = 1.5 into formula for f(t, y)

Example: For the initial value problem use Euler s method with h = 0.2 to approximate the solution at t = 0.2, 0.4, 0.6, 0.8, and 1.0. Index i t i y i y' I = f(t i,y i ) = f i y i+1 =y i + h f(t i,y i ) 0 0 1 2.5 y 1 =y 0 + h f(t 0,y 0 ) = 1.5 1 0.2 1.5 1.8500 y 2 =y 1 + h f(t 1,y 1 ) = 1.87 2 0.4 1.87 3 0.6 4 0.8 5 1.0 y1 y0 f0 h 1 ( 3 0 0. 5) ( 0. 2) 1 2. 5( 0. 2) 1. 5... y2 y1 f1 h 15. 3 2 0 2 0 5 15 ( 0. 2) 1. 87 Compute the slope at t 2 = 0.4 and use the fact that we have the approximation y 2 = 1.87 to use in the Euler formula.

Example: For the initial value problem use Euler s method with h = 0.2 to approximate the solution at t = 0.2, 0.4, 0.6, 0.8, and 1.0. Index i t i y i y' I = f(t i,y i ) = f i y i+1 =y i + h f(t i,y i ) 0 0 1 2.5 y 1 =y 0 + h f(t 0,y 0 ) = 1.5 1 0.2 1.5 1.8500 y 2 =y 1 + h f(t 1,y 1 ) = 1.87 2 0.4 1.87 1.2650 y 3 =y 2 + h f(t 2,y 2 ) = 2.123 3 0.6 2.123 4 0.8 5 1.0 y1 y0 f0 h 1 ( 3 0 0. 5) ( 0. 2) 1 2. 5( 0. 2) 1. 5... y2 y1 f1 h 15. 3 2 0 2 0 5 15 ( 0. 2) 1. 87. y3 y2 f2 h 1. 87 3 2 0 4 0. 5 1. 87 ( 0. 2) 2. 123

Example: For the initial value problem use Euler s method with h = 0.2 to approximate the solution at t = 0.2, 0.4, 0.6, 0.8, and 1.0. Index i t i y i y' I = f(t i,y i ) = f i y i+1 =y i + h f(t i,y i ) 0 0 1 2.5 y 1 =y 0 + h f(t 0,y 0 ) = 1.5 1 0.2 1.5 1.8500 y 2 =y 1 + h f(t 1,y 1 ) = 1.87 2 0.4 1.87 1.2650 y 3 =y 2 + h f(t 2,y 2 ) = 2.123 3 0.6 2.123 4 0.8 5 1.0 y y f h 1 ( 3 0 0. 5)( 0. 2) 1 2. 5( 0. 2) 1. 5 1 0 0 2 1 1 3 2 2 y y f h 1. 5 3 2 0. 2 0. 5 1. 5 ( 0. 2) 1. 87 y y f h 1. 87 3 2 0. 4 0. 5 1. 87 ( 0. 2) 2. 123 Continue in a similar fashion.

Example: For the initial value problem use Euler s method with h = 0.2 to approximate the solution at t = 0.2, 0.4, 0.6, 0.8, and 1.0. Index i t i y i y' I = f(t i,y i ) = f i y i+1 =y i + h f(t i,y i ) 0 0 1 2.5 y 1 =y 0 + h f(t 0,y 0 ) = 1.5 1 0.2 1.5 1.8500 y 2 =y 1 + h f(t 1,y 1 ) = 1.87 2 0.4 1.87 1.2650 y 3 =y 2 + h f(t 2,y 2 ) = 2.123 3 0.6 2.123 0.7385 y 4 =y 3 + h f(t 3,y 3 ) = 2.2707 4 0.8 2.2707 5 1.0 y y f h 1 ( 3 0 0. 5)( 0. 2) 1 2. 5( 0. 2) 1. 5 1 0 0 2 1 1 3 2 2 4 3 3. 0.. 2 y y f h 1. 5 3 2 0. 2 0. 5 1. 5 ( 0. 2) 1. 87 y y f h 1. 87 3 2 0. 4 0. 5 1. 87 ( 0. 2) 2. 123 y y f h 2. 123 3 2 0 6 5 2 1 3 ( 0. 2) 2. 2707

Example: For the initial value problem use Euler s method with h = 0.2 to approximate the solution at t = 0.2, 0.4, 0.6, 0.8, and 1.0. Index i t i y i y' I = f(t i,y i ) = f i y i+1 =y i + h f(t i,y i ) 0 0 1 2.5 y 1 =y 0 + h f(t 0,y 0 ) = 1.5 1 0.2 1.5 1.8500 y 2 =y 1 + h f(t 1,y 1 ) = 1.87 2 0.4 1.87 1.2650 y 3 =y 2 + h f(t 2,y 2 ) = 2.123 3 0.6 2.123 0.7385 y 4 =y 3 + h f(t 3,y 3 ) = 2.2707 4 0.8 2.2707 5 1.0 y y f h 1 ( 3 0 0. 5)( 0. 2) 1 2. 5( 0. 2) 1. 5 1 0 0 2 1 1 3 2 2 4 3 3 5 4 4... y y f h 1. 5 3 2 0. 2 0. 5 1. 5 ( 0. 2) 1. 87 y y f h 1. 87 3 2 0. 4 0. 5 1. 87 ( 0. 2) 2. 123 y y f h 2. 123 3 2 0. 6 0. 5 2. 123 ( 0. 2) 2. 2707 y y f h 2. 2707 3 2 0 8 0 5 2 2707 ( 0. 2) 2. 32363

Example: For the initial value problem use Euler s method with h = 0.2 to approximate the solution at t = 0.2, 0.4, 0.6, 0.8, and 1.0. Index i t i y i y' I = f(t i,y i ) = f i y i+1 =y i + h f(t i,y i ) 0 0 1 2.5 y 1 =y 0 + h f(t 0,y 0 ) = 1.5 1 0.2 1.5 1.8500 y 2 =y 1 + h f(t 1,y 1 ) = 1.87 2 0.4 1.87 1.2650 y 3 =y 2 + h f(t 2,y 2 ) = 2.123 3 0.6 2.123 0.7385 y 4 =y 3 + h f(t 3,y 3 ) = 2.2707 4 0.8 2.2707 0.2646 y 5 =y 4 + h f(t 4,y 4 ) = 2.32363 5 1.0 2.32363 y y f h 1 ( 3 0 0. 5)( 0. 2) 1 2. 5( 0. 2) 1. 5 1 0 0 2 1 1 3 2 2 4 3 3 5 4 4 y y f h 1. 5 3 2 0. 2 0. 5 1. 5 ( 0. 2) 1. 87 y y f h 1. 87 3 2 0. 4 0. 5 1. 87 ( 0. 2) 2. 123 y y f h 2. 123 3 2 0. 6 0. 5 2. 123 ( 0. 2) 2. 2707 y y f h 2. 2707 3 2 0. 8 0. 5 2. 2707 ( 0. 2) 2. 32363

The exact solution to our IVP is We approximated the solution of our IVP at t = 0.2, 0.4, 0.6, 0.8, 1.0 so now let s compare our results to the exact solution at those values of t. Exact y in red Approximate y in blue 2.5 y 2.0 1.5 1.0 0.5 0.2 0.4 0.6 0.8 1.0 t

Euler Approx. 3 Direction Field for y'=3-2*t-.5*y 2.5 2 1.5 Exact 1 0.5 0 0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1 Note here we are looking over interval 0 t 1.

Accuracy of Euler s Method: Euler s method should not be used for real world approximations of IVPs. There are much more accurate methods available. But these other methods are used in much the same way as Euler s method. Euler s method is a recursive procedure used to obtain discrete approximations to IVPs. It generates a piecewise linear approximation by pasting together tangent line approximations. Its accuracy depends on how closely the t-values t 1, t 2, t 3, are spaced. For a very small spacing Euler s method requires a lot of steps and hence can be considered expensive. Even with small spacing certain IVPs can not be well approximated with Euler s method. Next we illustrate the behavior of Euler s method two different problems. Definition of recursive relating to, or constituting a procedure that can repeat itself indefinitely

Example: Approximate the IVP via Euler s method. The exact solution is x(t) = t + t ln(t).

Inspect the scales for the graphs. Approximate (solid) + True Soln (dotted) 18 1.4 ABS. ERROR 16 14 12 10 8 6 4 2 0 0 2 4 6 1.2 1 0.8 0.6 0.4 0.2 0 0 2 4 6

Observe the slow but steady growth in the error as t increases. Since each step introduces new error into the computed approximate solution, we might expect this type of behavior in every problem; however, the actual accumulation of error from successive steps is very problem dependent.

Euler Approx of IVP Essentially, the error introduced by each step of the time marching process moves us from one solution of the differential equation onto a different solution. (At each step we encounter a new IVP; a perturbed IVP.) If, nearby solutions separate from one another as t increases, we can expect to see a steady increase in the error. Note that a change of initial conditions had those solution curves move away from the solution curve for the original IVP. On the other hand, if nearby solutions move closer together as t increases, we could expect to observe a steady decline in the error. The next example demonstrates this situation.

Another Example: Approximate the IVP via Euler s method. True solution Here nearby solutions move closer together as t increases, so we observe a steady decline in the error.

Approximate (solid) + True Soln (dotted) 5.5 0.18 ABS. ERROR 5 0.16 4.5 0.14 4 0.12 3.5 0.1 3 0.08 2.5 0.06 2 0.04 1.5 0.02 1 0 2 4 6 0 0 2 4 6

In this case changes in the initial conditions have the nearby solutions move closer together as t increases. So we could expect to observe a steady decline in the error.

In both of these examples accuracy may be improved by choosing smaller values of the stepsize h. But this not guaranteed to happen in all cases. Here consider the IVP h = 0.25 h = 0.125 h = 0.0625 h = 0.01 dy = y 2-2t, y(-1.5) = -2.5 dt