Presentation is loading. Please wait.

Presentation is loading. Please wait.

Class Notes 18: Numerical Methods (1/2)

Similar presentations


Presentation on theme: "Class Notes 18: Numerical Methods (1/2)"— Presentation transcript:

1 Class Notes 18: Numerical Methods (1/2)
82 – Engineering Mathematics

2 Differential Equation
Numerical Methods Differential Equation Analytical Techniques: Integrating Factor & Exact (1st order) (2nd or higher order, linear, constant coefficients) Power Series (2nd order, linear) Laplace Transform (Linear, constant coefficient, I.C.) Numerical Techniques: Fix (single) step - Euler - Runge-Kutta Multi-step - Adams-Bashforth Idea: approximate the value of y at a specified time tn

3 Numerical Methods: the Euler Method
WHAT is Euler Method WHY Euler method can work HOW to apply Euler method What is the PROBLEM with Euler method How to IMPROVE Euler method

4 The Euler Method (Tangent Line Method) - WHAT
First order initial value problem Euler’s Formula: Repeatedly evaluating Euler’s formula using the result of each step to execute the next step Obtain a sequence of values y0, y1, y2, … yn that approximate the value of the solution at points t0, t1, t2, … tn Euler’s formula can be derived in three ways

5 The Euler Method (Tangent Line Method) - WHY
Approach 1: Tangent Line Assume an unique solution of the form Write the differential equation at the point t=tn Approximate the derivation by the corresponding forward difference quotient

6 The Euler Method (Tangent Line Method) - WHY
Replace Solve for h → step size

7 The Euler Method (Tangent Line Method) - WHY
Approach 2: Integration Let be the solution of the initial value problem

8 The Euler Method (Tangent Line Method) - WHY
Replace shaded rectangle

9 The Euler Method (Tangent Line Method) - WHY
Approach 3: Taylor Series The solution has a Taylor series about tn or replace and take the first two terms (linearization)

10 The Euler Method (Tangent Line Method) - HOW
How to apply Euler method step 1 define f(t,y) step 2 input initial values t0 and y0 step 3 input step size h and the number of steps n step 4 output t0 and y0 step 5 for j from 1 to n do k1 = f(t, y) y = y + h*k1 n times t = t + h output t and y end

11 The Euler Method (Tangent Line Method) - HOW
Example Exact solution

12 The Euler Method (Tangent Line Method) - PROBLEM
Error in numerical approximations Convergence How small a step size is needed in order to guarantee a given level of accuracy? slow down calculations Small step size - may cause loss of accuracy Numerical approximation Analytical solution Step size

13 The Euler Method (Tangent Line Method) - PROBLEM
Fundamental sources of errors 1) Formula/Algorithm - approximation e.g. Euler → straight line approximations 2) The input data (except for the first step) are only approximations to the actual values of the solution at the specific points 3) Finite precision of the computer

14 The Euler Method (Tangent Line Method) - PROBLEM
Error type 1) and 2) Assume that the computer can execute all computations exactly. It can retain infinitely many digits (if necessary) at each step Error type 3) Global Truncation Error (source of error: 1 and 2) Solution Numerical Approximation Actual computed solution With round off error Round off error Numerical Approximation

15 The Euler Method (Tangent Line Method) - PROBLEM
The absolute value of the total error in computing based on Global Truncation Error Round off error

16 The Euler Method (Tangent Line Method) - PROBLEM
Example – Round off Error Computer with four digits Compute for x=0.3334

17 The Euler Method (Tangent Line Method) - PROBLEM
How to reduce round-off error 1) Minimize the number of calculations 2) Use double-precision arithmetic

18 The Euler Method (Tangent Line Method) - PROBLEM
Global versus Local Truncation Error Assume that the solution is to the initial value problem Global Truncation Error Local Truncation Error (In each step)

19 The Euler Method (Tangent Line Method) - PROBLEM
Expand about tn using polynomial with a remainder where is some point using the Euler formula to calculate an approximation to the difference between and is the local truncation error

20 The Euler Method (Tangent Line Method) - PROBLEM
M is the maximum of on the interval [a b]

21 The Euler Method (Tangent Line Method) - PROBLEM
One use of the equation is to choose a step size that will result in a local truncation error no greater than some given tolerance level For example if the local truncation error must be no greater than ε Difficulty: estimate or M

22 The Euler Method (Tangent Line Method) - PROBLEM
Reducing the interval by ½ reduces the error by ¼ The global truncation error Euler method is called a first order method because its global truncation error is proportional to the first power of the step size h K: some constant

23 The Euler Method (Tangent Line Method) - IMPROVE
Improved Euler formula (Heun formula) Idea: replace integrand by the average of the two endpoints Heun formula Euler formula

24 The Euler Method (Tangent Line Method) - IMPROVE
Improved Euler formula (Heun formula) Heun formula Euler formula Local Truncation Error: Local Truncation Error: Global truncation error: First order method Global Truncation Error: Second order method Cost: more computational work

25 The Euler Method (Tangent Line Method) - IMPROVE
If depends only on t and not on y, solving the differential equation reduces to integrating in this case Trapezoid rule of numerical integration

26 The Euler Method (Tangent Line Method) - IMPROVE
How to apply improved Euler method step 1 define f(t,y) step 2 input initial values t0 and y0 step 3 input step size h and the number of steps n step 4 output t0 and y0 step 5 for j from 1 to n do k1 = f(t, y) k2 = f(t + h, y + h*k1) y = y (h/2)*(k1 + k2) t = t + h output t and y end

27 The Euler Method (Tangent Line Method) - IMPROVE
The improved Euler method is an example of a predictor-corrector method predicts the value of yn+1 corrects the estimate (Predictor) (Corrector)


Download ppt "Class Notes 18: Numerical Methods (1/2)"

Similar presentations


Ads by Google