Anda di halaman 1dari 44

ENGG 407

Numerical Methods in Engineering


P14 L01
Lecture #5
Dr. Sameh Nassar
ENGG 407 L02 Winter 2012 Lecture #5 Dr. Sameh Nassar
Sameh Nassar
ENGG 407 L01 Spring 2014 Lecture #5 Dr. Sameh Nassar
Recall: ENGG 407 P14 Topics
1. Introduction and Mathematical Background (Ch. #1, #2)
2. Roots of Nonlinear Equations (Ch. #3)
3. Linear Equations and Systems (Ch. #4, #5)
4. Interpolation, Least-squares Estimation & Curve Fitting (Ch. #6)
5. Numerical Differentiation (Ch. #8)
6. Numerical Integration (Ch. #9)
7. Ordinary Differential Equations: Initial Value Problems (Ch. #10)
8. Ordinary Differential Equations: Boundary Value Problems (Ch. #11)
ENGG 407 L02 Winter 2012 Lecture #5 Dr. Sameh Nassar
Sameh Nassar
ENGG 407 L01 Spring 2014 Lecture #5 Dr. Sameh Nassar
Recall from Lecture #1: Taylor Series
f(x
i+1
)
f(x
i
)
h
The term R
n
is called the
Remainder
where is a value of x that
lies between x
i
and x
i+1
For a function f(x) that depends on only one independent
variable x, the value at point x
i+1
can be approximated by
the following Taylor Series:
ENGG 407 L02 Winter 2012 Lecture #5 Dr. Sameh Nassar
Sameh Nassar
ENGG 407 L01 Spring 2014 Lecture #5 Dr. Sameh Nassar
Recall from Lecture #1: Taylor Series
k
0 k
i
) k (
1 i
h
! k
) x ( f
) x ( f

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

+
zero order approximation
h ) x ( f ) x ( f ) x ( f
i
'
i 1 i
+
+ 1
st
order approximation
2
i
' '
i
'
i 1 i
h
! 2
) x ( f
h ) x ( f ) x ( f ) x ( f + +
+
2
nd
order approximation
M
n
i
) n (
2
i
' '
i
'
i 1 i
h
! n
) x ( f
.... h
! 2
) x ( f
h ) x ( f ) x ( f ) x ( f + + + +
+
n
th
order approx.
ENGG 407 L02 Winter 2012 Lecture #5 Dr. Sameh Nassar
Sameh Nassar
ENGG 407 L01 Spring 2014 Lecture #5 Dr. Sameh Nassar
Recall from Lecture #1: Taylor Series
Sometimes, Taylor Series can be written using the following
format:
i.e. replacing the symbols x
i+1
by x and x
i
(point of expansion)
by a.
For a function that is a function of two or more (independent)
variables, Taylor Series can be applied in the same manner as
for one variable, however, the differentiation will involve
partial derivatives.
ENGG 407 L02 Winter 2012 Lecture #5 Dr. Sameh Nassar
Sameh Nassar
ENGG 407 L01 Spring 2014 Lecture #5 Dr. Sameh Nassar
Why Numerical Differentiation?
Thus, in the first case above (i.e. known function), tabulated data
points are obtained first from the function and then numerical
differentiation is performed.
In the second case above (i.e. given data points), numerical
differentiation can be done using one of two approaches:
(1) Finite difference approximation.
(2) Function approximation (by fitting a curve first to the data using
any method from Lecture #4 and then differentiate it analytically ).
Numerical differentiation is employed in the following cases:
The function is known but is difficult (or not possible) to be
differentiated analytically.
A set of discrete points is provided and a differentiation is required.
ENGG 407 L02 Winter 2012 Lecture #5 Dr. Sameh Nassar
Sameh Nassar
ENGG 407 L01 Spring 2014 Lecture #5 Dr. Sameh Nassar
Numerical Differentiation
Finite Difference
Approximation
Function
Approximation
Discrete
Points
Fitted
Curve
ENGG 407 L02 Winter 2012 Lecture #5 Dr. Sameh Nassar
Sameh Nassar
ENGG 407 L01 Spring 2014 Lecture #5 Dr. Sameh Nassar
Numerical Differentiation
)
i
(x f'
Numerical
Differentiation
(finite difference
approximation)
Differentiation
ENGG 407 L02 Winter 2012 Lecture #5 Dr. Sameh Nassar
Sameh Nassar
ENGG 407 L01 Spring 2014 Lecture #5 Dr. Sameh Nassar
Finite Difference Approximation
General Finite difference
approximation formulae
for derivatives are
obtained using Taylor
series.
However, for 1
st
order
approximations (i.e. first
derivatives), formulae can
be obtained directly using
simple mathematics (or
geometry!)
ENGG 407 L02 Winter 2012 Lecture #5 Dr. Sameh Nassar
Sameh Nassar
ENGG 407 L01 Spring 2014 Lecture #5 Dr. Sameh Nassar
Numerical Differentiation
n n
i 1 i
i
) n (
2
i 1 i
i
' '
i 1 i i
'
i 1 i
R ) x x (
! n
) x ( f
.... ) x x (
! 2
) x ( f
) x x )( x ( f ) x ( f ) x ( f + + + + + =
+ + + +
n n
i
) n (
2
i
' '
i
'
i 1 i
R h
! n
) x ( f
.... h
! 2
) x ( f
h ) x ( f ) x ( f ) x ( f + + + + + =
+
1
i
'
i 1 i
R h ) x ( f ) x ( f ) x ( f + + =
+
) h (
h
f
h
R
h
) x ( f ) x ( f
) x ( f
i
1
i 1 i
i
'
O +

=
+
Forward Finite Divided Difference (Using Taylor Series):
) x ( f
1 i+
) x ( f
i
i
f
1
st
forward difference
h
f
i

1
st
forward finite
divided difference
) x ( ' f
i
1
st
order forward finite difference
Truncation error
Assuming equidistant points
ENGG 407 L02 Winter 2012 Lecture #5 Dr. Sameh Nassar
Sameh Nassar
ENGG 407 L01 Spring 2014 Lecture #5 Dr. Sameh Nassar
Numerical Differentiation
n n
i 1 i
i
) n (
2
i 1 i
i
' '
i 1 i i
'
i 1 i
R ) x x (
! n
) x ( f
.... ) x x (
! 2
) x ( f
) x x )( x ( f ) x ( f ) x ( f + + + + + =

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

1
i
'
i 1 i
R h ) x ( f ) x ( f ) x ( f + =

) h (
h
f
h
R
h
) x ( f ) x ( f
) x ( f
i
1
1 i i
i
'
O +

=

Backward Finite Divided Difference (Using Taylor Series):
) x ( f
1 i
) x ( f
i
i
f
1
st
backward difference
h
f
i

1
st
backward finite
divided difference
) x ( ' f
i
1
st
order backward finite difference
Truncation error
Assuming equidistant points
ENGG 407 L02 Winter 2012 Lecture #5 Dr. Sameh Nassar
Sameh Nassar
ENGG 407 L01 Spring 2014 Lecture #5 Dr. Sameh Nassar
Numerical Differentiation
....... h
! 3
) x ( f
h
! 2
) x ( f
h ) x ( f ) x ( f ) x ( f
3
i
) 3 (
2
i
' '
i
'
i 1 i
+ + =

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

=
+
+
Centered Finite Divided Difference (Using Taylor Series):
_
subtract
Truncation error
Assuming equidistant points
Assuming equidistant points
) x ( f
1 i
) x ( f
1 i+
i
x
ENGG 407 L02 Winter 2012 Lecture #5 Dr. Sameh Nassar
Sameh Nassar
ENGG 407 L01 Spring 2014 Lecture #5 Dr. Sameh Nassar
Simple Finite Differences for the First Derivative
forward finite
divided difference
centered finite
divided difference
backward finite
divided difference
h
) x ( f ) x ( f
) x ( f
i 1 i
i
'

+
h
) x ( f ) x ( f
) x ( f
1 i i
i
'

h 2
) x ( f ) x ( f
) x ( f
1 i 1 i
i
'
+

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

+
+
1
1
'
) ( ) (
) (
OR
OR
OR
1
1
'
) ( ) (
) (

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

i i
i i
i
x x
x f x f
x f
Note that h is used when the points are equally spaced.
For each of the given formulae above, only 2 points are used to
estimate the 1
st
derivative, and hence they are called two-point
finite difference formulae.
ENGG 407 L02 Winter 2012 Lecture #5 Dr. Sameh Nassar
Sameh Nassar
ENGG 407 L01 Spring 2014 Lecture #5 Dr. Sameh Nassar
Example #1
Use the forward, backward and centered difference
approximation to estimate the first derivative of:
f(x) = sin(x) at x=0.8 using a step size h=0.6.
Then, estimate the true relative error for each case.
Hint: all x values are in radians
ENGG 407 L02 Winter 2012 Lecture #5 Dr. Sameh Nassar
Sameh Nassar
ENGG 407 L01 Spring 2014 Lecture #5 Dr. Sameh Nassar
Example #1 (sol. 1/3)
4 . 1 x , 2 . 0 x
1 i 1 i
= =
+
1814896 0.44682273
6 . 0
) 8 . 0 sin( ) 4 . 1 sin(
h
) x ( f ) x ( f
) x ( f
i 1 i
i
'
forw
=

+
3507436 0.86447793
6 . 0
) 2 . 0 sin( ) 8 . 0 sin(
h
) x ( f ) x ( f
) x ( f
1 i i
i
'
back
=


f(x)=sin(x)
cos(0.8) = 0.696706709347165 (assumed true value)
6 . 0 h , 8 . 0 x
i
= =
f(x)=cos(x)
2661166 0.65565033
6 . 0 * 2
) 2 . 0 sin( ) 4 . 1 sin(
h 2
) x ( f ) x ( f
) x ( f
1 i 1 i
i
'
cent
=

+
ENGG 407 L02 Winter 2012 Lecture #5 Dr. Sameh Nassar
Sameh Nassar
ENGG 407 L01 Spring 2014 Lecture #5 Dr. Sameh Nassar
Example #1 (sol. 2/3)
% 24.1 % 100
9347165 0.69670670
3507436 0.86447793 - 9347165 0.69670670
| = =
back
t
|
% 35.9 % 100
9347165 0.69670670
1814896 0.44682273 - 9347165 0.69670670
| = =
forw
t
|
% 5.9 % 100
9347165 0.69670670
2661166 0.65565033 - 9347165 0.69670670
| = =
cent
t
|
Comment!
ENGG 407 L02 Winter 2012 Lecture #5 Dr. Sameh Nassar
Sameh Nassar
ENGG 407 L01 Spring 2014 Lecture #5 Dr. Sameh Nassar
Example #1 (sol. 3/3)
X (radians)
f(x)
f(x)=sin(x)
) 8 . 0 ( f
'
forw
f(0.8)=cos(0.8)
) 8 . 0 ( f
'
back
) 8 . 0 ( f
'
cent
ENGG 407 L02 Winter 2012 Lecture #5 Dr. Sameh Nassar
Sameh Nassar
ENGG 407 L01 Spring 2014 Lecture #5 Dr. Sameh Nassar
Finite Differences for the First Derivative
If higher accuracy is required for the estimated derivative, more than 2
points should be used and also Taylor series should not be truncated
after only the linear term. For example:
High-Accuracy Divided-Differences Formulae
It can be shown that:
forward Taylor series expansion
Three-point forward
difference for 1
st
derivative
ENGG 407 L02 Winter 2012 Lecture #5 Dr. Sameh Nassar
Sameh Nassar
ENGG 407 L01 Spring 2014 Lecture #5 Dr. Sameh Nassar
Finite Differences for the First Derivative
Summary (for Equidistant Points)
ENGG 407 L02 Winter 2012 Lecture #5 Dr. Sameh Nassar
Sameh Nassar
ENGG 407 L01 Spring 2014 Lecture #5 Dr. Sameh Nassar
Example #2
Use the centered difference approximation to estimate the first
derivative of:
f(x) = sin(x) at x=0.8 using a step size h=0.6.
Apply both the two-point and the four-point formulae.
Then, estimate the true relative error for each case.
Hint: all x values are in radians
ENGG 407 L02 Winter 2012 Lecture #5 Dr. Sameh Nassar
Sameh Nassar
ENGG 407 L01 Spring 2014 Lecture #5 Dr. Sameh Nassar
Example #2 (sol. 1/2)
f(x)=sin(x)
cos(0.8) = 0.696706709347165 (assumed true value)
f(x)=cos(x)
h 2
) x ( f ) x ( f
) x ( f
1 i 1 i
i
'
cent
+

h 12
) x ( f ) x ( f 8 ) x ( f 8 ) x ( f
) x ( f
2 i 1 i 1 i 2 i
i
'
cent
+ +
+ +

Four-Point formula
Two-Point formula
0 . 2 x , 4 . 1 x
4 . 0 x , 2 . 0 x
2 i 1 i
2 i 1 i
= =
= =
+ +

6 . 0 h , 8 . 0 x
i
= =
Centered divided difference formulas:
ENGG 407 L02 Winter 2012 Lecture #5 Dr. Sameh Nassar
Sameh Nassar
ENGG 407 L01 Spring 2014 Lecture #5 Dr. Sameh Nassar
Example #2 (sol. 2/2)
h 2
) x ( f ) x ( f
) x ( f
1 i 1 i
i
'
cent
+

h 12
) x ( f ) x ( f 8 ) x ( f 8 ) x ( f
) x ( f
2 i 1 i 1 i 2 i
i
'
cent
+ +
+ +

2661166 0.65565033
6 . 0 * 2
) 2 . 0 sin( ) 4 . 1 sin(
) x ( f
i
'
cent
=

% 5.9 % 100
9347165 0.69670670
2661166 0.65565033 - 9347165 0.69670670
| = =
cent
t
|
3390675 0.69382325
6 . 0 * 12
) 4 . 0 sin( ) 2 . 0 sin( * 8 ) 4 . 1 sin( * 8 ) 0 . 2 sin(
) x ( f
i
'
cent
=
+ +

% 0.413 % 100
9347165 0.69670670
3390675 0.69382325 - 9347165 0.69670670
| = =
cent
t
|
Two-Point formula
Four-Point formula
ENGG 407 L02 Winter 2012 Lecture #5 Dr. Sameh Nassar
Sameh Nassar
ENGG 407 L01 Spring 2014 Lecture #5 Dr. Sameh Nassar
Finite Differences for the Second Derivative
Summary (for Equidistant Points)
ENGG 407 L02 Winter 2012 Lecture #5 Dr. Sameh Nassar
Sameh Nassar
ENGG 407 L01 Spring 2014 Lecture #5 Dr. Sameh Nassar
Finite Differences for the Third Derivative
Summary (for Equidistant Points)
ENGG 407 L02 Winter 2012 Lecture #5 Dr. Sameh Nassar
Sameh Nassar
ENGG 407 L01 Spring 2014 Lecture #5 Dr. Sameh Nassar
Finite Differences for the Fourth Derivative
Summary (for Equidistant Points)
ENGG 407 L02 Winter 2012 Lecture #5 Dr. Sameh Nassar
Sameh Nassar
ENGG 407 L01 Spring 2014 Lecture #5 Dr. Sameh Nassar
Finite Difference Numerical Differentiation Errors
Recall that h is typically < 1.0.
For small h values, the values of
f(x-h), f(x), f(x+h) will be very close
to each other, and hence the use of
finite difference formulae may
result in loss of precision due to
subtractive cancellation.
Recall from Lecture #1 that
smaller h values will reduce
truncation errors but may result in
large round-off errors.
Recall from Lecture #1:
Total Numerical Error = Truncation Errors + Round-Off Errors
ENGG 407 L02 Winter 2012 Lecture #5 Dr. Sameh Nassar
Sameh Nassar
ENGG 407 L01 Spring 2014 Lecture #5 Dr. Sameh Nassar
Example #3 (In Class Example!)
Use the two-point centered difference approximation to
estimate the first derivative of:
f(x) = sin(x) at x=0.8 using the following step sizes:
h = 0.6, 0.0375, 1.875x10
-4
and 2.5x10
-7
.
Then, estimate the true relative error for each case and
comment on the results.
Hints:
- All x values are in radians.
- Use 8 decimal points in your computations.
ENGG 407 L02 Winter 2012 Lecture #5 Dr. Sameh Nassar
Sameh Nassar
ENGG 407 L01 Spring 2014 Lecture #5 Dr. Sameh Nassar
Numerical Differentiation
(2) Function Approximation Techniques:
As mentioned earlier, this is done by fitting
a curve first to the data using any method
from Lecture #4 and then differentiate
it (i.e. the fitted function) analytically.
This approach has the advantages of being
used with non-equidistant data and that
the derivative can be estimated at any point between the given data
points or the points themselves.
Usually polynomials are used for the curve fitting since they are
easy to differentiate.
Also, Lagrange polynomials are often used due to their simplicity.
Discrete
Points
Fitted
Curve
ENGG 407 L02 Winter 2012 Lecture #5 Dr. Sameh Nassar
Sameh Nassar
ENGG 407 L01 Spring 2014 Lecture #5 Dr. Sameh Nassar
Numerical Differentiation
(2) Function Approximation Techniques:
Recall Lagrange Polynomials for n+1 data points from Lecture #4:
where:
Case
of 1
st
order
Case of
2
nd
order
ENGG 407 L02 Winter 2012 Lecture #5 Dr. Sameh Nassar
Sameh Nassar
ENGG 407 L01 Spring 2014 Lecture #5 Dr. Sameh Nassar
Numerical Differentiation
(2) Function Approximation Techniques:
Thus, the derivative of any order k, can be obtained at any point x as:
0
Case of n = 2 (i.e. 3 data points):
0
Home Work!:
For the above derivative, prove that in case of equidistant points it will
simplify to the three-point forward divided difference formula used
earlier.
ENGG 407 L02 Winter 2012 Lecture #5 Dr. Sameh Nassar
Sameh Nassar
ENGG 407 L01 Spring 2014 Lecture #5 Dr. Sameh Nassar
Richardsons Extrapolation
Error-correction techniques are used to improve the results of
numerical differentiation on the basis of the derivative estimates
themselves.
The methods using two estimates of a derivative to compute a third,
more accurate approximation, are known as Richardsons
Extrapolation techniques.
Hence, Richardsons Extrapolation is a general algorithm that
minimizes the error in the computation of a derivative, i.e. f(x) by
combining two less accurate approximations of the derivative.
This is done as steps, and based on the number of such steps, the
truncation error will decrease from O(h
2
) to O(h
4
), O(h
6
), O(h
8
),.
Richardsons Extrapolation will be used again with some numerical
integration approaches (stay tuned for discussion in Lecture #6!).
ENGG 407 L02 Winter 2012 Lecture #5 Dr. Sameh Nassar
Sameh Nassar
ENGG 407 L01 Spring 2014 Lecture #5 Dr. Sameh Nassar
Richardsons Extrapolation
Using finite difference for numerical differentiation to obtain the first
derivative f(x) with a step size h:
(h) (h) E D D (x) f' + = =
) (
1 i i
x x h =
+
Exact value
of the derivative
Approximate value
of the derivative
Truncation
Error
with:
) (h ) (h ) (h ) (h
2 2 1 1
E D E D D + = + =
1
i i
1
n
x x
h
) (
1

=
+
with:
2
i i
2
n
x x
h
) (
1

=
+
)
1 2 1 2
h h (i.e. , n n < >
and:
ENGG 407 L02 Winter 2012 Lecture #5 Dr. Sameh Nassar
Sameh Nassar
ENGG 407 L01 Spring 2014 Lecture #5 Dr. Sameh Nassar
Richardsons Extrapolation
Recall:
)] (h ) (h [
h (h
) (h x f
1 2
2 1
2
D D D D

+ =
1 ) /
1
) ( '
2
2
2
2
1
2
1
h
h
) (h
) (h
=
E
E
i.e. it is O(h
2
)
estimation error
With O(h
4
)
estimation
error
Using the two-point centered divided difference:
) h (
h 2
) x ( f ) x ( f
) x ( f
h
6
) x ( f
h 2
) x ( f ) x ( f
) x ( f
2
1 i 1 i
i
'
2
i
) 3 (
1 i 1 i
i
'
O +

=
+
+
Truncation error
Then, if using two different step sizes (h
1
and
h
2
,the following relationship can be obtained:
Thus:
(h) D
ENGG 407 L02 Winter 2012 Lecture #5 Dr. Sameh Nassar
Sameh Nassar
ENGG 407 L01 Spring 2014 Lecture #5 Dr. Sameh Nassar
Richardsons Extrapolation
Special Case:
) (h ) (h
1 2
D D D
3
1
3
4

2 h h
1 2
/ =
l
i.e. D D D
3
1
3
4
a

More accurate
estimate
Less accurate
estimate
Improved
Derivative
] 4 [
3
1
or ) (h ) (h
1 2
D D D
ENGG 407 L02 Winter 2012 Lecture #5 Dr. Sameh Nassar
Sameh Nassar
ENGG 407 L01 Spring 2014 Lecture #5 Dr. Sameh Nassar
Richardsons Extrapolation
n h D
0
D
1
D
2
D
3
0 h
1
D(h
1
) D(h
2
, h
1
) D(h
3
, h
2
, h
1
) D(h
4
, h
3
, h
2
, h
1
)
1 h
2
D(h
2
) D(h
3
, h
2
) D(h
4
, h
3
, h
2
)
2 h
3
D(h
3
) D(h
4
, h
3
)
3 h
4
D(h
4
)
l
0 0 1
D D D
3
1
3
4
a

l
1 1 2
D D D
15
1
15
16

a
l
2 2 3
D D D
63
1
63
64

a
O(h
4
)
O(h
6
)
O(h
2
)
O(h
8
)
Error:
D
0
is the derivative obtained using the two-point centered divided difference
h
2
= h
1
/2, h
3
= h
1
/4, h
4
= h
1
/8, .
ENGG 407 L02 Winter 2012 Lecture #5 Dr. Sameh Nassar
Sameh Nassar
ENGG 407 L01 Spring 2014 Lecture #5 Dr. Sameh Nassar
Richardsons Extrapolation
Thus, the general formulae for Richardsons Extrapolation (for the
first derivative) can be written as:
For efficient application of Richardsons Extrapolation, the algorithm
is applied recursively using a specified number of N approximations
for successive values of D
m
s obtained using h/2
n
.
In this case, a starting value for h is selected (n =0) and N+1 values
are computed (0 n N), i.e.:
Then the recursive computation is done as:
ENGG 407 L02 Winter 2012 Lecture #5 Dr. Sameh Nassar
Sameh Nassar
ENGG 407 L01 Spring 2014 Lecture #5 Dr. Sameh Nassar
Richardsons Extrapolation
Like any recursive (iterative method), the approximations can stop by
either specifying an or choosing a specific N.
As discussed earlier with finite difference formulae (when very small h is
selected), Richardsons Extrapolation may lead to round-off errors as
well, however, it can provide very high accuracy without using extremely
small values of h.
Error:
ENGG 407 L02 Winter 2012 Lecture #5 Dr. Sameh Nassar
Sameh Nassar
ENGG 407 L01 Spring 2014 Lecture #5 Dr. Sameh Nassar
Example #4 (In Class Example)
Estimate the first derivative of f(x) = sin(x) at x=0.8 using
Richardsons Extrapolation with an initial step size of 0.3.
Apply three approximation steps (i.e. N = 3)
Then, estimate the true relative error after each approximation
and comment on the results.
Hints:
- All x values are in radians.
- Use 8 decimal points in your computations.
ENGG 407 L02 Winter 2012 Lecture #5 Dr. Sameh Nassar
Sameh Nassar
ENGG 407 L01 Spring 2014 Lecture #5 Dr. Sameh Nassar
Numerical Partial Differentiation
Numerical partial differentiation is used to estimate the derivatives of
functions of more than one variable, i.e. for z = f(x, y) for example.
In this case, z is a function of 2 independent
variables (x and y) and the z value is given at
n m points (x
i
, y
j
).
The derivatives are obtained for one variable
at a time (i.e. considering all other variables
as constants).
Thus, the numerical differentiation formulae of
functions of one variable are applied to multi-
variable functions but for each variable at a
time.
In the sequel, some of the finite difference formulae (used earlier) are
given for data with constant spacing h
x
and h
y
in the x direction and y
direction, respectively.
ENGG 407 L02 Winter 2012 Lecture #5 Dr. Sameh Nassar
Sameh Nassar
ENGG 407 L01 Spring 2014 Lecture #5 Dr. Sameh Nassar
Numerical Partial Differentiation
Two-point central divided difference for 1
st
derivatives
Three-point central divided difference for 2
nd
derivatives:
ENGG 407 L02 Winter 2012 Lecture #5 Dr. Sameh Nassar
Sameh Nassar
ENGG 407 L01 Spring 2014 Lecture #5 Dr. Sameh Nassar
Numerical Partial Differentiation
Four-point central divided difference for mixed 2
nd
derivatives:
ENGG 407 L02 Winter 2012 Lecture #5 Dr. Sameh Nassar
Sameh Nassar
ENGG 407 L01 Spring 2014 Lecture #5 Dr. Sameh Nassar
Example #5
The following data for the velocity component in the x-direction, u,
are obtained as a function of the two coordinates x and y.
Use the four-point central divided difference formula for mixed 2
nd
derivatives to evaluate such derivative at the point (2, 3).
ENGG 407 L02 Winter 2012 Lecture #5 Dr. Sameh Nassar
Sameh Nassar
ENGG 407 L01 Spring 2014 Lecture #5 Dr. Sameh Nassar
Example #5
h
x
= 1, h
y
=1
f(x
i+1
, y
j+1
) = u(3, 4) = 9 f(x
i-1
, y
j+1
) = u(1, 4) = 7
f(x
i+1
, y
j-1
) = u(3, 2) =
22
f(x
i-1
, y
j-1
) = u(1, 2) = 8
x
i
= 2, y
j
=3
ENGG 407 L02 Winter 2012 Lecture #5 Dr. Sameh Nassar
Sameh Nassar
ENGG 407 L01 Spring 2014 Lecture #5 Dr. Sameh Nassar
Sections:
8.1
8.2
8.3
8.4
8.5
8.6
8.7
8.8
8.9
8.10
Textbook Readings

Anda mungkin juga menyukai