+ All Categories
Home > Documents > Introuction To numerical methods - Philadelphia UniversityCh1+Ch2+C… · Introuction To numerical...

Introuction To numerical methods - Philadelphia UniversityCh1+Ch2+C… · Introuction To numerical...

Date post: 08-Apr-2018
Category:
Upload: vonga
View: 225 times
Download: 1 times
Share this document with a friend
15
7/30/2012 1 Philadelphia University Engineering Faculty Mechanical Engineering Department Eng. Laith Batarseh Introuction To numerical methods Introduction to numerical methods Numerical methods are those in which the mathematical problem is reformulated so it can be solved by arithmetic operations. We use numerical methods when: Geometry is very complex There is no way to find exact solution Mathematical model general form: Function Forcing Parameters Variable t Independen f Variable Dependent , ,
Transcript
Page 1: Introuction To numerical methods - Philadelphia UniversityCh1+Ch2+C… · Introuction To numerical methods Introduction to numerical methods ... Computer reduce such problem by rearranging

7/30/2012

1

Philadelphia University

Engineering Faculty Mechanical Engineering Department

Eng. Laith Batarseh

Introuction To numerical methods

Introduction to numerical methods

Numerical methods are those in which the mathematical

problem is reformulated so it can be solved by arithmetic

operations.

We use numerical methods when:

Geometry is very complex

There is no way to find exact solution

Mathematical model general form:

Function

ForcingParameters

Variable

tIndependenf

Variable

Dependent,,

Page 2: Introuction To numerical methods - Philadelphia UniversityCh1+Ch2+C… · Introuction To numerical methods Introduction to numerical methods ... Computer reduce such problem by rearranging

7/30/2012

2

Introduction to numerical methods

Problem Definition

Mathematical Model

Numeric Or Graphic Results

Implementation

Physical problem + Assumptions + Boundary or Initial

Conditions

Transform the physical problem into mathematical equation or

equations and define the solution desired to be obtained

Solve the Mathematical model to find the desired solution and

represent in by numeric or graphic means

Explain and discus the mathematical solution and refer it back

to the physical problem

Introduction to numerical methods

Significant Figures: are the digits of a number we can use

with confidence.

Significant Figures = number of certain digits + one digit

Examples:

Significant Figures

0 1 2 3 4 5

26.5 mm

Uncertain

Digits

Certain

Digits

3 Sign. Figs

Page 3: Introuction To numerical methods - Philadelphia UniversityCh1+Ch2+C… · Introuction To numerical methods Introduction to numerical methods ... Computer reduce such problem by rearranging

7/30/2012

3

Introduction to numerical methods

Special Cases:

2.55 & 25.5 & 255 & 2550 & 25500 have 3 Sig. Figs.

2.55 & 0.255 & 0.0255 & 0.00255 have 3 Sig. Figs.

Significant Figures

Representation : 2.55 x 101 & 2 & 3 & 4

Representation : 2.55 x 10-1 & -2 & -3 & -4

Introduction to numerical methods

Accuracy refers to how closely a computed or measured value

agree with the true value.

Precision refers to how closely individual computed or measured

value agree with each other.

Bias (inaccuracy) is the opposite of accuracy. Systematic

deviation from true value

Uncertainty (imprecision) is the opposite of precision.

Magnitude of scatter.

Example:

Accuracy and Precision

Inaccurate &

imprecise

accurate &

imprecise

Inaccurate &

precise

accurate &

precise

Numerical

methods must be

Page 4: Introuction To numerical methods - Philadelphia UniversityCh1+Ch2+C… · Introuction To numerical methods Introduction to numerical methods ... Computer reduce such problem by rearranging

7/30/2012

4

Introduction to numerical methods

Error represents the deviation from the truth or true value

There are two types of error may appear when numerical

methods are used: Round – off error andTruncation error.

Both errors can be represented mathematically by:

Errors Definitions

%100xTrueValue

ionApproximatTrueValue

ionApproximatTrueValueE

t

t

%100

Pr

Pr

xionApproximatCurrent

ionApproximateviousionApproximatCurrent

ionApproximateviousionApproximatCurrentE

t

a

Et = True error

εt = relative true error

Ea = Approximate error

εa= relative Approximate error

Introduction to numerical methods

Round – off error: Results form chopping off some

significant figures. This type of error is found in computer

processes.

Example:

π = 3.14159265….

Computer limitations in representation of numeral

quantity create such error.

Computer reduce such problem by rearranging number

presentation : 25560000 → 2.556 x107

Round – off error

Round – off error

Page 5: Introuction To numerical methods - Philadelphia UniversityCh1+Ch2+C… · Introuction To numerical methods Introduction to numerical methods ... Computer reduce such problem by rearranging

7/30/2012

5

Introduction to numerical methods

Truncation error: Results form using approximationmethods instead of exact mathematical procedures to findthe solution

Example:

Assume f(x) = x2+x+1 , then f(5) = 52 +5+1 = 31

Assume you used the 1st order Taylor series for

example to find the value of f(5) and the results was:

f(5) =f(4)+f’(4)(5-4) = 30 assume xi = 4 , xi+1 = 5

Error = 31 – 30 = 1 (this is a truncation error )

Truncation error

Truncation Error

Taylor series formula:

: the reminder ofTaylor series

Where:

h = xi+1 – xi (step size)

xi : initial independent value

xi+1:next independent value

ζ: is a value lies somewhere between xi+1 and xi

n: Taylor series approximation order

Taylor series

n

n

i

n

iiiii R

n

hxfhxfhxfhxfxfxf

!

)(...

!3

)('''

!2

)('')(')()(

)(32

1

! 1

)(1)1(

n

hfR

nn

n

Page 6: Introuction To numerical methods - Philadelphia UniversityCh1+Ch2+C… · Introuction To numerical methods Introduction to numerical methods ... Computer reduce such problem by rearranging

7/30/2012

6

Truncation Error

Example#1:

If and xi = 0 xi+1 = 1

Then theTaylor series expansion for

Note: when applying Taylor series to estimate polynomials, the number

of terms that gives the exact solution equals the order of approximation

and the rest term will be equal zero (ie. f(n+1) =0)

Taylor series

52635)(234 xxxxxf

!4

)(

!3

)('''

!2

)('')(')()(

4432

1

hxfhxfhxfhxfxfxf iii

iii

Truncation Error

Example#1(cont):

Taylor series

1 & 0 52635)( 1

234 ii xxxxxxxf

!4

)(

!3

)('''

!2

)('')(')()(

4432

1

hxfhxfhxfhxfxfxf iii

iii

5)0( ixf

120)0( 120)(

18)0( 18120)(

12)0( 121860)(

2)0( 212920)(

)4()4(

)3()3(

)2(2)2(

)1(23)1(

fxf

fxxf

fxxxf

fxxxxf

21

!4

0

!3

0

!2

0)0()0()1(:order 4

16!3

0

!2

0)0()0()1(:.order 3

13!2

0)0()0()1(:order 2

7)0()0()1(:order 1

5)0()1(:order 0

)4()4()3()3()2()2()1(th

)3()3()2()2()1(rd

)2()2()1(nd

)1(st

th

hfhfhfhfff

hfhfhff

hfhfff

hfff

ff

21)1( 1 ixf

Page 7: Introuction To numerical methods - Philadelphia UniversityCh1+Ch2+C… · Introuction To numerical methods Introduction to numerical methods ... Computer reduce such problem by rearranging

7/30/2012

7

Truncation Error

Example#1(cont):

Taylor series

%0%10021

2121:order 4

%81.23%10021

1621:.order 3

%09.38%10021

1321:order 2

%67.66%10021

721:order 1

%19.76%10021

521:order 0

th

rd

nd

st

th

x

x

x

x

x

t

t

t

t

t

21)1( 1 ixf

Note : as the order of Taylor approximation increase, the

accuracy increase too

Truncation Error

Example#2:

and xi = π/4 xi+1 =π/3

Solution:

Taylor series

)cos()( xxf

Order (n) f(n)(x) f (π/3) εt

0 Cos(x) 0.707106781 41.4

1 -sin(x) 0.521986659 4.4

2 -cos(x) 0.497754491 0.449

3 Sin(x) 0.499869147 2.62x10-2

4 Cos(x) 0.500007551 1.51x10-3

5 -sin(x) 0.500000304 6.08x10-5

6 -cos(x) 0.499999988 2.44x10-6

Page 8: Introuction To numerical methods - Philadelphia UniversityCh1+Ch2+C… · Introuction To numerical methods Introduction to numerical methods ... Computer reduce such problem by rearranging

7/30/2012

8

Truncation Error

Taylor series reminder:

Assume 0th orderT.S:

It is inconvenient to deal with the remainder as infinite series . So, let us start

with the 1st term of the remainder :

derivative mean – value theorem states that if a function f(x) and its derivative

are continues over an interval from xi and xi+1, then there exists at least one point

on the function has a slope, designated by f’(ξ), that is parallel to the line joiningf(xi) and f(xi+1).

Taylor series reminder

! 1

)(

!

)(...

!2

)('')(')()(

1)1()(2

1

n

hf

n

hxfhxfhxfxfxf

nnn

i

n

iiii

...!3

)('''

!2

)('')(' ),()(

32

1

hxfhxfhxfRxfxf ii

inii

Rn

hxfR in )('

Truncation Error

Graphical Presentation

Taylor series reminder

Rnh

RSlope o

xi Xi+1

F(x)

x

2

1!2

''

'

'

hf

R

hfR

h

Rf

o

o

Page 9: Introuction To numerical methods - Philadelphia UniversityCh1+Ch2+C… · Introuction To numerical methods Introduction to numerical methods ... Computer reduce such problem by rearranging

7/30/2012

9

Truncation Error

Example:

Let us take the 1st order approximation inTaylor series:

Rearrange the terms :

Note that the 1st part is used to approximate the 1st derivative in

numerical methods

Using Taylor series to estimate truncation error

111 ' Rxxxfxfxf iiiii

iiii

iii

xx

R

xx

xfxfxf

1

1

1

1 '

First-order

Approximation

Truncation

Error

Truncation Error

Example(cont):

The reminder represents the truncation error and equal to

Or:

O(xi+1-xi): error order notification and it means that the error is in the

order of h so, if h is halve, then the error is halve too. In similar way, if

the error was in order O(h2), its mean if the step h is halve the error

will be reduced to 1/4th of its previous value.

Using Taylor series to estimate truncation error

ii

ii

xxf

xx

R

1

1

1

!2

''

ii

ii

xxOxx

R

1

1

1

Page 10: Introuction To numerical methods - Philadelphia UniversityCh1+Ch2+C… · Introuction To numerical methods Introduction to numerical methods ... Computer reduce such problem by rearranging

7/30/2012

10

Numerical Differentiation

First derivative

Formula derivation

Assume we take the 1st orderTaylor series terms

Rearrange to separate the first derivative:

Δfi : 1st forward difference.

Δf/h: 1st finite forward divided difference.

Forward Difference

111 ' Rxxxfxfxf iiiii

hOh

fxxO

xx

xfxfxf i

ii

ii

iii

1

1

1'

Numerical Differentiation

First derivative

Formula derivation

Expand 2nd orderTaylor series terms backward to get:

Truncate above equation after the 1st term and rearrange to separatethe first derivative:

: 1st Backward difference.

: 1st finite backward divided difference.

Backward Difference

...!2

'' ' 2

1 hxf

hxfxfxf iiii

hO

h

fxxO

h

xfxfxf ii

iii

11

1'

hf /1

1f

Page 11: Introuction To numerical methods - Philadelphia UniversityCh1+Ch2+C… · Introuction To numerical methods Introduction to numerical methods ... Computer reduce such problem by rearranging

7/30/2012

11

Numerical Differentiation

First derivative

Formula derivation

Centered Difference

...!2

'' ' 2

1 hxf

hxfxfxf iiii

...

!2

'' ' 2

1 hxf

hxfxfxf iiii

211

3

11

2...

62' hO

h

xfxfxf

h

xfxfxf iiiii

i

Numerical Differentiation

Graphical representation

Xi-1 Xi+1

F(x)

xxi

True solution

Backward

Forward

Centered

Page 12: Introuction To numerical methods - Philadelphia UniversityCh1+Ch2+C… · Introuction To numerical methods Introduction to numerical methods ... Computer reduce such problem by rearranging

7/30/2012

12

Examples

Example #1

Given information

assume you have the following functions :

Find the value of f(2) using Taylor series 3rd order expansion. Let

h=0.5 and find the relative true error (εt)

Taylor series

1

1)( .

1)( .

1

1)( .

3

34

34

2

34

x

xxxfc

xxxfb

x

xxxfa

Examples

Example #1

Solution

Taylor series 3rd order expansion (n=3) is obtained as:

The exact solution is found as:

Taylor series

312

122)2( .

3122)2( .

312

122)2( .

3

34

34

2

34

fc

fb

fa

!3

)(

!2

)()()()(

3)3(2)2()1(

1

hxfhxfhxfxfxf ii

iii

Page 13: Introuction To numerical methods - Philadelphia UniversityCh1+Ch2+C… · Introuction To numerical methods Introduction to numerical methods ... Computer reduce such problem by rearranging

7/30/2012

13

Examples

Example #1

Solution

Taylor series

function f(1)(1.5) f(2)(1.5) f(3)(1.5) f (2)

a 0.2400 9.8080 0.2400 2.5008

b 2.0587 2.9046 2.0587 2.9944

c 2.2359 4.5990 2.2359 3.0027

0027.3!3

5.0*)5.1(

!2

5.0*)5.1(5.0*)5.1()5.1()2( .

9944.2!3

5.0*)5.1(

!2

5.0*)5.1(5.0*)5.1()5.1()2( .

5008.2!3

5.0*)5.1(

!2

5.0*)5.1(5.0*)5.1()5.1()2( .

3'''

3

2''

3'

333

3'''

2

2''

2'

222

3'''

1

2''

1'

111

fffffc

fffffb

fffffa

Examples

Example #2

Given information

assume you have the following functions :

Find the value of f’(2) using forward, backward and centered finite

divided difference

Assume xi-1 = 1.5 xi = 2 xi+1 = 2.5

Finite divided difference

1

1)( .

1)( .

1

1)( .

3

34

34

2

34

x

xxxfc

xxxfb

x

xxxfa

Page 14: Introuction To numerical methods - Philadelphia UniversityCh1+Ch2+C… · Introuction To numerical methods Introduction to numerical methods ... Computer reduce such problem by rearranging

7/30/2012

14

Examples

Example #2

Solution

forward finite divided difference:

Assume: xi = 2 xi+1 = 2.5

Finite divided difference

5.9869

25.2

25.2)2(' .

3.8869 25.2

25.2)2(' .

3.309525.2

25.2)2(' .

fffc

fffb

fffa

ii

iii

xx

xfxfxf

1

1'

Examples

Example #2

Solution

backward finite divided difference:

Assume: xi-1 = 1.5 xi = 2

Finite divided difference

3.4303

25.2

5.12)2(' .

2.7213 25.2

5.12)2(' .

1.7000 25.2

5.12)2(' .

fffc

fffb

fffa

h

xfxfxf ii

i1'

Page 15: Introuction To numerical methods - Philadelphia UniversityCh1+Ch2+C… · Introuction To numerical methods Introduction to numerical methods ... Computer reduce such problem by rearranging

7/30/2012

15

Examples

Example #2

Solution

centered finite divided difference:

Assume: xi-1 = 1.5 xi+1 = 2.5

Finite divided difference

4.708625.22

5.15.2)2(' .

3.304125.22

5.15.2)2(' .

2.5048 25.22

5.15.2)2(' .

fffc

fffb

fffa

h

xfxfxf ii

i2

' 11


Recommended