All Courses
All Courses
Courses by Software
Courses by Semester
Courses by Domain
Tool-focused Courses
Machine learning
POPULAR COURSES
Success Stories
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 Once this is done, we write a program in Matlab to evaluate the second order derivative of the analytical function exp(x)*cos(x) and compare it…
Jerrold C William
updated on 06 Jun 2019
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
Once this is done, we write a program in Matlab to evaluate the second order derivative of the analytical function exp(x)*cos(x) and compare it with the 3 numerical approximations that we have derived.
a. To Provide a plot that compares the absolute error between the above mentioned schemes
b. To explain how these errors compare with FDS and BDS approximations
THE CODE:
% Taylors Table Derivative
% Analytical Way
clc
clear all
close all
x=pi/3;
analytical=-2*exp(x)*sin(x);
n=10;
dx=linspace(0.01,1,10);
% Using Forward Difference Scheme
for i=1:length(dx )
forward(i)=((35*f(x))-(104*f(x+dx(i)))+(114*f(x+(2*dx(i))))-(56*f(x+(3*dx((i)))))+(11*f(x+(4*dx(i)))))/(12*(dx(i))^2);
backward(i)=((35*f(x))-(104*f(x-dx(i)))+(114*f(x-(2*dx(i))))-(56*f(x-(3*dx((i)))))+(11*f(x-(4*dx(i)))))/(12*(dx(i))^2);
cds(i)=((-30*f(x))+(16*f(x-dx(i)))+(16*f(x+(dx(i))))-(f(x+(2*dx((i)))))-(f(x-(2*dx(i)))))/(12*(dx(i))^2);
error_forward(i)=abs(forward(i)-analytical);
error_backward(i)=abs(backward(i)-analytical);
error_cds(i)=abs(cds(i)-analytical);
end
loglog(dx,error_forward,'-kd','markerfacecolor','r','markersize',7)
grid on
hold on
loglog(dx,error_backward,'-ko','markerfacecolor','b','markersize',7)
hold on
loglog(dx,error_cds,'-ks','markerfacecolor','g','markersize',7)
fprintf(' \n Forward scheme= %g',forward(n));
fprintf(' \n backward scheme = %g',backward(n));
fprintf(' \n cds scheme = %g',cds(n));
fprintf(' \n Actual derivative = %g',analytical);
fprintf(' \n Forward Error = %g',error_forward(n));
fprintf(' \n Backward Error = %g',error_backward(n));
fprintf(' \n CDS Error= %g',error_cds(n));
xlabel('step size')
ylabel('error')
legend('SKEWED RIGHT','SKEWED LEFT','CDS','location','northwest')
title('step size vs relative error');
fname={'forward','backward','cds'};
figure(2)
x=[1:3];
y=[error_forward(n) error_backward(n) error_cds(n)];
bar(x,y)
set(gca,'xTick',1:length(fname),'xTickLabel',fname);
xlabel('order')
ylabel('error')
legend('error prediction using 1 2 4 order approximation')
FUNCTION CODE:
function y=f(x);
y=exp(x)*cos(x);
end
THE RESULTS:
Forward scheme= 47.5215
backward scheme = -2.59705
cds scheme = -5.17395
Actual derivative = -4.93575
Forward Error = 52.4573
Backward Error = 2.3387
CDS Error= 0.238207
The above program calculates analytical value of the function at a user defined point (user needs to provide the input for the point where apporximation is to be calculated, max step size, min step size and the interval size between the point of consideration).
The value of x and dx is provided to three functions,i.e., central approximation, right skewed approximation and left skewed approximation. The values from these variables are considered and plotted on a graph.
The graph obtained is shown above. From the graph we can clearly understand that Central Approximation Error is less than Left Approximation Error followed by Right Approximation Error. Hence the vartiation of the error is as follows:
Central Approximation Error < Left Approximation Error < Right Approximation Error.
Thus it is prefered to used central differencing scheme to solve any given equation to obtain more accurate answers.
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...
SHELL MESHING OF AN INTERIOR PANEL SUBSTRATE FOR FINITE ELEMENT ANALYSIS
SHELL MESHING OF A INTERIOR PANEL SUBSTRATE FOR FINITE ELEMENT ANALYSIS OBJECTIVE: Structural mesh is oftained for the complex interior panel plastics of a car for finite element analysis, by extracting mid surfaces with thickness elements using manual and auto generated methods. ABSTRACT & PRE-REQUISITES:…
26 Jul 2019 05:13 AM IST
MESHING A BONNET FOR STRUCTURAL ANALYSIS USING ANSA
MESHING A BONNET FOR STRUCTURAL ANALYSIS USING ANSA OBJECTIVE: The given CAD of a car bonnet is to be meshed for structural analysis with the required mesh parameters. ABSTRACT: To work with thin-walled solids, using a midsurface shell model can reduce the degrees of freedom in your model by factors of ten…
16 Jul 2019 06:51 AM IST
SURFACE WRAP OF AN ENGINE ASSEMBLY
SURFACE WRAP OF AN ENGINE ASSEMBLY OBJECTIVE: To extract a surface wrap of a CAD model, thereby eliminating the control volumes from which the 3D structure of meshed elements have been obtained. PROJECT WALKTHROUGH: Firstly, the topology of the CAD has to be taken care of, in order to eliminate any possibility of…
28 Jun 2019 08:28 AM IST
SURFACE MESHING OF A BMW M6
OBJECTIVE: The given CAD model of BMW M6 is to be eliminated from it\'s topological errors & render surface mesh, expel the errors occuring during the wholesome process. PREREQUISITES: CAD CLEAN UP & ITS USES: Meshing for FEA and CFD is simple: Just start with your CAD model, break it up into a bunch of small pieces,…
06 Jun 2019 11:58 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.