All Courses
All Courses
Courses by Software
Courses by Semester
Courses by Domain
Tool-focused Courses
Machine learning
POPULAR COURSES
Success Stories
Objective:- To compare truncation error values between Central difference scheme, Skewed right-sided difference scheme & Skewed left-sided difference scheme for 4th order approximations of the second-order derivative. Theory:- A Taylor series is a series expansion of a function about a point.…
Smitesh Badnapurkar
updated on 24 Dec 2020
Objective:- To compare truncation error values between Central difference scheme, Skewed right-sided difference scheme & Skewed left-sided difference scheme for 4th order approximations of the second-order derivative.
Theory:- A Taylor series is a series expansion of a function about a point. Taylors series for a function f(x) at point about a point x=a can be given as-
f(x)=f(a)+f′(a)(x-a)+f′′(a)(x-a)22!+f′′′(a)(x-a)33!+......+fn′(a)(x-a)nn!....
1. Central differencing scheme:- for this type of scheme number of nodes can be calculated by following formula.
Number of nodes = p + q - 1
Where, p = order of derivative = 2
q = order of approximation = 4.
∴ Number of nodes = 2+4-1 = 5
Δx2d2udx2=af(i-2)+bf′(i-1)+cf′′(i)+df′′′(i+1)+efiv(i+2)
Lets prepare Taylors table for above scheme.
f(i) | (Δx).f′(i) | (Δx2).f′′(i) | (Δx3).f′′′(i) | (Δx4).fiv(i) | (Δx5).fv(i) | (Δx6).fvi(i) | |
a.f(i-2) | a | -2a | 2a | -(43)a | (23)a | -(32120)a | (64720)a |
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 | (43)e | (23)e | (32120)e | (64720)e |
0 | 0 | 1 | 0 | 0 | - | - | |
Table 1: Taylors table for central differencing |
Hence we get 5 equations from above table,
a+b+c+d+e=0
-2a-b+0c+d+2e=0
2a-0.5b+0c+0.5d+2e=1
-(43)a-(16)b+0c+(16)d+(43)e=0
(23)a+(124)b+0c+(124)d+(23)e=0
Lets solve above equation using the matrix inversion method and calculate values for coefficients 'a', 'b', 'c', 'd' & 'e' by creating MATLAB code.
clear all
close all
clc
%Objective is to find unknown coefficient for central differencing scheme
%Creating matrix A of coefficients
A = [1 1 1 1 1; -2 -1 0 1 2; 2 0.5 0 0.5 2; -4/3 -1/6 0 1/6 4/3; 2/3 1/24 0 1/24 2/3]
%Matrix B
B = [0; 0; 1; 0; 0]
%Matrix X consist unknown coefficients
%Matrix X = [a; b; c; d; e]
%Calculate Matrix X by X = AB
X = AB
Hence, we get a=-0.083333; b = 1.3333; c = -2.5; d = 1.3333; e = -0.083333
∴ a = e & b = d
Δx2d2udx2=af(i-2)-bf′(i-1)+cf′′(i)+dfiv(i+1)+efv(i+2)
∴ Δx2d2udx2= (a+b+c+d+e).f(i)+(-2a-b+0c+d+2e)(f′(i)Δx)+(2a+0.5b+0c+0.5d+2e)(f′′(i)Δx2)+(-(43)a-(16)b+0c+(16)d+(43)e)(f′′′(i)Δx3)+((23)a+(124)b+0c+(124)d+(23)e)(f′iv(i)Δx4)+(-(32120)a-(1120)b+0c+(1120)d+(32120)e)(f′v(i)Δx5)+((64720)a+(1720)b+0c+(1720)d+(64720)e)(f′vi(i)Δx6)+.....
For above equation as
a+b+c+d+e=0
-2a-b+0c+d+2e=0
-(43)a-(16)b+0c+(16)d+(43)e=0
(23)a+(124)b+0c+(124)d+(23)e=0
and by putting values of 'a', 'b', 'c', 'd' & 'e' we get (-(32120)a-(1120)b+0c+(1120)d+(32120)e)=0
∴ Δx2d2udx2= (2a+0.5b+0c+0.5d+2e)(f′′(i)Δx2)+((64720)a+(1720)b+0c+(1720)d+(64720)e)(f′vi(i)Δx6)+.....
Now divide above equation by Δx2 on both side
Hence we get,
d2udx2= (2a+0.5b+0c+0.5d+2e)f′′(i)+((64720)a+(1720)b+0c+(1720)d+(64720)e)(f′vi(i)Δx4)+.....
Which contains Δx4 i.e. 4th order and higher (above 4) order terms.
2. Skewed right sided differencing scheme:- for this type of scheme number of nodes can be calculated by following formula.
Number of nodes = p + q
Where, p = order of derivative = 2
q = order of approximation = 4.
∴ Number of nodes = 2+4 = 6
Δx2d2udx2=af(i)+bf′(i+1)+cf′′(i+2)+df′′′(i+3)+efiv(i+4)+gfv(i+5)
Lets prepare Taylors table for above scheme.
f(i) | (Δx).f′(i) | (Δx2).f′′(i) | (Δx3).f′′′(i) | (Δx4).fiv(i) | (Δx5).fv(i) | (Δx6).fvi(i) | |
a.f(i) | a | 0 | 0 | 0 | 0 | 0 | 0 |
b.f(i+1) | b | b | b2 | b6 | b24 | b120 | b720 |
c.f(i+2) | c | 2c | 2c | (43)c | (23)c | (32120)c | (64720)c |
d.f(i+3) | d | 3d | (92)d | (276)d | (8124)d | (243120)d | (729720)d |
e.f(i+4) | e | 4e | 8e | (646)e | (25624)e | (1024120)e | (4096720)e |
g.f(i+5) | g | 5g | (252)g | (1256)g | (62524)g | (3125120)g | (15625720)g |
0 | 0 | 1 | 0 | 0 | 0 | - | |
Table 2: Taylors table for skewed right sided differencing |
Hence we get 6 equations from above table,
a+b+c+d+e+g=0
0a+b+2c+3d+4e+5g=0
0a+0.5b+2c+(92)d+8e+(252)g=1
0a+(16)b+(43)c+(276)d+(646)e+(1256)g=0
0a+(124)b+(23)c+(8124)d+(25624)e+(62524)g=0
0a+(1120)b+(32120)c+(243120)d+(1024120)e+(3125120)g=0
Lets solve above equation using the matrix inversion method and calculate values for coefficients 'a', 'b', 'c', 'd', 'e' & 'g' by creating MATLAB code.
clear all
close all
clc
%Objective is to find unknown coefficient for skewed right side differencing scheme
%Creating matrix A of coefficients
A = [1 1 1 1 1 1; 0 1 2 3 4 5; 0 0.5 2 9/2 8 25/2; 0 1/6 4/3 27/6 64/6 125/6; 0 1/24 2/3 81/24 256/24 625/24; 0 1/120 32/120 243/120 1024/120 3125/120]
%Matrix B
B = [0; 0; 1; 0; 0; 0]
%Matrix Y consist unknown coefficients
%Matrix Y = [a; b; c; d; e; g]
%Calculate Matrix Y by Y = AB
Y = AB
%for calulating coefficient of(Deltax^6). f^(vi)(i)
z=(Y(1)*0)+(Y(2)*(1/720))+(Y(3)*(64/720))+(Y(4)*(729/720))+(Y(5)*(4096/720))+(Y(6)*(15625/720))
Hence, we get a = 3.75; b = -12.833; c = 17.833; d = -13; e = 5.0833; g = -0.83333
Δx2d2udx2=af(i)-bf′(i+1)+cf′′(i+2)+df′′′(i+3)+efiv(i+4)+gfv(i+5)
∴ Δx2d2udx2= (a+b+c+d+e+g).f(i)+(0a+b+2c+3d+4e+5g)(f′(i)Δx)+(0a+0.5b+2c+(92)d+8e+(252)g)(f′′(i)Δx2)+(0a+(16)b+(43)c+(276)d+(646)e+(1256)g)(f′′′(i)Δx3)+(0a+(124)b+(23)c+(8124)d+(25624)e+(62524)g)(f′iv(i)Δx4)+(0a+(1120)b+(32120)c+(243120)d+(1024120)e+(3125120)g)(f′v(i)Δx5)+(0a+(1720)b+(64720)c+(729720)d+(4096720)e+(15625720)g)(fvi(i)Δx6)+....
For above equation as
a+b+c+d+e+g=0
0a+b+2c+3d+4e+5g=0
0a+0.5b+2c+(92)d+8e+(252)g=1
0a+(16)b+(43)c+(276)d+(646)e+(1256)g=0
0a+(124)b+(23)c+(8124)d+(25624)e+(62524)g=0
0a+(1120)b+(32120)c+(243120)d+(1024120)e+(3125120)g=0
and by putting values of 'a', 'b', 'c', 'd', 'e' & 'g' we get (0a+(1720)b+(64720)c+(729720)d+(4096720)e+(15625720)g)=-0.7611 which is not equal to zero.
∴ Δx2d2udx2= (0a+0.5b+2c+(92)d+8e+(252)g)(f′′(i)Δx2)+(0a+(1720)b+(64720)c+(729720)d+(4096720)e+(15625720)g)(f′vi(i)Δx6)+.....
Now divide above equation by Δx2 on both side
Hence we get,
d2udx2= (0a+0.5b+2c+(92)d+8e+(252)g)f′′(i)+(0a+(1720)b+(64720)c+(729720)d+(4096720)e+(15625720)g)(f′vi(i)Δx4)+.....
Which contains Δx4 i.e. 4th order and higher (above 4) order terms.
3. Skewed left sided differencing scheme:- for this type of scheme number of nodes can be calculated by following formula.
Number of nodes = p + q
Where, p = order of derivative = 2
q = order of approximation = 4.
∴ Number of nodes = 2+4 = 6
Δx2d2udx2=af(i)+bf′(i-1)+cf′′(i-2)+df′′′(i-3)+efiv(i-4)+gfv(i-5)
Lets prepare Taylors table for above scheme.
f(i) | (Δx).f′(i) | (Δx2).f′′(i) | (Δx3).f′′′(i) | (Δx4).fiv(i) | (Δx5).fv(i) | (Δx6).fvi(i) | |
a.f(i) | a | 0 | 0 | 0 | 0 | 0 | 0 |
b.f(i-1) | b | -b | b2 | -b6 | b24 | -b120 | b720 |
c.f(i-2) | c | -2c | 2c | -(43)c | (23)c | -(32120)c | (64720)c |
d.f(i-3) | d | -3d | (92)d | -(276)d | (8124)d | -(243120)d | (729720)d |
e.f(i-4) | e | -4e | 8e | -(646)e | (25624)e | -(1024120)e | (4096720)e |
g.f(i-5) | g | -5g | (252)g | -(1256)g | (62524)g | -(3125120)g | (15625720)g |
0 | 0 | 1 | 0 | 0 | 0 | - | |
Table 3: Taylors table for skewed left sided differencing |
Hence we get 6 equations from above table,
a+b+c+d+e+g=0
0a-b-2c-3d-4e-5g=0
0a+0.5b+2c+(92)d+8e+(252)g=1
0a-(16)b-(43)c-(276)d-(646)e-(1256)g=0
0a+(124)b+(23)c+(8124)d+(25624)e+(62524)g=0
0a-(1120)b-(32120)c-(243120)d-(1024120)e-(3125120)g=0
Lets solve above equation using the matrix inversion method and calculate values for coefficients 'a', 'b', 'c', 'd', 'e' & 'g' by creating MATLAB code.
clear all
close all
clc
%Objective is to find unknown coefficient for skewed left side differencing scheme
%Creating matrix A of coefficients
A = [1 1 1 1 1 1; 0 -1 -2 -3 -4 -5; 0 0.5 2 9/2 8 25/2; 0 -1/6 -4/3 -27/6 -64/6 -125/6; 0 1/24 2/3 81/24 256/24 625/24; 0 -1/120 -32/120 -243/120 -1024/120 -3125/120]
%Matrix B
B = [0; 0; 1; 0; 0; 0]
%Matrix Z consist unknown coefficients
%Matrix Z = [a; b; c; d; e; g]
%Calculate Matrix Z by Z = AB
Z = AB
%for calulating coefficient of(Deltax^6). f^(vi)(i)
z=(Z(1)*0)+(Z(2)*(1/720))+(Z(3)*(64/720))+(Z(4)*(729/720))+(Z(5)*(4096/720))+(Z(6)*(15625/720))
Hence, we get a = 3.75; b = -12.833; c = 17.833; d = -13; e = 5.0833; g = -0.83333
Δx2d2udx2=af(i)-bf′(i+1)+cf′′(i+2)+df′′′(i+3)+efiv(i+4)+gfv(i+5)
∴ Δx2d2udx2= (a+b+c+d+e+g).f(i)-(0a+b+2c+3d+4e+5g)(f′(i)Δx)+(0a+0.5b+2c+(92)d+8e+(252)g)(f′′(i)Δx2)-(0a+(16)b+(43)c+(276)d+(646)e+(1256)g)(f′′′(i)Δx3)+(0a+(124)b+(23)c+(8124)d+(25624)e+(62524)g)(f′iv(i)Δx4)-(0a+(1120)b+(32120)c+(243120)d+(1024120)e+(3125120)g)(f′v(i)Δx5)+(0a+(1720)b+(64720)c+(729720)d+(4096720)e+(15625720)g)(fvi(i)Δx6)-....
For above equation as
a+b+c+d+e+g=0
0a-b-2c-3d-4e-5g=0
0a+0.5b+2c+(92)d+8e+(252)g=1
0a-(16)b-(43)c-(276)d-(646)e-(1256)g=0
0a+(124)b+(23)c+(8124)d+(25624)e+(62524)g=0
0a-(1120)b-(32120)c-(243120)d-(1024120)e-(3125120)g=0
and by putting values of 'a', 'b', 'c', 'd', 'e' & 'g' we get (0a+(1720)b+(64720)c+(729720)d+(4096720)e+(15625720)g)=-0.7611 which is not equal to zero.
∴ Δx2d2udx2= (0a+0.5b+2c+(92)d+8e+(252)g)(f′′(i)Δx2)+(0a+(1720)b+(64720)c+(729720)d+(4096720)e+(15625720)g)(f′vi(i)Δx6)+.....
Now divide above equation by Δx2 on both side
Hence we get,
d2udx2= (0a+0.5b+2c+(92)d+8e+(252)g)f′′(i)+(0a+(1720)b+(64720)c+(729720)d+(4096720)e+(15625720)g)(f′vi(i)Δx4)+.....
Which contains Δx4 i.e. 4th order and higher (above 4) order terms.
MATLAB Code for Comparison of errors:-
clear all
close all
clc
%analytical function, f(x)= cos(x)*exp(x)
x=pi/3;
%hence, first order analytical derivative can be calculated as, f'(x)= (cos(x)*exp(x))- (sin(x)*exp(x))
%hence, second order analytical derivative can be calculated as, f''(x)= -2*(sin(x)*exp(x))
Analytical_derivative = -2*(sin(x)*exp(x));
%range for dx values
dx = linspace(pi/40,pi/400,25);
for i=1:length(dx);
%Central differencing scheme for second order derivative at fourth order approximation,
%formula, (a*f(x-2dx)+b*f(x-dx)+c*f(x)+d*f(x+dx)+e*f(x+2dx))/(dx)^2
%X=[a b c d e]
X = [-0.08333333333333337 1.333333333333334 -2.500000000000001 1.333333333333335 -0.0833333333333337];
central = (X(1)*cos(x-2*dx(i))*exp(x-2*dx(i)) + X(2)*cos(x-dx(i))*exp(x-dx(i)) + X(3)*cos(x)*exp(x) + X(4)*cos(x+dx(i))*exp(x+dx(i)) + X(5)*cos(x+2*dx(i))*exp(x+2*dx(i)) )/((dx(i))^2);
Central_differencing_error(i) = abs(Analytical_derivative - central);
%Right skewed differencing scheme for second order derivative at fourth order approximation,
%formula, (a*f(x)+b*f(x+dx)+c*f(x+2dx)+d*f(x+3dx)+e*f(x+4dx)+g*f(x+5dx))/(dx)^2
%Y=[a b c d e g]
Y = [3.749999999999991 -12.8333333333333 17.83333333333329 -12.99999999999998 5.083333333333328 -0.8333333333333329];
right_skewed = (Y(1)*cos(x)*exp(x) + Y(2)*cos(x+dx(i))*exp(x+dx(i)) + Y(3)*cos(x+2*dx(i))*exp(x+2*dx(i)) + Y(4)*cos(x+3*dx(i))*exp(x+3*dx(i)) + Y(5)*cos(x+4*dx(i))*exp(x+4*dx(i)) + Y(6)*cos(x+5*dx(i))*exp(x+5*dx(i)) )/((dx(i))^2);
Right_skewed_differencing_error(i) = abs(Analytical_derivative - right_skewed);
%Left skewed differencing scheme for second order derivative at fourth order approximation,
%formula, (a*f(x)+b*f(x-dx)+c*f(x-2dx)+d*f(x-3dx)+e*f(x-4dx)+g*f(x-5dx))/(dx)^2
%Z=[a b c d e g]
Z = [3.749999999999991 -12.8333333333333 17.83333333333329 -12.99999999999998 5.083333333333328 -0.8333333333333329];
left_skewed = (Z(1)*cos(x)*exp(x) + Z(2)*cos(x-dx(i))*exp(x-dx(i)) + Z(3)*cos(x-2*dx(i))*exp(x-2*dx(i)) + Z(4)*cos(x-3*dx(i))*exp(x-3*dx(i)) + Z(5)*cos(x-4*dx(i))*exp(x-4*dx(i)) + Z(6)*cos(x-5*dx(i))*exp(x-5*dx(i)) )/((dx(i))^2);
Left_skewed_differencing_error(i) = abs(Analytical_derivative - left_skewed);
endfor
figure(1);
loglog(dx,Central_differencing_error,'-d-','color','r');
hold on;
loglog(dx,Right_skewed_differencing_error,'-o-','color','b');
hold on;
loglog(dx,Left_skewed_differencing_error,'-s-','color','m');
axis([pi/450 pi/30 10^(-11) 10^(-1)]);
legend('Central differencing error','Right skewed differencing error','Left skewed differencing error');
xlabel('dx');
ylabel('Truncation error');
title('Comparison of differencing schemes');
Given data:- Function, f(x)=cos(x).ex
As per ddx(u×v)=(u′×v)+(v′×u)
Where u=cos(x) & v=ex
Hence Second order derivative, f′′(x)=-2.sin(x).ex=-4.935745353035276
As per above derived equations, we have formulae for
Central difference scheme, -0.083333â‹…f(x-2dx)+1.3333â‹…f(x-dx)-2.5â‹…f(x)+1.3333â‹…f(x+dx)-0.083333â‹…f(x+2dx)(dx)2
Right side skewed scheme, 3.75â‹…f(x)-12.833â‹…f(x+dx)+17.833â‹…f(x+2dx)-13â‹…f(x+3dx)+5.0833â‹…f(x+4dx)-0.83333â‹…f(x+5dx)(dx)2
Left side skewed scheme, 3.75â‹…f(x)-12.833â‹…f(x-dx)+17.833â‹…f(x-2dx)-13â‹…f(x-3dx)+5.0833â‹…f(x-4dx)-0.83333â‹…f(x-5dx)(dx)2
So, truncation error is calculated by takin differennce between absolute derivative value and numerical approximate value.
Above plot is 'dx values' v/s 'truncation error', where plot is generated on logarithmic scale for different values of 'dx'. From above graph it is clear that the truncation error values offered by central differencing are less than right & left skewed differencing scheme i.e. Central differencing scheme gives closed solution to true solution than skewed schemes. While right side skewed error and left side skewed errors are merely equal
Hence, Central differencing error
Advantage of skewed scheme over central differencing scheme:- As skewed schemes required data from only one end i.e. either left side or right side from the considered node, so its not complicated to use skewed scheme when direction of any property is given. But if we consider central differencing scheme we have to provide data from both side of considered node, so its bit complex to provide data from both side when flow direction of property is given. Hence for such cases skewed schemes are better and more accurate than central differencing scheme.
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...
Discretization of 3D intake manifold using GEM-3D
Aim:-> To perform discretization of intake manifold with converting it in 1D circuit model from 3D model and observing effect of discretization length on result. Theory: Discretization is the splitting of large parts into smaller sections to improve a model's accuracy. There are two ways in which a fluid…
07 Sep 2021 03:50 PM IST
Conjugate heat transfer analysis of exhaust Port
Aim:-> Conjugate heat transfer (CHT) analysis of exhaust port. Theory:- As we know heat is transferred by 3 modes i.e. Conduction, convection & radiation. Conduction:- is an exchange of energy by direct interaction between molecules of a substance containing temperature differences. Convection:- is…
20 Aug 2021 02:07 PM IST
Turbocharger Modelling using GT Power
Aim:-> Study of turbocharger and its modeling using GT Suit. Theory:- A turbocharger (technically a turbosupercharger), colloquially known as turbo, is a turbine-driven, forced induction device that increases an internal combustion engine's power output by forcing…
20 Aug 2021 08:11 AM IST
Comparison of CI and SI engine and calibration of Single cylinder CI-Engine
Aim:-> To compare SI and CI engine and perform basic calibration of single cylinder CI engine. Comparison of SI V/S CI Engine model: SI Engine CI Engine SI engine is internal combustion engine that operates on the principle of spark ignition. CI engine is internal combustion engine that operates on the principle…
20 Aug 2021 08:09 AM IST
Related Courses
Skill-Lync offers industry relevant advanced engineering courses for engineering students by partnering with industry experts.
© 2025 Skill-Lync Inc. All Rights Reserved.