Week 3.5 - Deriving 4th order approximation of a 2nd order derivative using Taylor Table method
Aim: - To derive and write a program for in MATLAB for 4th order approximation for second order derivative by following methods-
- Central difference
- Skewed right sided difference
- Skewed left sided difference
Objective: - 1. To evaluate the second order derivative of the function
- To plot and compare the values and errors of the 3 methods derived.
Theory and derivations: -
During solving a CFD problem we may come across partial derivative equation which consists 2nd order derivative. Since due to complexity of the equation we may have to chose numerical approach rather than analytical. But when dealing with numerical approach we try to make the error margin as low as possible.
As the order of approximation get higher, we get higher accuracy. Hence, we are going to derive the three methods of approximation for an analytical function. The methods are following.
- Central difference: - Here the nodes selected are symmetrical i.e. the data is taken from both sides of point of focus. Using Taylor’s method, we get
Here there are two nodes taken from both side of the point of focus i.e. f(i).
(NOTE: - To select the number of nodes in consideration, we use following expression:
N=p + q -1 for central differencing
N = p + q for skewed differencing
Here N is no. of nodes, p is order of derivative and q is order of approximation.)
Taylor’s table for Central difference:
|
f(X) |
dx f’(x) |
dx2 f’’(x) |
dx3 f’’’(x) |
dx4 f’’’’(x) |
dx5 f’’’’’(x) |
|
|
af(i-1) |
a |
-2a |
4a/2 |
-8a/6 |
16a/24 |
-32a/120 |
|
bf(i-2) |
b |
-b |
b/2 |
-b/6 |
b/24 |
-b/120 |
|
cf(i) |
c |
0 |
0 |
0 |
0 |
0 |
|
df(i-1) |
d |
d |
d/2 |
d/6 |
d/24 |
d/120 |
|
ef(i-2) |
e |
2e |
4e/2 |
8e/6 |
16e/24 |
32e/120 |
|
af(i-2) +bf(i-1) +cf(i) +df(i+1) + ef(i+2) |
0 |
0 |
1 |
0 |
0 |
? |
This table transform into matrix of type AX=B
i.e. Values = a = -0.0833 b= 1.3333 c= -2.5000 d= 1.3333 e= -0.0833
These coefficients will further used in code to get the value of derivative.
- Skewed right sided difference: - When the data point of the left nodes are not available (at initial boundary conditions) then we have to rely on the available data set.
Taylor’s table for Skewed right sided difference:
|
f(x) |
dx f’ (X) |
dx2 f’’ (x) |
dx3 f’’’(x) |
dx4f’’’’(x) |
dx5f’’’’’(x) |
|
|
af(i) |
a |
0 |
0 |
0 |
0 |
0 |
|
bf(i+1) |
b |
b |
b/2 |
b/6 |
b/24 |
b/120 |
|
cf(i+2) |
c |
2c |
4c/2 |
8c/6 |
16c/24 |
32c/120 |
|
df(i+3) |
d |
3d |
9d/2 |
27d/6 |
81d/24 |
243d/120 |
|
ef(i+4) |
e |
4e |
16e/2 |
64e/6 |
256e/24 |
1024e/120 |
|
ff(i+5) |
f |
5f |
25f/2 |
125f/6 |
625f/24 |
3125f/120 |
|
af(i) + bf(i+1) + cf(i+2) + df(i+3) + ef(i+4) +ff(i+5) |
0 |
0 |
1 |
0 |
0 |
0 |
This table transform into matrix of type AX=B:
unknown i.e. Values = a = 3.7500 b= -12.8333 c= 17.8333
d= -13.0000 e= 5.0833 f= -0.8333
These coefficients will further used in code to get the value of derivative.
- Skewed left sided difference: - When the data point of the right nodes are not available (at boundary conditions) then we have to rely on the available data set.
Taylor’s table for Skewed right sided difference:
|
f(x) |
dx f’ (X) |
dx2 f’’ (x) |
dx3 f’’’(x) |
dx4f’’’’(x) |
dx5f’’’’’(x) |
|
|
af(i-5) |
a |
-5a |
25a/2 |
-125a/6 |
625a/24 |
-3125a/120 |
|
bf(i-4) |
b |
-4b |
16b/2 |
-64b/6 |
256b/24 |
-1024b/120 |
|
cf(i-3) |
c |
-3c |
9c/2 |
-27c/6 |
81c/24 |
-243c/120 |
|
df(i-2) |
d |
-2d |
4d/2 |
-8d/6 |
16d/24 |
-32d/120 |
|
ef(i-1) |
e |
-e |
e/2 |
-e/6 |
e/24 |
-e/120 |
|
ff(i) |
f |
0 |
0 |
0 |
0 |
0 |
|
af(i-5) + bf(i-4) + cf(i-3) + df(i-2) + ef(i-1) +ff(i) |
0 |
0 |
1 |
0 |
0 |
0 |
This table transform into matrix of type AX=B:
unknown i.e. Values = a = -0.8333 b= 5.0833 c=13.0000
d= 17.8333 e= -12.8333 f= 3.7500
These coefficients will further used in code to get the value of derivative.
Code: