Week 3.5 - Deriving 4th order approximation of a 2nd order derivative using Taylor Table method
Objective:
- To derive the following 4th order approximations of the second-order derivative.
1. Central difference
2. Skewed right-sided difference
3. Skewed left-sided difference.
- To write a program in MATLAB to evaluate the second-order derivative of the analytical function ex.cos(x) and compare it with the 3 numerical approximations that have been derived.
Taylor's Series:
A Taylor Series is an expansion of some function into an infinite sum of terms, where each term has a larger exponent like x, x2, x3, etc.
Example: The taylor series for the function ex:
ex = 1+x+ x22! + x33! + x44! + x55! +...
says that the function:ex is equal to the infinite sum of terms:1 + x + x2/2! + x3/3! + ... etc.
Approximations:
We can use the first few terms of a Taylor Series to get an approximate value for a function.
Here we show better and better approximations for cos(x). The red line is cos(x), the blue is the approximation.

Central Differencing:
We are going to derive the central differencing for the fourth order approximation of the second order derivative of a function using Taylor's table method.
In order to derive the central differencing we need to calculate the number of nodes or stencils required to evaluate the second order accurate.
For Central Differencing,
Number of Nodes, N=P+Q−1
where,
P = Order of the derivative.
Q = Order of Approximation.
For fourth order approximation of the second order derivative , the number of nodes required to derive central differencing is,
N = 2 + 4 - 1 = 5.
The hypothesis of the second order derivative is expressed as,
∇x2f''(x)=af(i−2)+bf(i−1)+cf(i)+df(i+1)+ef(i+2)...........(1)
Now evaluating each term of the hypothesis using taylor series,
af(i−2)=a[f(i)−2∇x1!f'(i)+(2∇x)22!f''(i)−(2∇x)33!f'''(i)+(2∇x)44!−.........]
bf(i−1)=b[f(i)−∇x1!f'(i)+(∇x)22!f''(i)−(∇x)33!f'''(i)+(∇x)44!−.........]
cf(i)=cf(i)
df(i+1)=d[f(i)+∇x1!f'(i)+(∇x)22!f''(i)+(∇x)33!f'''(i)+(∇x)44!−.........]
ef(i+2)=e[f(i)+2∇x1!f'(i)+(2∇x)22!f''(i)+(2∇x)33!f'''(i)+(2∇x)44!−.........]
Generating Taylor's table to visualise the equations properly,
| ∇x2∂2f∂x2 | f(i) | ∇xf'(i) | ∇x2f''(i) | ∇x3f'''(i) | ∇x4f''''(x) |
| af(i−2) | a | -2a | 4a/2 | -8a/6 | 16a/24 |
| bf(i−1) | b | -b | b/2 | -b/6 | b/24 |
| cf(i) | c | 0 | 0 | 0 | 0 |
| df(i+1) | d | d | d/2 | d/6 | d/24 |
| ef(i+2) | e | 2e | 4e/2 | 8e/6 | 16e/24 |
| Evaluation for 2nd order derivative | 0 | 0 | 1 | 0 | 0 |
With the help of the taylor's table we can find out the values of the coefficients by forming the equations,
1).a+b+c+d+e=0
2).−2a−b+d+2e=0
3).4a2+b2+d2+4e2=1
4).−8a6−b6+d6+8e6=0
5).16a24+b24+d24+16e24=0
On solving the above equations we will get the values for coeffiecients and these coefficients value will then be put in equation 1 and hence the second order derivative for the fourth order approximation of the function for central differencing is evaluated.
Skewed right-sided difference:
In this case we are going to follow the same as procedure as we did in central differencing.
The number of nodes required,
N=P+Q
P = Order of the derivative.
Q = Order of Approximation.
For fourth order approximation of the second order derivative , the number of nodes required to derive skewed right-sided difference is,
N = 2 + 4 = 6.
The hypothesis of the second order derivative is expressed as,
∇x2f''(x)=af(i)+bf(i+1)+cf(i+2)+df(i+3)+ef(i+4)+gf(i+5)...........(2) `
Now evaluating each term of the hypothesis using taylor series,
af(i)=af(i)
bf(i+1)=b[f(i)+∇x1!f'(i)+(∇x)22!f''(i)+(∇x)33!f'''(i)+(∇x)44!−.........]
cf(i+2)=c[f(i)+2∇x1!f'(i)+(2∇x)22!f''(i)+(2∇x)33!f'''(i)+(2∇x)44!−.........]
df(i+3)=d[f(i)+3∇x1!f'(i)+(3∇x)22!f''(i)+(3∇x)33!f'''(i)+(3∇x)44!−.........]
ef(i+4)=e[f(i)+4∇x1!f'(i)+(4∇x)22!f''(i)+(4∇x)33!f'''(i)+(4∇x)44!−.........]
gf(i+5)=g[f(i)+5∇x1!f'(i)+(5∇x)22!f''(i)+(5∇x)33!f'''(i)+(5∇x)44!−.........]
Generating Taylor's Table,
| ∇x2∂2f∂x2 | f(i) | ∇xf'(i) | ∇x2f''(i) | ∇x3f'''(i) | ∇x4f''''(x) | ∇x5f'''''(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 |
| gf(i+5) | g | 5g | 25g/2 | 125g/6 | 625g/24 | 3125g/120 |
| Evaluation for 2nd order derivative | 0 | 0 | 1 | 0 | 0 | 0 |
With the help of the taylor's table we can find out the values of the coefficients by forming the equations,
1).a+b+c+d+e+g=0
2).b+2c+3d+4e+5g=0
3).b2+4c2+9d2+16e2+25g2=1
4).b6+8c6+27d6+64e6+125g6=0
5).b24+16c24+81d24+256e24+625g24=0
6).b120+32c120+243d120+1024e120+3125g120=0
On solving the above equations we will get the values for coeffiecients and these coefficients value will then be put in equation 2 and hence the second order derivative for the fourth order approximation of the function for right-sided differencing is evaluated.
Skewed left-sided difference:
In this case we are going to follow the same as procedure as we did in right - sided differencing.
The number of nodes required,
N=P+Q
P = Order of the derivative.
Q = Order of Approximation.
For fourth order approximation of the second order derivative , the number of nodes required to derive skewed right-sided difference is,
N = 2 + 4 = 6.
The hypothesis of the second order derivative is expressed as,
∇x2f''(x)=af(i−5)+bf(i−4)+cf(i−3)+df(i−2)+ef(i−1)+gf(i)...........(3)
Now evaluating each term of the hypothesis using taylor series,
af(i−5)=a[f(i)−5∇x1!f'(i)+(5∇x)22!f''(i)−(5∇x)33!f'''(i)+(5∇x)44!−.........]
bf(i−4)=b[f(i)−4∇x1!f'(i)+(4∇x)22!f''(i)−(4∇x)33!f'''(i)+(4∇x)44!−.........]
cf(i−3)=c[f(i)−3∇x1!f'(i)+(3∇x)22!f''(i)−(3∇x)33!f'''(i)+(3∇x)44!−.........]
df(i−2)=d[f(i)−2∇x1!f'(i)+(2∇x)22!f''(i)−(2∇x)33!f'''(i)+(2∇x)44!−.........]
ef(i−1)=e[f(i)−∇x1!f'(i)+(∇x)22!f''(i)−(∇x)33!f'''(i)+(∇x)44!−.........]
gf(i)=gf(i)
Generating Taylor's Table,
| ∇x2∂2f∂x2 | f(i) | ∇xf'(i) | ∇x2f''(i) | ∇x3f'''(i) | ∇x4f''''(x) | ∇x5f'''''(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 |
| gf(i) | g | 0 | 0 | 0 | 0 | 0 |
| Evaluation for 2nd order derivative | 0 | 0 | 1 | 0 | 0 | 0 |
With the help of the taylor's table we can find out the values of the coefficients by forming the equations,
1).a+b+c+d+e+g=0
2).−5a−4b−3c−2d−e=0
3).25a2+16b2+9c2+4d2+e2=1
4).−125a6+−64b6+−27c6+−8d6+−e6=0
5).625a24+256b24+81c24+16d24+e24=0
6).−3125a120+−1024b120+−243c120+−32d120+−e120=0
On solving the above equations we will get the values for coeffiecients and these coefficients value will then be put in equation 3 and hence the second order derivative for the fourth order approximation of the function for left-sided differencing is evaluated.
Now that we have derived all the equations for second order derivative using Central differencing, Right-sided difference and Left-sided difference schemes, we are going to evaluate it using MATLAB program and plotting the results showing the absolute errors with ranges of dx.