All Courses
All Courses
Courses by Software
Courses by Semester
Courses by Domain
Tool-focused Courses
Machine learning
POPULAR COURSES
Success Stories
FUNCTION OF DIFFERENT SCHEME 1) CENTRAL DIFFERENCE SCHEME The function is to find analytical derivative of the exp(x)*cos(x) of second order and compare it with central method to compute the error. In the central difference method the values are taken from both the sides of the grid points & used where both sides…
Aravind Subramanian
updated on 23 Oct 2019
FUNCTION OF DIFFERENT SCHEME
1) CENTRAL DIFFERENCE SCHEME
The function is to find analytical derivative of the exp(x)*cos(x) of second order and compare it with central method to compute the error. In the central difference method the values are taken from both the sides of the grid points & used where both sides value are available.
% Central difference method
function error_c = central_diff(x,dx)
% second derivative of function exp(x)*cosx using analytical method
analytical_derivative = -2*exp(x)*sin(x);
% Numerical method using central method
central_method = ((-2.5*exp(x)*cos(x))+(1.334*exp(x-dx)*cos(x-dx))-(0.0833*exp(x-(2*dx))*cos(x-(2*dx)))+(1.334*exp(x+dx)*cos(x+dx))-(0.0833*exp(x+(2*dx))*cos(x+(2*dx))))/(dx^2);
% truncation error
error_c = abs(central_method-analytical_derivative );
end
2) SKEWED LEFT DIFFERENCE
The function is to find analytical derivative of the exp(x)*cos(x) of second order and compare it with skewed left difference to compute the error. In this method all the values are taken from the left side of the grid points which are mainly used temperature distribution problem.
% Skewed left difference
function error_l = skewed_left_diff(x,dx)
% second derivative of function exp(x)*cosx using analytical method
analytical_derivative = -2*exp(x)*sin(x);
% Numerical method using skewed left method
skewed_left_method = ((3.75*(exp(x).*(cos(x))))-(12.833*(exp(x-dx).*(cos(x-dx))))+(17.833*(exp(x-(2*dx)).*(cos(x-(2*dx)))))-(13*(exp(x-(3*dx)).*(cos(x-(3*dx)))))+(5.0833*(exp(x-(4*dx)).*(cos(x-(4*dx)))))-(0.833*(exp(x-(5*dx)).*(cos(x-(5*dx))))))./(dx.^2)
% truncation error
error_l = abs(skewed_left_method-analytical_derivative )
end
3) SKEWED RIGHT DIFFERENCE
The function is to find analytical derivative of the exp(x)*cos(x) of second order and compare it with skewed right difference to compute the error. This method is same as the left skewed difference just the values of the frid points are taken from the right side.
% Skewed right difference
function error_r = skewed_right_diff(x,dx)
% second derivative of function exp(x)*cosx using analytical method
analytical_derivative = -2*exp(x)*sin(x);
% Numerical method using skewed right method
skewed_right_method = ((3.75*(exp(x).*cos(x)))-12.833*(exp(x+dx).*cos(x+dx))+17.833*(exp(x+2*dx).*cos(x+2*dx))-13*(exp(x+3*dx).*cos(x+3*dx))+5.0833*(exp(x+4*dx).*cos(x+4*dx))-0.833*(exp(x+5*dx).*cos(x+5*dx)))./(dx.^2)
% truncation error
error_r = abs(skewed_right_method-analytical_derivative )
end
4) FORWARD DIFFERENCE SCHEME
The forward difference of first order is compute with the analytical derivative. It is first order scheme so the error is more when compared to the other scheme.
% forward difference method
function error_f = forward_diff_method(x,dx)
% second derivative of function exp(x)*cosx using analytical method
analytical_derivative = -2*exp(x)*sin(x);
% Numerical method using FDS
forward_method = (exp(x+dx)*cos(x+dx) - exp(x)*cos(x))./dx;
% Truncation error
error_f = abs(forward_method - analytical_derivative)
end
5) BACKWARD DIFFERENCE SCHEME
The backward difference of first order is compute with the analytical derivative
% Backward difference method
function error_b = backward_diff_method(x,dx)
% second derivative of function exp(x)*cosx using analytical method
analytical_derivative = -2*exp(x)*sin(x)
% Numerical method using BDS
backward_method = (exp(x)*cos(x) - exp(x-dx)*cos(x-dx) )./dx;
% Truncation error
error_b = abs(backward_method - analytical_derivative)
end
MAIN PROGRAM
The Taylor series is used the compute the coefficient of the Left, right skewed difference and also for the central difference method.
The linsolve command is used to solve the matrix and find the coefficient, then the coeff are substituted in the numerical method and difference in the analytical and numerical method is found.
First the plot of the Left,Right and central difference (trunciation error vs dx) and required axis and legends are provided.
clear all
close all
clc
% program to compare analytical and numerical method and plot the difference
% value of x
x = pi/3;
% to create 20 interval between pi/4 to pi/4000
dx = linspace(pi/4,pi/4000,20);
% The for loop is used the find value of each dx value
for i = 1:length(dx)
% the call of the predefined functions
skewed_right_error(i) = skewed_right_diff(x,dx(i));
skewed_left_error(i) = skewed_left_diff(x,dx(i));
central_diff_error(i) = central_diff(x,dx(i));
forward_diff_error(i) = forward_diff_method(x,dx(i));
backward_diff_error(i) = backward_diff_method(x,dx(i));
end
% The plot of error against dx
figure(1)
loglog(dx,skewed_right_error,\'*\')
hold on
loglog(dx,skewed_left_error,\'--r\')
hold on
loglog(dx,central_diff_error,\'color\',\'b\')
xlabel(\'dx\')
ylabel(\'truncation error\')
legend(\'right skewed scheme\',\'left skewed scheme\',\'central scheme\');
% The plot of error against dx
figure(2)
loglog(dx,skewed_right_error,\'*\')
hold on
loglog(dx,skewed_left_error,\'--r\')
hold on
loglog(dx,central_diff_error,\'color\',\'b\')
hold on
loglog(dx,forward_diff_error,\'color\',\'g\')
hold on
loglog(dx,backward_diff_error,\'color\',\'r\')
legend(\'right skewed scheme\',\'left skewed scheme\',\'central scheme\',\'FDS\',\'BDS\')
PLOT 1:
The three schemes are plotted to each value of dx, as we increase the step size the error values are decreasing in all three difference schemes.
The slope of the three scheme are almost a constant and decreases with increase in the dx value.
From the plot it is clear that the error in the central scheme is more when compared to the other two scheme this clearly shows that the no of terms used for the calculation increases the error value decreases.
The Skewed left scheme and Skewed right scheme uses \"p+q\"(p(order of equation)=2,q(accuracy required)=4) i.e. 6 terms whereas central difference scheme uses \"p+q-1\" (p(order of equation)=2,q(accuracy required)=4) i.e. 5 terms and hence excessive error is observed in central difference scheme which consider lower known data points near the point of consideration.
PLOT 2:
The figure above shows comparison of forward and backward schemes with Central difference,Skewed right sided difference and Skewed left sided difference scheme
The plot 2 has less significant it used to show that the error is more when the no of terms used is less, this is clearly depicted by the straight line graph the FDS & BDS and value of the error doesnt vary with dx, hence higher error is observed in forward and backward schemes due lesser number of data points are used for calculation when compared to other schemes.
IMPORTANCE OF SKEWED SCHEME OVER CENTRAL DIFFERENCE SCHEME
Skewed schemes utilize data from either left or right data points from the point of consideration,whereas central difference scheme us data from both left and right from the point of consideration.Apparently skewed schemes can be used when direction of flow of a particular entity is known i.e. for example if heat flows over plate from left to right and Skewed right sided scheme is used the solution obtain would contain higher accuracy when compared to CDS. If you want to compute single or higher order derivative at corner node CDS system cannot be used.
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 11 - Louver/Grille characterization
Aim The objective of the project is to simulate a hexa grille placed at the center of the channel for a streamline flow and do a parametric optiization of the design. Task Define a parameter to optimize the design. Define trials. Define primary and compound functions that you want to report. Calculate parametric solutions.…
20 Sep 2021 12:41 PM IST
Week 12 - Final Project - Modelling and Analysis of a Datacenter
AIM The objective of the project is to create a data center model using macros in the Icepak. The main parts of the data center are Computer room air conditioning (CRAC), server cabinets, power distribution units and perforated tiles. Analyze the flow distribution and behaviour of temperature in the server stacks. Problem…
20 Sep 2021 12:41 PM IST
Week 10 - MRF project
Aim The objective of the project is to create a MRF model by importing the model to Ansys Icepak and setup the physics & solve the thermal model. Moving Reference Frame The Moving reference frame approach is a steady state method used in CFD to model problems with rotating parts. The MRF is a moving/sliding mesh…
24 Aug 2021 05:23 PM IST
Week 9 - PCB Thermal Simulation
PCB Board A printed circuit board (PCB) mechanically supports and electrically connects electronic components using conductive tracks, pads and other features etched from one or more sheet layers of copper laminated onto and/or between sheet layers of a non conductive substrate. Components are generally…
19 Jul 2021 11:56 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.