551614:Advanced Mathematics for Mechatronicsmecha.sut.ac.th/files/551614-Math-1.pdf · Numerical...

Preview:

Citation preview

1

551614:Advanced Mathematics for Mechatronics

Numerical solution for ODEsSchool of Mechanical Engineering

2

Prescribed text :

Numerical Method for Engineering, Seventh Edition, Steven C.Chapra, Raymond P. Canale.,McGraw Hill 2014

3

Recommended reading :

Numerical Methods for Engineers and Scientists, Amos

Gilat and Vish Subramaniam, Wiley,2008

Numerical Methods Using MATLAB, John.H.Methews.,

Kurtis D.Fink.,Prentice Hall , Fourth Edition,2004

ระเบียบวธีิเชิงตวัเลขในงานวศิวกรรม, ปราโมทย์ เดชะ

อาํไพ., สาํนกัพิมพแ์ห่งจุฬาลงกรณ์มหาวิทยาลยั พ.ศ.2556

4

Course Description

Truncation errors and the Taylor seriesNumerical Solutions for ODEsFinite difference methodOptimization

5

Errors in Numerical Solutions

Truncation ErrorsRound-Off ErrorsTotal Error• Local Error• Global Error

6

Truncation Errors :The Taylor series

( ) ( ) ( ) ( ) +

∆++

∆+

∆+=+

iii xn

nn

xxii dx

fdnx

dxfdx

dxdfxxfxf

!!2!1 2

22

1

( ) ( )ii xfxf ≅+1

Zero-order approximation

First-order approximation

( ) ( )ix

ii dxdfxxfxf

!11∆

+=+

7

The Taylor series

( ) 2.125.05.015.01.0 234 +−−−−= xxxxxfapproximation

8

The Remainder for the Taylor Series Expansion

9

Truncation Errors: Example3 5 7 9

sin( )3! 5! 7! 9!x x x xx x= − + − + +

sin 0.52359886 6π π = =

sin 0.56π =

Taylor’s series expansion:

The exact value:

The Zero-order approximation;

The truncation error: 0.5 0.5235988 0.0235988TRE = − = −

10

Truncation Errors: Example3 5 7 9

sin( )3! 5! 7! 9!x x x xx x= − + − + +

6sin 0.49967426 6 3!π π π = − =

sin 0.56π =

Taylor’s series expansion:

The exact value:

The first-order approximation;

The truncation error: 0.5 0.4996742 0.0003258TRE = − =

11

Round-Off Errors

12

Total Error

TrueError TrueSolution NumericalSolution= −

The true error:

The true relative error:

TrueRelativeError TrueSolution NumericalSolutionTrueSolution

−=

13

Total Error

The Global Error is the total discrepancy due to past as well as present stepsThe Local Error refers to the error incurred over a single step. It is calculated with a Taylor series expansion.

14

The Global ErrorThe relative global error:

%TheGlobalError 100TrueSolution NumericalSolutionTrueSolution

−= ×

15

The Total Error: Example

16

The Total Error: Example

3.21875 5.25%TheGlobalError 100 63.13.21875

−= × =

The percent relative global error (Step 1);

The percent relative global error (Step 2);

3 5.875%TheGlobalError 100 95.83

−= × =

17

The Total Error: Example

3 22 12 20 8.5y x x x= − + − +

( ) ( ) ( )2 3 42 3 4

2 3 42! 3! 4!i i i

localx x x

x x xd f d f d fEdx dx dx

∆ ∆ ∆= + +

Exact estimates of the errors in Euler’s method

2

4

4

6 24 2012 24

12

y x xy x

d fdx

= − + −= − +

= −

Problem statement:

18

The Total Error: Example

22

2

33

44

6(0) 24(0) 20 (0.5) 2.52

12(0) 24 (0.5) 0.53 212 (0.5) 0.03125

4 3 2

l

l

l

E

E

E

− + −= = −

− += =

×−

= = −× ×

2 3 4 2.03125localtotal l l lE E E E= + + = −

The percent relative local error (Step 1);

%TheLocalError= 100 63.1localtotalE

TrueSolution× =

19

The Total Error: Example

22

2

33

44

6(0.5) 24(0.5) 20 (0.5) 1.18752

12(0.5) 24 (0.5) 0.3753 2

12 (0.5) 0.031254 3 2

l

l

l

E

E

E

− + −= = −

− += =

×−

= = −× ×

2 3 4 0.84375localtotal l l lE E E E= + + = −

The percent relative local error (Step 2);

0.84375%TheLocalError= 100 28.13

−× =

20

Numerical Solutions for ODEs

Introduction to Ordinary Differential Equations (ODE)

21

Study Objectives

• Solve Ordinary differential equation (ODE) problems.

• Appreciate the importance of numerical method in solving ODE.

• Assess the reliability of the different techniques.

• Select the appropriate method for any particular problem.

22

Computer Objectives

• Develop programs to solve ODE.• Use software packages to find the solution of

ODE

23

Learning Objectives of Lesson 1

Recall basic definitions of ODE,• order, • linearity• initial conditions, • solution,

Classify ODE based on( order, linearity, conditions)

Classify the solution methods

24

Partial Derivatives

u is a function of more than one

independent variable

Ordinary Derivatives

v is a function of one independent variable

Derivatives

Derivatives

dtdv

yu∂∂

25

Partial Differential Equations

involve one or more partial derivatives of unknown functions

Ordinary Differential Equations

involve one or more

Ordinary derivatives of

unknown functions

Differential EquationsDifferentialEquations

162

2

=+ tvdt

vd 02

2

2

2

=∂∂

−∂∂

xu

yu

26

Ordinary Differential Equations

)cos()(2)(5)(

)()(:

2

2

ttxdt

tdxdt

txd

etvdt

tdvExamples

t

=+−

=−

Ordinary Differential Equations (ODE) involve one or more ordinary derivatives of unknown functions with respect to one independent variable

x(t): unknown function

t: independent variable

27

Order of a differential equation

1)(2)()(

)cos()(2)(5)(

)()(:

43

2

2

2

2

=+−

=+−

=−

txdt

tdxdt

txd

ttxdt

tdxdt

txd

etxdt

tdxExamples

t

The order of an ordinary differential equations is the order of the highest order derivative

Second order ODE

First order ODE

Second order ODE

28

A solution to a differential equation is a function that satisfies the equation.

Solution of a differential equation

0)()(:

=+ txdt

tdxExample

0)()(

)(:Proof

)(

=+−=+

−=

=

−−

tt

t

t

eetxdt

tdx

edt

tdx

etxSolution

29

Linear ODE

32

2

:

( )( )

( ) ( )( ) 1

t

Examples

dx tx t e

dt

d x t dx tx t

dt dt

− =

− + =

An ODE is linear ifThe unknown function and its derivatives appear to power one

No product of the unknown function and/or its derivatives

Linear ODE

Non-linear ODE

30

Nonlinear ODE

1)()()(

2)()(5)(

1))(cos()(:ODEnonlinear of Examples

2

2

2

2

=+−

=−

=−

txdt

tdxdt

txd

txdt

tdxdt

txd

txdt

tdx

An ODE is linear ifThe unknown function and its derivatives appear to power one

No product of the unknown function and/or its derivatives

31

Uniqueness of a solution

byay

xydt

xyd

==

=+

)0()0(

0)(4)(2

2

In order to uniquely specify a solution to an n th order differential equation we need n conditions

Second order ODE

Two conditions are needed to uniquely specify the solution

32

Auxiliary conditions

Boundary Conditions

• The conditions are not at one point of the independent variable

Initial Conditions

all conditions are at one point of the independent variable

auxiliary conditions

33

Boundary-Value and Initial value Problems

Boundary-Value Problems

• The auxiliary conditions are not at one point of the independent variable

• More difficult to solve than initial value problem

5.1)2(,1)0(2 2

===++ −

xxexxx t

Initial-Value Problems

The auxiliary conditions are at one point of the independent variable

5.2)0(,1)0(2 2

===++ −

xxexxx t

same different

34

Classification of ODEODE can be classified in different ways

Order• First order ODE• Second order ODE• Nth order ODE

Linearity• Linear ODE• Nonlinear ODE

Auxiliary conditions• Initial value problems• Boundary value problems

35

Analytical Solutions

Analytical Solutions to ODE are available for linear ODE and special classes of nonlinear differential equations.

36

Numerical Solutions

Numerical method are used to obtain a graph or a table of the unknown functionMost of the Numerical methods used to solve ODE are based directly (or indirectly) on truncated Taylor series expansion

37

Classification of the MethodsNumerical Methods

for solving ODE

Multiple-Step Methods

Estimates of the solution at a particular step are based on information on more than one step

One-Step Methods

Estimates of the solution at a particular step are entirely based on information on the previous step

38

More Lessons in this unit

Taylor series methodsMidpoint and Heun’s methodRunge-Kutta methodsMultiple step MethodsSolving systems of ODEBoundary value Problems

39

40

The sequence of events in the application of

ODEs for engineering problem solving

Differential equations

Analytical methods• Exact solution

Numerical methods Approximate solution

41

42

5.82012215.81045.0

23

234

+−+−=

++−+−=

xxxyxxxxy

43

5.82012215.81045.0

23

234

+−+−=

++−+−=

xxxyxxxxy