Docsity

Differentiation-Continuous Functions - Numerical Methods - Lecture Slides, Slides of Mathematical Methods for Numerical Analysis and Optimization

Partial preview of the text

Download Differentiation-Continuous Functions - Numerical Methods - Lecture Slides and more Slides Mathematical Methods for Numerical Analysis and Optimization in PDF only on Docsity!

Differentiation-Continuous Functions

Forward Difference Approximation

x

f x x f x

x

f x

lim + −

For a finite '^ Δ x '

x

f x x f x

f x

Example 1

The velocity of a rocket is given by

14 10 2100

14 10 2000 ln 4

4

− ≤ ≤  

  

× −

× = t t t

ν t

where ' ν ' is given in m/s and ' t ' is given in seconds.

a) Use forward difference approximation of the first derivative of to

calculate the acceleration at. Use a step size of.

b) Find the exact value of the acceleration of the rocket.

c) Calculate the absolute relative true error for part (b).

ν ( ) t

t = 16 s Δ t = 2 s

Example 1 Cont.

Solution

( )

( ) ( )

t
t t
a t

i i i

ν (^) + 1 ν

ti = 16

Δ t = 2

1

t i + = ti +∆ t

( )

( ) ( )

2

18 16 16

ν − ν a ≈

Example 1 Cont.

2

  1. 02 − 392. 07 ≈

2 ≈ 30. 474 m/s

The exact value of a^ (^16 ) can be calculated by differentiating

( ) t t

t 9. 8 14 10 2100

14 10 2000 ln 4

4

^ − 

  

× −

× ν =

as

( ) [ ν ( ) t ]

dt
d
a t =

b)

Example 1 Cont.

Knowing that

[ ( )]

t

t dt

d 1 ln = and^2

1 1

dt t t

d =−  

  

( ) 9. 8 14 10 2100

14 10

14 10

14 10 2100 (^2000 )

4

4

4

− 

 

 

 

× −

× 

 

 

 

×

× −

dt t

t d a t

( ) ( )

( 2100 ) 9. 8 14 10 2100

14 10 1 14 10

14 10 2100 2000 4 2

4

4

4 − − 

× −

× − 

 

×

× −

t

t

t

t

200 3

4040 29. 4

− +

− −

Backward Difference Approximation of the First

Derivative

We know

x
f x x f x
x
f x
lim + −
For a finite ' Δ x ' ,
x
f x x f x
f x
If ' Δ x ' is chosen as a negative number,

( )

( ) ( )

x
f x x f x
f x

( ) ( )

x

f x f x x

Δ

− −Δ

Backward Difference Approximation of the

First Derivative Cont.

This is a backward difference approximation as you are taking a point

backward from x. To find the value of (^) f ′( ) (^) x at i x = x , we may choose another

point ' Δ x '

behind as x = xi − 1

. This gives

( )

( ) ( )

x
f x f x
f x

i i i

− 1

1

1

−

−

−

−

i i

i i

x x

f x f x

where

1 Δ − = − i i x x x

Example 2

The velocity of a rocket is given by

14 10 2100

14 10 2000 ln 4

4

− ≤ ≤  

  

× −

× = t t t

ν t

where ' ν ' is given in m/s and ' t ' is given in seconds.

a) Use backward difference approximation of the first derivative of

to calculate the acceleration at. Use a step size of.

b) Find the absolute relative true error for part (a).

ν ( ) t

t = 16 s Δ t = 2 s

Example 2 Cont.

Solution

t

t t a t

i i

∆

− ≈

ti = 16

Δ t = 2

1

t i − = ti −∆ t

2

16 14 16

a ≈

Example 2 Cont.

The absolute relative true error is

100

  1. 674

  2. 674 28. 915 t x

− ∈ =

= 2. 5584 %

The exact value of the acceleration at from Example 1 is

2 a 16 = 29. 674 m/s

t = 16 s

Derive the forward difference approximation

from Taylor series

Taylor’s theorem says that if you know the value of a function '^ f^ 'at a point

i x and all its derivatives at that point, provided the derivatives are

continuous between i x and^ xi^ + 1 , then

( ) ( ) ( )( )

( ) ( − ) +

2 1 1 1

i i

i i i i i i

x x
f x
f x f x f x x x

Substituting for convenience Δ x = xi + 1 − xi

′′

  • = + ′ +

2 1 Δ 2!

Δ x

f x f x f x f x x

i i i i

′′ − ∆

− ′ (^) =

x

f x

x

f x f x f x

i i i i 2!

1

( x )

x

f x f x f x

i i i + ∆ ∆

− ′ (^) =

0

1

Derive the forward difference approximation

from Taylor series Cont.

From Taylor series

( ) ( ) ( )

( ) ( )

( ) ( ) +

′′′

′′

  • = + ′ +

2 3 1 Δ 3!

Δ 2!

Δ x

f x x

f x f x f x f x x

i i i i i

( ) ( ) ( )

( ) ( )

( ) ( ) +

′′′ −

′′ − = − ′ +

2 3 1 Δ 3!

Δ 2!

Δ x

f x x

f x f x f x f x x

i i i i i

Subtracting equation (2) from equation (1)

( ) ( ) ( )( )

( ) ( ) +

′′′

  • −^ − = ′ +

3 1 1 Δ 3!

2 2 Δ x

f x f x f x f x x i i i i

( )

( ) ( ) ( ) ( ∆ ) +

′′′ − ∆

− ′ (^) =

  • 1 − 1 2

2 3!

x

f x

x

f x f x f x

i i i i

( )

( ) ( ) ( )

1 1 2 0 2

x x

f x f x f x

i i i + ∆ ∆

− ′ (^) =

  • −

Central Divided Difference

Hence showing that we have obtained a more accurate formula as the

error is of the order of (^) ( ).

2

0 Δ x

x

f(x)

x-Δx x x+Δx

Figure 3 Graphical Representation of central difference approximation of first derivative