All Courses
All Courses
Courses by Software
Courses by Semester
Courses by Domain
Tool-focused Courses
Machine learning
POPULAR COURSES
Success Stories
Aim: Deriving 4th order approximation of a 2nd order derivative using Taylor Table method Governing equations Central difference scheme(Symmetric scheme) Number of nodes in central schemes= p+q-1(p=order of derivative,q=order of approximation) …
Faizan Akhtar
updated on 16 Feb 2021
Aim: Deriving 4th order approximation of a 2nd order derivative using Taylor Table method
Governing equations
Central difference scheme(Symmetric scheme)
Number of nodes in central schemes= p+q-1(p=order of derivative,q=order of approximation)
=2+4-1=5=2+4−1=5
d2ydx2≈af(i-2)+bf(i-1)+cf(i)+df(i+1)+ef(i+2)d2ydx2≈af(i−2)+bf(i−1)+cf(i)+df(i+1)+ef(i+2)
f(i-2)=f(i)-2∗Δxf′(i)+f′′(i)4Δx22-f′′′(i)8Δx36+f′′′′(i)16Δx424-f′′′′′(i)32Δx5120+f′′′′′′(i)64Δx6720
Multiplying the above equation by a
a∗(f(i-2))=a∗(f(i)-2∗Δxf′(i)+f′′(i)4Δx22-f′′′(i)8Δx36+f′′′′(i)16Δx424-f′′′′′(i)32Δx5120+f′′′′′′(i)64Δx6720)
f(i-1)can be calculated by Taylor theorem
f(i-1)=f(i)-f′(i)Δx+f′′(i)Δx22-f′′′(i)Δx36+f′′′′(i)Δx424-f′′′′′(i)Δx5120+f′′′′′′(i)Δx6720
Multiplying the above equation by b
b∗(f(i-1))=b∗(f(i)-f′(i)Δx+f′′(i)Δx22-f′′′(i)Δx36+f′′′′(i)Δx424-f′′′′′(i)Δx5120+f′′′′′′(i)Δx6720)
f(i+1)can be calculated by Taylor theorem
f(i+1)=f(i)+f′(i)Δx+f′′(i)Δx22+f′′′(i)Δx36+f′′′′(i)Δx424+f′′′′′(i)Δx5120+f′′′′′′(i)Δx6720
Multiplying the above equation by d
d∗(f(i+1))=d∗(f(i)+f′(i)Δx+f′′(i)Δx22+f′′′(i)Δx36+f′′′′(i)Δx424+f′′′′′(i)Δx5120+f′′′′′′(i)Δx6720)
f(i+2)can be calculated by Taylor theorem
f(i+2)=f(i)+2∗Δxf′(i)+f′′(i)4Δx22+f′′′(i)8Δx36+f′′′′(i)16Δx424+f′′′′′(i)32Δx5120+f′′′′′′(i)64Δx6720
Multiplying the above equation by e
e∗(f(i+2))=e∗(f(i)+2∗Δxf′(i)+f′′(i)4Δx22+f′′′(i)8Δx36+f′′′′(i)16Δx424+f′′′′′(i)32Δx5120+f′′′′′′(i)64Δx6720)
Forming Taylor's table for keeping track of coefficient
Numerical Stencil | Taylor's series terms | ||||||
f(i) | Δxf′(i) | Δx2∗f′′(i) | Δx3f′′′(i) | Δx4f′′′′(i) | Δx5f′′′′′(i) | Δx6f′′′′′′(i) | |
a∗f(i-2) | a | -2a | 2a | -8a6 | 16a24 | -32a120 | 64a720 |
b∗f(i-1) | b | -b | b2 | -b6 | b24 | -b120 | b720 |
c∗f(i) | c | 0 | 0 | 0 | 0 | 0 | 0 |
d∗f(i+1) | d | d | d2 | d6 | d24 | d120 | d720 |
e∗f(i+2) | e | 2e | 2e | 8e6 | 16e24 | 32e120 | 64e720 |
Summing each and every term in the table
Σa∗f(i-2)+b∗f(i-1)+cf(i)+d∗f(i+1)+e∗f(i+2)=d2ydx2
Σa+b+c+d+e=0(As such equation under consideration is second order)
Σ-2a-b+0+d+2e=0(As such equation under consideration is second order)
Σ2a+b2+0+d2+2e=1
Σ-8a6+-b6+0+d6+8e6=0
Σ16a24+b24+0+d24+16e24=0
The values of a,b,c,d,ecan be calculated by Matlab
a=-112
b=43
c=-52
d=43
e=-112
Thus a=eandb=d
Rearranging all the terms
d2ydx2≈af(i-2)+bf(i-1)+cf(i)+df(i+1)+ef(i+2)=(a+b+c+d+e)f(i)+(-2a-b+0+d+2e)Δxf′(i)+(2a+b2+0+d2+2e)Δx2f′′(i)+(-8a6+-b6+0+d6+8e6)Δx3f′′′(i)+(16a24+b24+0+d24+16e24)Δx4f′′′′(i)+(-32a120+-b120+0+d120+32e120)Δx5f′′′′′(i)+(64a720+b720+0+d720+64e720)Δx6f′′′′′′(i)
Equating LHS and RHS
d2ydx2=-112f(i-2)+43f(i-1)+-52f(i)+43f(i+1)+-112f(i+2)=0∗f(i)+0∗f′(i)+(-2a-b+0+d+2e)Δx2f′′(i)+0∗f′′′(i)+0∗f′′′′(i)+0∗f′′′′′(i)+(somevalue)∗Δx6f′′′′′′(i)
Dividing by Δx2throughout
d2ydx2=-112f(i-2)+43f(i-1)+-52f(i)+43f(i+1)+-112f(i+2)∗1Δx2=(-2a-b+0+d+2e)∗f′′(i)+order of (Δx4)
Thus equation for the skewed right-sided difference is
d2ydx2=(-112f(i-2)+43f(i-1)+-52f(i)+43f(i+1)+-112f(i+2))∗1Δx2
Skewed right-sided difference
Solution
Number of nodes in right sided schemes= p+q (p=order of derivative,q=order of approximation)
=2+4=6
d2ydx2≈af(i)+bf(i+1)+cf(i+2)+df(i+3)+ef(i+4)+gf(i+5) `
f(i+1)can be calculated by Taylor theorem
f(i+1)=f(i)+f′(i)Δx+f′′(i)Δx22+f′′′(i)Δx36+f′′′′(i)Δx424+f′′′′′(i)Δx5120+f′′′′′′(i)Δx6720
Multiplying the above equation by b
b∗(f(i+1))=b∗(f(i)+f′(i)Δx+f′′(i)Δx22+f′′′(i)Δx36+f′′′′(i)Δx424+f′′′′′(i)Δx5120+f′′′′′′(i)Δx6720)
f(i+2)can be calculated by Taylor theorem
f(i+2)=f(i)+2∗Δxf′(i)+f′′(i)4Δx22+f′′′(i)8Δx36+f′′′′(i)16Δx424+f′′′′′(i)32Δx5120+f′′′′′′(i)64Δx6720
Multiplying the above equation by c
c∗(f(i+2))=c∗(f(i)+2∗Δxf′(i)+f′′(i)4Δx22+f′′′(i)8Δx36+f′′′′(i)16Δx424+f′′′′′(i)32Δx5120+f′′′′′′(i)64Δx6720)
f(i+3)can be calculated by Taylor theorem
f(i+3)=f(i)+f′(i)∗3Δx+f′′(i)92Δx2+f′′′(i)276Δx3+f′′′′(i)8124Δx4+f′′′′′243120Δx5+f′′′′′′(i)729720Δx6
Multiplying the above equation by d
d∗f(i+3)=d∗(f(i)+f′(i)∗3Δx+f′′(i)92Δx2+f′′′(i)276Δx3+f′′′′(i)8124Δx4+f′′′′′243120Δx5+f′′′′′′(i)729720Δx6)
f(i+4)can be calculated by Taylor theorem
f(i+4)=f(i)+f′(i)4∗Δx+f′′(i)162Δx2+f′′′(i)646Δx3+f′′′′(i)25624Δx4+f′′′′′(i)1024120Δx5+f′′′′′′(i)4096720Δx6
Multiplying the above equation by e
e∗(f(i+4))=e∗(f(i)+f′(i)4∗Δx+f′′(i)162Δx2+f′′′(i)646Δx3+f′′′′(i)25624Δx4+f′′′′′(i)1024120Δx5+f′′′′′′(i)4096720Δx6)
f(i+5)can be calculated by Taylor theorem
f(i+5)=f(i)+f′(i)∗5∗Δx+f′′(i)252Δx2+f′′′(i)1256Δx3+f′′′′(i)62524Δx4+f′′′′′(i)3125120Δx5+f′′′′′′(i)15625720Δx6
Multiplying the above equation by g
g∗(f(i+5))=g∗(f(i)+f′(i)∗5∗Δx+f′′(i)252Δx2+f′′′(i)1256Δx3+f′′′′(i)62524Δx4+f′′′′′(i)3125120Δx5+f′′′′′′(i)15625720Δx6)
Calculating Coefficients through Taylor's table.
Numerical Stencil | Taylor's series terms | |||||
f(i) | Δxf′(i) | Δx2f′′(i) | Δx3f′′′(i) | Δx4f′′′′(i) | Δx5f′′′′′(i) | |
af(i) | a | 0 | 0 | 0 | 0 | 0 |
bf(i+1) | b | b | b2 | b6 | b24 | b120 |
cf(i+2) | c | 2c | 4c2 | 8c6 | 16c24 | 32c120 |
df(i+3) | d | 3d | 9d2 | 27d6 | 81d24 | 243d120 |
ef(i+4) | e | 4e | 16e2 | 64e6 | 256e24 | 1024e120 |
gf(i+5) | g | 5g | 25g2 | 125g6 | 625g24 | 3125g120 |
Solving for a,b,c,d,e,g
Summing Taylor's series terms
Σa+b+c+d+e+g=0
Σ0+b+2c+3d+4e+5g=0
Σ0+b2+4c2+9d2+16e2+25g2=1
Σ0+b6+8c6+27d6+64e6+125g6=0
Σ0+b24+16c24+81d24+256e24+625g24=0
Σ0+b120+32c120+243d120+1024e120+3125g120=0
a=154
b=-776
c=1076
d=-13
e=6112
g=-56
Rearranging all the terms
Thus equation for the skewed right-sided difference is
d2ydx2=(154f(i)+-776f(i+1)+1076f(i+2)-13f(i+3)+6112f(i+4)+-56f(i+5))∗1Δx2
Skewed left-sided difference
Number of nodes in left sided schemes= p+q (p=order of derivative,q=order of approximation)
=2+4=6
d2ydx2≈af(i)+bf(i-1)+cf(i-2)+df(i-3)+ef(i-4)+gf(i-5) `
f(i-1)can be calculated by Taylor theorem`
f(i-1)=f(i)-f′(i)Δx+f′′(i)Δx22-f′′′(i)Δx36+f′′′′(i)Δx424-f′′′′′(i)Δx5120+f′′′′′′(i)Δx6720+..........
Multiplying the above equation by b
b∗(f(i-1))=b∗(f(i)-f′(i)Δx+f′′(i)Δx22-f′′′(i)Δx36+f′′′′(i)Δx424-f′′′′′(i)Δx5120+f′′′′′′(i)Δx6720+)
f(i-2)can be calculated by Taylor theorem
f(i-2)=f(i)-2∗Δxf′(i)+f′′(i)4Δx22-f′′′(i)8Δx36+f′′′′(i)16Δx424-f′′′′′(i)32Δx5120+f′′′′′′(i)64Δx6720+.....................
Multiplying the above equation by c
c∗(f(i-2))=c∗(f(i)-2∗Δxf′(i)+f′′(i)4Δx22-f′′′(i)8Δx36+f′′′′(i)16Δx424-f′′′′′(i)32Δx5120+f′′′′′′(i)64Δx6720+.....................)
f(i-3)can be calculated by Taylor theorem`
f(i-3)=f(i)-f′(i)∗3Δx+f′′(i)92Δx2-f′′′(i)276Δx3+f′′′′(i)8124Δx4-f′′′′′(i)243120Δx5+f′′′′′′(i)729720Δx6
Multiplying the above equation by d
d∗(f(i-3))=d∗(f(i)-f′(i)∗3Δx+f′′(i)92Δx2-f′′′(i)276Δx3+f′′′′(i)8124Δx4-f′′′′′(i)243120Δx5+f′′′′′′(i)729720Δx6)
f(i-4)can be calculated by Taylor theorem `
f(i-4)=f(i)-f′(i)4∗Δx+f′′(i)162Δx2-f′′′(i)646Δx3+f′′′′(i)25624Δx4-f′′′′′(i)1024120Δx5+f′′′′′′(i)4096720Δx6
Multiplying the above equation by e
e∗(f(i-4))=e∗(f(i)-f′(i)4∗Δx+f′′(i)162Δx2-f′′′(i)646Δx3+f′′′′(i)25624Δx4-f′′′′′(i)1024120Δx5+f′′′′′′(i)4096720Δx6)
f(i-5) can be calculated by Taylor theorem`
f(i-5)=f(i)-f′(i)∗5∗Δx+f′′(i)252Δx2-f′′′(i)1256Δx3+f′′′′(i)62524Δx4-f′′′′′(i)3125120Δx5+f′′′′′′(i)15625720Δx6
Multiplying the above equation by g
g∗(f(i-5))=g∗(f(i)-f′(i)∗5∗Δx+f′′(i)252Δx2-f′′′(i)1256Δx3+f′′′′(i)62524Δx4-f′′′′′(i)3125120Δx5+f′′′′′′(i)15625720Δx6)
Calculating Coefficients through Taylor's table.
Numerical Stencil | Taylor series table | |||||
f(i) | Δxf′(i) | Δx2f′′(i) | Δx3f′′′(i) | Δx4f′′′′(i) | Δx5f′′′′′(i) | |
af(i) | a | 0 | 0 | 0 | 0 | 0 |
bf(i-1) | b | -b | b2 | -b6 | b24 | -b120 |
cf(i-2) | c | -2c | 4c2 | -8c6 | 16c24 | -32c120 |
df(i-3) | d | -3d | 9d2 | -27d6 | 81d24 | -243d120 |
ef(i-4) | e | -4e | 16e2 | -64e6 | 256e24 | -1024e120 |
gf(i-5) | g | -5g | 25g2 | -125g6 | 625g24 | -3125g120 |
Summation of all the terms will yield
Σa+b+c+d+e+g=0
Σ0-b-2c-3d-4e-5g=0
Σ0+b2+4c2+9d2+16e2+25g2=1
Σ0+-b6+-8c6+27d6+-64e6+-125g6=0
Σ0+b24+16c24+81d24+256e24+625g24=0
Σ0+-b120+-32c120+-243d120+-1024e120+-3125g120=0
a=154
b=-776
c=1076
d=-13
e=6112
g=-56
Thus equation for the skewed left-sided difference is
d2ydx2=(154f(i)+-776f(i-1)+1076f(i-2)-13f(i-3)+6112f(i-4)+-56f(i-5))∗1Δx2
Matlab coding
Calculating central difference scheme coefficient through Matlab
>> A=[1,1,1,1,1;-2,-1,0,1,2;2,1/2,0,1/2,2;-8/6,-1/6,0,1/6,8/6;16/24,1/24,0,1/24,16/24]
A =
1.0000 1.0000 1.0000 1.0000 1.0000
-2.0000 -1.0000 0 1.0000 2.0000
2.0000 0.5000 0 0.5000 2.0000
-1.3333 -0.1667 0 0.1667 1.3333
0.6667 0.0417 0 0.0417 0.6667
>> B=[0;0;1;0;0]
B =
0
0
1
0
0
>> X=AB
X =
-0.0833
1.3333
-2.5000
1.3333
-0.0833
Calculating skewed right-sided scheme coefficient through Matlab
>> A=[1,1,1,1,1,1;0,1,2,3,4,5;0,1/2,4/2,9/2,16/2,25/2;0,1/6,8/6,27/6,64/6,125/6;0,1/24,16/24,81/24,256/24,625/24;0,1/120,32/120,243/120,1024/120,3125/120]
A =
1.0000 1.0000 1.0000 1.0000 1.0000 1.0000
0 1.0000 2.0000 3.0000 4.0000 5.0000
0 0.5000 2.0000 4.5000 8.0000 12.5000
0 0.1667 1.3333 4.5000 10.6667 20.8333
0 0.0417 0.6667 3.3750 10.6667 26.0417
0 0.0083 0.2667 2.0250 8.5333 26.0417
>> B=[0;0;1;0;0;0]
B =
0
0
1
0
0
0
>> X=AB
X =
3.7500
-12.8333
17.8333
-13.0000
5.0833
-0.8333
Note: All the coefficients have been turned in fractions for ease in the calculation.
Calculating second-order derivative of exp(x)*cos(x) and comparing it with the three schemes.
Matlab code
function error_cds=central_difference_scheme(x,dx)
Exact_derivative=-2*exp(x)*sin(x);
Numerical_derivative=((-1/12)*exp(x-2*dx)*cos(x-2*dx)+(4/3)*exp(x-dx)*cos(x-dx)+(-5/2)*exp(x)*cos(x)+(4/3)*exp(x+dx)*cos(x+dx)+(-1/12)*exp(x+2*dx)*cos(x+2*dx))/dx^2;
error_cds=abs(Numerical_derivative-Exact_derivative);
end
function error_srs=skewed_right_sided_scheme(x,dx)
Exact_derivative=-2*exp(x)*sin(x);
Numerical_derivative=((15/4)*exp(x)*cos(x)+(-77/6)*exp(x+dx)*cos(x+dx)+(107/6)*exp(x+2*dx)*cos(x+2*dx)-13*exp(x+3*dx)*cos(x+3*dx)+(61/12)*exp(x+4*dx)*cos(x+4*dx)+(-5/6)*exp(x+5*dx)*cos(x+5*dx))/dx^2;
error_srs=abs(Numerical_derivative-Exact_derivative);
end
function error_sls=skewed_left_sided_scheme(x,dx)
Exact_derivative=-2*exp(x)*sin(x);
Numerical_derivative=((15/4)*exp(x)*cos(x)+(-77/6)*exp(x-dx)*cos(x-dx)+(107/6)*exp(x-2*dx)*cos(x-2*dx)-13*exp(x-3*dx)*cos(x-3*dx)+(61/12)*exp(x-4*dx)*cos(x-4*dx)+(-5/6)*exp(x-5*dx)*cos(x-5*dx))/dx^2;
error_sls=abs(Numerical_derivative-Exact_derivative);
end
% evaluating second order derivative of the function using three schemes
clear
close all
clc
x=pi/3;
dx=linspace(pi/4000,pi/40,80);
for i=1:length(dx)
error_cds(i)=central_difference_scheme(x,dx(i));
error_srs(i)=skewed_right_sided_scheme(x,dx(i));
error_sls(i)=skewed_left_sided_scheme(x,dx(i));
end
% plotting
figure(1)
loglog(dx,error_cds,'r');
hold on
loglog(dx,error_srs,'g');
hold on
loglog(dx,error_sls,'b');
xlabel('Range of dx values')
ylabel('Error');
legend('central difference scheme','skewed right sided scheme','skewed left sided scheme');
title('Comparison of errors from different schemes');
Graph
Conclusion
The central difference scheme will give the lowest error for increasing values of dx compared to the right-sided and left-sided scheme.
The error pattern follows the trend of Central difference scheme< Skewed left-sided scheme < Skewed right-sided scheme
Although the central difference scheme gives less error compared to skewed but in some cases skewed (right and left) is more useful. For eg if an error at the boundary to be calculated then skewed schemes are applied. The central difference scheme is not applicable in this regard.
Leave a comment
Thanks for choosing to leave a comment. Please keep in mind that all the comments are moderated as per our comment policy, and your email will not be published for privacy reasons. Please leave a personal & meaningful conversation.
Other comments...
Week-4 : Basic Calibration of Single cylinder CI-Engine
Aim: Basic Calibration of Single cylinder CI-Engine Objective : Explore Tutorial No 1- CI final 1.Compare SI vs CI and list down differences (assignment no 2-SI) 2. Comments on the following parameters BSFC Exhaust Temperature A/F ratios 3.Change MFB 50 and observe impact on performance Introduction Difference…
11 Nov 2021 05:26 AM IST
Week 2 : Basic Calibration of Single cylinder SI-Engine
Aim: Basic Calibration of Single-cylinder SI-Engine Objective: 1. Run the case at 1800 rpm and list down important parameters (20 Marks) air flow rate BMEP BSFC In-cylinder pressure 2. Increase the power output at 3600 rpm by 10% (30 Marks) Introduction A spark-ignition engine (SI engine) is…
22 Oct 2021 07:11 AM IST
Week 1 : Exploring the GUI of GT-POWER
Aim: Exploring the GUI of GT-suite GT-suite can be used in a wide range of applications. There are several industries that are using GT-suite for various applications On-highway and off-highway vehicle Marine and rail Industrial machinery Aerospace Power generation Multiphysics platform GT-Suite has a versatile multiphysics…
12 Oct 2021 02:52 PM IST
Week 8: Literature review - RANS derivation and analysis
Aim: Literature review - RANS derivation and analysis Objective: Apply Reynolds decomposition to the NS equations and come up with the expression for Reynolds stress. Explain your understanding of the terms Reynolds stress What is turbulent viscosity? How is it different from molecular viscosity? Introduction…
01 Sep 2021 07:52 AM IST
Related Courses
0 Hours of Content
Skill-Lync offers industry relevant advanced engineering courses for engineering students by partnering with industry experts.
© 2025 Skill-Lync Inc. All Rights Reserved.