All Courses
All Courses
Courses by Software
Courses by Semester
Courses by Domain
Tool-focused Courses
Machine learning
POPULAR COURSES
Success Stories
Aim: To derive 4th order approximations of second order derivative for central difference, right skewed and left skewed schemes and write a matlab program to compare error between them Method The code for comparison of error between different schemes is shown below clc clear all close all dx=linspace(1/40,1/20,25);…
C Ajay Sekar
updated on 26 Jan 2020
Aim: To derive 4th order approximations of second order derivative for central difference, right skewed and left skewed schemes and write a matlab program to compare error between them
Method
The code for comparison of error between different schemes is shown below
clc
clear all
close all
dx=linspace(1/40,1/20,25);
x=(pi/40);
analytical_function=exp(x)*cos(x);
for i=1:length(dx)
CDS_approx(i)=(-0.0834*(-2*exp(x-2*dx(i))*sin(x-2*dx(i)))+1.3337*(-2*exp(x-dx(i))*sin(x-dx(i)))-2.5005*(-2*exp(x)*sin(x))+1.3337*(-2*exp(x+dx(i))*sin(x+dx(i)))-0.0834*(-2*exp(x+2*dx(i))*sin(x+2*dx(i))))/(dx(i)^2);
second_order_derivative(i)=-2*exp(x)*sin(x);
error_CDS(i)=abs(second_order_derivative(i)-CDS_approx(i));
FDS_approx(i)=(2.9280*(-2*exp(x)*sin(x))-8.7103*(-2*exp(x+dx(i))*sin(x+dx(i)))+9.5624*((-2*exp(x+2*dx(i))*sin(x+2*dx(i))))-4.7063*(-2*exp(x+3*dx(i))*sin(x+3*dx(i)))+0.9260*(-2*exp(x+4*dx(i))*sin(x+4*dx(i))))/(dx(i)^2);
error_FDS(i)=abs(second_order_derivative(i)-FDS_approx(i));
BDS_approx(i)=(2.9336*(-2*exp(x)*sin(x))-8.7327*(-2*exp(x-dx(i))*sin(x-dx(i)))+9.5961*((-2*exp(x-2*dx(i))*sin(x-2*dx(i))))-4.7287*(-2*exp(x-3*dx(i))*sin(x-3*dx(i)))+0.9317*(-2*exp(x-4*dx(i))*sin(x-4*dx(i))))/(dx(i)^2);
error_BDS(i)=abs(second_order_derivative(i)-BDS_approx(i));
end
subplot(2,2,1)
plot(dx,error_CDS,\'k\')
xlabel(\'dx values\')
ylabel(\'Error values CDS\')
title(\'CDS Error values Vs dx\')
subplot(2,2,2)
plot(dx,error_FDS,\'r\')
xlabel(\'dx values\')
ylabel(\'Error values FDS\')
title(\'FDS Error values Vs dx\')
subplot(2,2,3)
plot(dx,error_BDS,\'g\')
xlabel(\'dx values\')
ylabel(\'Error values BDS\')
title(\'BDS Error values Vs dx\')
Derivation:
If the information used in forming the finite difference equation comes from the left of
grid point then it is called backward differencing. In such differencing no information
from the right side of the grid is used. (i.e. i,i-1). In the above fig. Dashed line represent
Backward differencing.If the information used in forming the finite difference equation come from the right sideof the grid point, Then it is called forward differencing. In such differencing no information from the left side of the grid is used. (i.e. i,i+1). In the above fig. Dotted line
represent Forward differencing.If the information is used in forming the finite difference equation come from both left and right side of the grid, that it is called Central differencing. (i.e. i-1,i,i+1). In the above fig. Continoues line represent Central differencing.
The above equation is solved using wolfram alpha to get values of coefficients a,b,c d and e which is given as follows
a=-0.0834
b=1.337
c=-2.5005
d=1.337
e=0.0834
The above equation is solved using wolfram alpha to get values of coefficients a,b,c d and e which is given as follows
a=2.9280
b=-8.7103
c=9.5624
d=-4.7063
e=0.9260
.
The above equation is solved using wolfram alpha to get values of coefficients a,b,c d and e which is given as follows
a=2.9336
b=-8.7327
c=9.5961
d=-4.7287
e=0.9317
Results
The image below shows comparison between different schemes
Since the CDS (central difference scheme) is of second order, while backward and forward differencing schemes are of first order, as exptected, the CDS is more accurate as compared to other two schemes
Need for right hand skewed and left hand skewed schemes
The disadvantage with CDS is that it requires information both both sides of node i.e one from left hand side and other from right hand side. This may not always available in all applications . In such cases, backward or forward differencing schemes can be used which take information from backward or forward nodal points respectively. Moreover, the skewd difference schemes can be used to approximate functions with steep derivatives and hence will limit the function from blowing up .For CDS scheme, there are two errors - discretization error and floating point error both of which should balance each other for CDS to be accurate . This is not the case with skewed schemes
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 and derivation of fourth order approximations of second order derivative using taylor table and matlab
Aim: To derive 4th order approximations of second order derivative for central difference, right skewed and left skewed schemes and write a matlab program to compare error between them Method The code for comparison of error between different schemes is shown below clc clear all close all dx=linspace(1/40,1/20,25);…
26 Jan 2020 08:03 PM IST
Simulation of fluid flow through pipe using openfoam for different wedge angles
Objective To simulate fluid flow through pipeusing open foam for differnt wedge angles and compare results between them Method For simulation, instead of the complete cylinder a right circular cylindrical sector/wedgeis considered as the computational domain. This is done to avoid unnecessarycomputations by…
26 Jan 2020 07:28 PM IST
Simulation of fluid flow through pipe using open foam
Objective To simulate fluid flow thorugh pipe using open foam solver for incompressible flows (icofoam) and to write a program in matlab to genetrate mesh file required for solving fluid flow in pipe Method: From Hagen poiseuille pressure drop equation we can determine the decrease in thepressure per unit…
26 Jan 2020 06:52 PM IST
FVM literature review
The finite volume method (FVM) is a method for representing and evaluating partialdiffrential equation in the form of algebraic equations. This method is apply for over theentire volume & properties are assumed to be concentrated at geometric centre of thevolume concerned. Actually finite volume method there is use…
26 Jan 2020 05:59 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.