Beruflich Dokumente
Kultur Dokumente
Dr.U.Oral nal
Polynomial Approach
According to Newtons fundamental formula:
f x Pn x Rn x
Hence we can write:
df x dPn x dRn x
dx dx dx
Polynomial Approach
Forward differentiation
dP2 dP2 d 1 2 1 2
f f0
d dx h
0
dx x x0 0 2! 0
1
f f
1
f 2 f f
h
0 1 0 1 2
2
1
3 f 0 4 f 1 f 2
2h
Polynomial Approach
Central differentiation
Using Stirling`s formula:
2 ( ) 3
0 0
0 + = 0 + 0 + 2 + 1 +1 +
2! 3!
where 1/2(E1/2+E-1/2)
Polynomial Approach
Central differentiation
dP2
dx
1
h
f 0 2 f 0
0
x x0
dP2 1 1 h h
f x0 f x0 ( f 0 )
dx x x0 h 2 2 2 0
1 1
f1 f 1 f1 2 f 0 f 1
dP2
dx x x0 h 2 0
dP2 f1 f 1
dx x x0 2h
Error term
The error for the differentiation formulas may be determined with the aid of the
error term Rn(x):
n f n 1
Rn x x xi ; x0 xn
i 0 n 1!
dRn d x f n 1 1 f n 2 2
x
dx dx n 1! n 2!
where
n
x x xi and 1 , 2 x0 , x1 , xn
i 0
Error term
dRn
If we evaluate at x=xj, since the second term is zero, we can obtain:
dx
dRn x j d x j f n 1 n f n 1
x j xi
dx dx n 1! i 0 n 1!
i j
d x j
dx is of the order of hn. From this point of view, since the value of
f(n+1)() is unknown for most cases, we can express the error on the numerical
differentiation in terms of the order of the power of the interval.
However, it should be born in mind that the rounding error increases with
decreasing values of h.
dRn x
dx
O hn
d 2 Rn x d m Rn x
dx 2
n 1
O h ,,
dx m
O h n m 1
Example
Find the value of y at x=0.0 by using the value pairs given below.
Determine the truncation and rounding errors.
xi yi y 2 y 3 y 4 y
0.00 0.00000
0.10017
0.05 0.10017 0.00100
0.10117 0.00101
0.10 0.20134 0.00201 0.00003
0.10318 0.00104
0.15 0.30452 0.00305 0.00003
0.10623 0.00107
0.20 0.41075 0.00412
0.11035
0.25 0.52110
Example
By using a fourth degree polynomial ;
1 1 2 1 2 3
P4 f 0 f 0 2 f 0 3 f 0 4 f 0
2! 3! 4!
dP4 1 dP4 1 2 1 2 3 2 6 2 3 4 3 18 2 22 6 4
f 0 f0 f0 f0
dx h d h 2 6 24 0
dP4 1 1 1 1
f 0 2 f 0 3 f 0 4 f 0 1.99998
dx x x0 h 2 3 4
may be found.
On the other hand, the same result may be obtained by using finite difference
expressions, without generating a difference table:
1
dP4
f f
1
f 2 f f
1
f 3 f 3 f f
1
f 4 f 6 f 4 f f
h
1 0 2 1 0 3 2 1 0 4 3 2 1 0
dx x x0 2 3 4
dP4
1
25 f 0 48 f1 36 f 2 16 f 3 3 f 4 1.99998
dx x x0 12h
The derivative expression found above is the fourth degree forward differentiation
formula.
Example
Now let us examine the truncation and rounding errors:
dR4 1 d 1 2 3 4 R x x x x x x x
f n 1
5
f 0
dx x x h d n 1
(n 1)!h
n 0 1 n
0
0
5! 0
24 1 5 1 5 1 2 n
f0 f0 Rn h x0 n 1 f 0
5! h 5h n 1!
Although h=0.05 and 5f0 is 0.00000, there exists, at least, a rounding error of
0.000005. Hence the truncation error may be found as:
dR4
2 105
dx x x0
dR4
dx
O h 4 0.625 10 5
x x0
O 10 5
Example
On the other hand, the rounding error of each yi is yi=0.000005=. Because of
the 128 operations performed in the fourth forward differentiation formula the
rounding error is high.
In order to find the rounding error made in the calculation of y, let us first
consider the relative error:
128 25 f 0 48 f1 36 f 2 16 f 3 3 f 4
y num denom 12 h
The error of 12 and h may be taken as zero since they are accurate values. The
square bracket represents the numerator of y.
128
Therefore, since the relative error is y , the absolute error is:
y
128
12h As is seen, the rounding error is greater than the truncation
error and it is inversely proportional with h. Accordingly, it
128 0.000005
y 10 3 is more accurate to give the value of the derivative as:
12 0.05
y x 0 2.00
Order of Accuracy for the Central Differences
Example:
Using the polynomial approach, calculate;
o the third derivative with first order accuracy, ileriye doru farklar ile,
o The second derivative with second-order-accuracy central differences.
14
Differentiation with the Finite Difference Operators
High-order formulas can be obtained by using finite difference operators:
n is even
n is odd
Example:
Use the formulas given to obtain;
o the third derivative with first order accuracy, ileriye doru farklar ile, 15
o The second derivative with second-order-accuracy central differences.
Differentiation with Taylor series
-Forward Differentiation-
f (x+x) can be expanded to Taylor series about x as follows:
16
Differentiation with Taylor series
-Backward Differentiation-
Expanding f(x-x) about x:
17
Differentiation with Taylor series
-Backward Differentiation-
Taking the difference of f(x-x) and f(x+x):
18
Differentiation With Taylor Series
Higher Order Derivatives-
-
(a)
(b)
In order to obtain the central difference formula, simply add the forward and
backward approximation formulas:
20
Differentiation with Taylor series
-Higher Order Accuracy-
21
Example
- 4-point backward formula (Dawson) -
For a 1-dimensional grid system let us expand the u velocities to Taylor series
Example
- 4-point backward formula (Dawson) -
Multiply the first equation by 15, the second one by (-6) and collect three
equations:
which gives:
Extrapolation
Suppose that we have tabulated values.
We can also repeat the scheme using h values of 0.2 and 0.4.
We should first specify the number of points used in the formula and
indicate whether the formula is a forward, backward or central-
difference formula.
28
Method of Undetermined Coefficients
We should have:
Hence:
29
Rounding and truncation
Calculating the first derivative with the three-point forward
differentiation:
Total error:
Rounding and truncation
For the rounding errors we have:
Assuming that
32
Partial Derivatives of Multivariable Functions
33
Mixed Partial Derivatives
First let us perform a forward
differentiation with respect to y:
34
Mixed Partial Derivatives
Let us consider the same case. Now we use
the second-order central differences.
35
What Happens When the Node Points Are Not
Equidistant?
How can we calculate the derivatives in the following case?
f x2 , x1 f x1 , x0
f x2 , x1 , x0 f x1 , x0 , x2 f x0 , x2 , x1
x2 x0 36
What Happens When the Node Points Are Not
Equidistant?
P2 x f x0 x x0 f x1 , x0 x x0 x x1 f x2 , x1 , x0
2
= 1 , 0 + 2 1 0 2 , 1 , 0
=0
=0
= 1 + 0 1 2[ ]
2 1 1 0
2 , 1 1 , 0 2 1 1 + + 0
2 = 2 , 1 , 0 = = =
2 0 (1 + ) (1 + ) 2
10 21 1+ +0 0 2+ + 1+ 2 12
=
(1+) 2 (1+)
+ 2 + + 1 2 +1 +2
=
(1 + )
37