You are on page 1of 18

PART V

NUMERICAL
DIFFERENTIATION
&
INTEGRATION
1
Q23.8 pg 644
Estimate first derivative of
(a) y=x
3
+ 4x 15 ; at x = 0, h = 0.25
(b) y = e
x
+ x; at x = 2, h = 0.2

By using
(i) forward, backward, centered difference approximation
(ii) Richardson extrapolation

Q23.9 pg 644
The following data was collected for the distance traveled versus
time for a rocket:


Use numerical differentiation to estimate the rockets velocity and
acceleration at each time.


2
T,s 0 25 50 75 100 125
Y,km 0 32 58 78 92 100
NUMERICAL DIFFERENTATION
Introduction and Background
High Accuracy Differentiation Formulas
Richardson Extrapolation
3
Introduction
Estimate the derivatives (slope, curvature, etc.) of a
function by using the function values at only a set of
discrete points

Represent the function by Taylor polynomials or
Lagrange interpolation

Evaluate the derivatives of the interpolation
polynomial at selected nodal points
ONE-D CONSTITUTIVE LAWS IN
ENGINEERING
Law Equation Physical Area Gradient Flux Proportionalit
y
Fourier
Law
Heat
Conduction
Temperature Heat
Flux
Thermal
conductivity
Ficks Law Mass Diffusion Concentration Mass
Flux
Diffusivity
DArcys
Law
Flow Through
Porous Medium
Heat Flow
Flux
Hydraulic
Conductivity
Ohms Law Current Flow Voltage Current
Flux
Electrical
Conductivity
Newtons
Viscous
Law
Fluids Velocity Shear
Stress
Dynamic
Viscosity
Hooks
Law
Elasticity Deformation Stress Youngs
modulus
dT
q k
dx
=
dc
J D
dx
=
dh
q k
dx
=
dV
J
dx
o =
du
dx
t =
L
E
L
A
o =
4
FIRST DERIVATIVES
5
) x ( f
'
i-2 i-1 i i+1 i+2
x
Forward difference
Backward difference
Central difference
Actual
i i
i i
i i
i i
x x
y y
x x
x f x f
x f

~
'
+
+
+
+
1
1
1
1
) ( ) (
) (
1
1
1
1
) ( ) (
) (

~
'
i i
i i
i i
i i
x x
y y
x x
x f x f
x f
1 1
1 1
1 1
1 1
) ( ) (
) (
+
+
+
+

~
'
i i
i i
i i
i i
x x
y y
x x
x f x f
x f
DIFFERENTIATION BASED ON
TAYLOR SERIES
( ) ( ) ( )
( )
.........
! 2
' '
'
2
1
+ + + =
+
h
x f
h x f x f x f
i
i i i
FORWARD FINITE DIFFERENCE
( ) ( ) ( )
( )
.........
! 2
' '
'
2
1
+ + + =
+
h
x f
h x f x f x f
i
i i i
( )
( ) ( )
( ) h O
h
x f x f
x f
i i
i
+

=
+1
'
The error is O(h)
6
FORWARD DIVIDED DIFFERENCE
( )
( ) ( )
( ) ( ) h O
h
f
x x O
x x
x f x f
x f
i
i i
i i
i i
i
+
A
= +

=
+
+
+
1
1
1
'
f(x)
x
(x
i
, y
i
)
What is
derivative at
this
point?
f(x)
x
(x
i
, y
i
)
(x
i+1
,y
i+1
)
Determine a
second point
base on Dx (h)
f(x)
x
(x
i
, y
i
)
(x
i+1
,y
i+1
)
How does
this compare
to the actual
first derivative
at x
i
?
f(x)
x
(x
i
, y
i
)
(x
i+1
,y
i+1
)
7
( ) ( ) ( )
( )
( ) ( ) ( )
( )
.....
! 2
' '
'
......
! 2
' '
'
2
1
2
1
+ + =
+ + + =

+
h
x f
h x f x f x f
h
x f
h x f x f x f
i
i i i
i
i i i
Expand the Taylor series backwards
The error is still O(h)
BACKWARD FINITE DIFFERENCE
f(x)
x
(x
i
,y
i
)
(x
i-1
,y
i-1
)
( )
( ) ( )
h
f
h
x f x f
x f
i
i i
i
V
=

=
1
'
8
Subtract backward difference approximation from forward
Taylor series expansion
( ) ( ) ( )
( )
+ + =
+
3
1 1
! 3
' ' '
2 ' 2 h
x f
h x f x f x f
i
i i i
CENTERED FINITE DIFFERENCE
f(x)
x
(x
i
,y
i
)
(x
i-1
,y
i-1
)
(x
i+1
,y
i+1
) ( )
( ) ( )
( )
2
1 1
2
' h O
h
x f x f
x f
i i
i

=
+
( ) ( ) ( )
( ) ( )
( ) ( ) ( )
( ) ( )
...
! 3
' ' '
! 2
' '
'
...
! 3
' ' '
! 2
' '
'
3 2
1
3 2
1
h
x f
h
x f
h x f x f x f
h
x f
h
x f
h x f x f x f
i i
i i i
i i
i i i
+ =
+ + + =

+
The error is O(h
2
)
9
f(x)
x
f(x)
x
f(x)
x
f(x)
x
true derivative
backward
finite divided
difference approx.
centered
finite divided
difference approx.
forward
finite divided
difference approx.
SUMMARY
10
3 -point Forward difference


3 -point Backward difference

) x ( f
'
i-2 i-1 i i+1 i+2
2 i i
2 i 1 i i
i 2 i
i 1 i 2 i
x x
x f 3 x f 4 x f 3
x f
x x
x f 3 x f 4 x f
x f


+
+ +

+
~ '

+
~ '
) ( ) ( ) (
) (
) ( ) ( ) (
) (
Parabolic curve
GENERAL 3 POINTS FIRST DERIVATIVE
11
Use forward and backward difference approximations
of O(h
2
) to estimate the first derivative of

at x = 0.5 with h = 0.25 (exact sol. = -0.9125)
Forward Difference




Backward Difference
2 . 1 x 25 . 0 x 5 . 0 x 15 . 0 x 1 . 0 ) x ( f
2 3 4
+ =
% 82 . 5 , 859375 . 0
5 . 0
) 925 . 0 ( 3 ) 6363281 . 0 ( 4 2 . 0
) 25 . 0 ( 2
) 5 . 0 ( f 3 ) 75 . 0 ( f 4 ) 1 ( f
) 5 . 0 ( f
= =
+
=
+
= '
t


c
% 77 . 3 , 878125 . 0
5 . 0
2 . 1 ) 035156 . 1 ( 4 ) 925 . 0 ( 3
) 25 . 0 ( 2
) 0 ( f ) 25 . 0 ( f 4 ) 5 . 0 ( f 3
) 5 . 0 ( f
= =
+
=
+
= '
t
c
FIRST DERIVATIVE
17
FORWARD FINITE-DIVIDED DIFFERENCES
19
BACKWARD FINITE-DIVIDED DIFFERENCES
20
CENTERED FINITE-DIVIDED DIFFERENCES
21
RICHARDSON EXTRAPOLATION
Two ways to improve derivative estimates
decrease step size
use a higher order formula that employs more points
More accurate approximation
It is used to generate high-accuracy results while using
low-order formulas.
22
RICHARDSON EXTRAPOLATION
Integrals (second-order)






In similar fashion, Derivatives
(second-order, h
2
=h
1
/2)
23
| |

( ) ( ) ( )
( / )
/ ( ) ( )
2 2 1
2
1 2
2 1 2 1
1
I I h I h I h
h h 1
4 1
h h 2 I I h I h
3 3
= +

= =
( ) ( )
2 1
4 1
D D h D h
3 3
=
For a centered difference approximation with O(h
2
) the application
of this formula will yield a new derivative estimate of O(h
4
).
Special case h
2
= h
1
/2
EXAMPLE
Given the following function, use Richardsons extrapolation
to determine the derivative at 0.5.
f(x) = -0.1x
4
- 0.15x
3
- 0.5x
2
- 0.25x +1.2

f'(0.5)=?

By using centered difference to calculate f'(0.5) with h= 0.5
and h=0.25.

H= 0.5 h=0.25
f'(0.5) = (0.2-1.2)/2*0.5 f'(0.5) = (0.636-1.1035)/2*0.25
f(0) = 1.2
f(0.25) =1.1035
f(0.5) = 0.925
f(0.75) = 0.636
f(1) = 0.2

24

You might also like