All Courses
All Courses
Courses by Software
Courses by Semester
Courses by Domain
Tool-focused Courses
Machine learning
POPULAR COURSES
Success Stories
1) Central Difference ∂2f∂x2 ~= afi−2+bfi−1+cfi+dfi+1+efi+2 In the central difference we solve the 2nd order derivative using taylor series method. we take (i-2, i-1, i, i+1, i+2) itterations to create a taylor table for simplifying our solution. * Write the 2nd order derivative…
Vishavjeet Singh Yadav
updated on 05 Feb 2020
1) Central Difference
∂2f∂x2 ~= afi−2+bfi−1+cfi+dfi+1+efi+2
In the central difference we solve the 2nd order derivative using taylor series method. we take (i-2, i-1, i, i+1, i+2) itterations to create a taylor table for simplifying our solution.
* Write the 2nd order derivative in tabular form:.
|
f(i) |
f ’(i) |
f ’’(i) |
f ’’’(i) |
f ’’’’(i) |
afi−2 |
a |
-2a |
(4a)/2 |
-(8a)/6 |
(16a)/24 |
bfi−1 |
b |
-b |
b/2 |
-b/6 |
b/24 |
cfi |
c |
0 |
0 |
0 |
0 |
dfi+1 |
d |
d |
d/2 |
d/6 |
(16e)/24 |
efi+2 |
e |
-2e |
(4e)/2 |
(8e)/6 |
0 |
sum 0 0 1 0 0
∑(afi−2+bfi−1+cfi+dfi+1+efi+2)
written in the form of equations and solving the matrix
a+b+c+d+e = 0
-2a -b+0+d+2e = 0
2a+b/2+0+d/2+2e =1
-4a/3 -b/6+0+d/6+4e/6 =0
2a/3+b/24+0+d/24+2e/3 = 0
Now we have five unknowns (a,b,c,d,e) and also have five equations. To find out the values of these five unknowns we write a matlab code and get the value.
simplify this table using [A][X] = [B]
a = -0.0833
b = 1.333
c = -2.500
d = 1.3333
e = -0.083
Now we have the values of all five unknowns, put these values in equation(1)
∂2u∂x2=−0.08333fi−2+1.3333fi−1−2.5fi+1.333fi+1−0.0833fi+2∂x2
we consider LHS = RHS for this problem and neglecting the higher order than (i+2) and lower than (i-2) terms. so we get a approximation.
SKEWED LEFT SIDE SCHEME
∂2f∂x2 ~= afi−5+bfi−4+cfi−3+dfi−2+efi−1)+gfi
In the skewd left side scheme we solve the 2nd order derivative using taylor series method. we take (i-5, i-4, i-3, i-2, i-1, i) itterations to create a taylor table for simplifying our solution.
* Write the 2nd order derivative in tabular form:.
|
f(i) |
f’(i) |
F’’(i) |
F’’’(i) |
F’’’’(i) |
F’’’’’(i) |
af_(i-5) |
a |
-5a |
25a/2 |
-125a/6 |
625a/24 |
-3125a/12 |
bf_(i-4) |
b |
-4b |
16b/2 |
-64b/6 |
256b/24 |
-1024b/12 |
cf_(i-3) |
c |
-3c |
9c/2 |
-27c/6 |
81c/24 |
-243c/120 |
df_(i-2) |
d |
-2d |
4d/2 |
-8d/6 |
16d/24 |
-32d/120 |
ef(i-1) |
e |
-e |
e/2 |
-1e/6 |
1e/24 |
-1e/120 |
gf(i) |
g |
0 |
0 |
0 |
0 |
0 |
sum 0 0 1 0 0 0
∑(afi−5+bfi−4+cfi−3+dfi−2+efi−1+gfi
written in the form of equations and solving the matrix
a+b+c+d+e+g = 0
-5a -4b-3c-2d-1e+0 = 0
25a/2+16b/2+9c/2+4d/2+e/2+0 =1
-125a/6-64b/6-27c/6-8d/6-1e/6+0=0
625/24a+256b/24+81/24c+16/24d+1/24e+0=0
-3125a/12-1024b/12-243c/120-32d/120-e/120+0=0
Now we have six unknowns (a,b,c,d,e,g) and also have six equations. To find out the values of these six unknowns we write a matlab code and get the value.
simplify this table using [A][X] = [B]
a = -0.8333
b = 5.0833
c = -13
d = 17.8333
e = -12.8333
g = 3.75
Now we have the values of all six unknowns, put these values in equation(1)
∂2u∂x2=−0.8333fi−5+5.0833fi−4−13fi−3+17.8333fi−2−12.8333fi−1+3.75fi∂x2
*Skewed right side scheme
∂2f∂x2 ~= afi+bfi+2+cfi+3+dfi+4+efi+5)+gfi
In the skewd left side scheme we solve the 2nd order derivative using taylor series method. we take (i, i+1, i+2, i+3, i+4, i+5) itterations to create a taylor table for simplifying our solution.
* Write the 2nd order derivative in tabular form:.
|
F(i) |
F’(i) |
F’’(i) |
F’’’(i) |
F’’’’(i) |
F’’’’’(i) |
af_(i) |
a |
0 |
0 |
0 |
0 |
0 |
bf_(i+1) |
b |
b |
b/2 |
b/6 |
b/24 |
b/120 |
cf_(i+2) |
c |
2c |
4c/2 |
8c/6 |
16c/24 |
32c/120 |
df_(i+3) |
d |
3d |
9d/2 |
27d/6 |
81d/24 |
243d/120 |
ef_(i+4) |
e |
4e |
16e/2 |
64e/6 |
256e/24 |
1024e/120 |
gf(i+5) |
g |
5g |
25g/2 |
125g/6 |
625g/24 |
3125g/120 |
sum 0 0 1 0 0 0
∑(afi+bfi+1+cfi+2+dfi+3+efi+4+gfi+5
written in the form of equations and solving the matrix
a+b+c+d+e+g = 0
0+b+2c+3d+4e+5g+= 0
0+b/2+4b/2+9b/2+16b/2+25b/2 =1
0+b/6+8c/6+27d/6+64e/6+125g/6=0
0+b/24+16c/24+81d/24+256e/24+625g/24=0
0+b/120+32c/120+243d/120+1024e/120+3125g/120=0
Now we have six unknowns (a,b,c,d,e,g) and also have six equations. To find out the values of these six unknowns we write a matlab code and get the value.
simplify this table using [A][X] = [B]
a = 3.75
b = -12.8333
c = 17.8333
d = -13
e = 5.0833
g = -0.8333
Now we have the values of all six unknowns, put these values in equation(1)
∂2u∂x2=3.75fi−12.8333fi+1+17.833fi+2−13fi+3+5.0833fi+4−0.8333fi∂x2
* main program for 2nd order derivative
clear all
close all
clc
% Define Inputs
x = pi/3;
dx = linspace(pi/40,pi/4000,50);
% Error calculation of fourth order approximation of second derivative
% Using CDE,SRSDE,SLSDE calculate the error
for i = 1:length(dx)
analytical_derivative = -(2*exp(x)*sin(x));
central_difference_error(i) = central_approximation(x,dx(i));
skewed_right_side_difference_error(i)= skewed_right_side_approximation(x,dx(i));
skewed_left_side_difference_error(i)= skewed_left_side_approximation(x,dx(i));
end
% Ploting the graph to compare the error
loglog(dx,central_difference_error,\'color\',\'r\')
hold on
loglog(dx,skewed_right_side_difference_error,\'color\',\'b\')
hold on
loglog(dx,skewed_left_side_difference_error,\'color\',\'g\')
legend(\'central difference error\',\'skewed right side difference\',\'skewed left side difference\')
xlabel(\'dx\')
ylabel(\'error\')
* Function program for 2nd order derivative for fourth-order approximation for central approximation
function solution = central_approximation(x,dx);
% Analytical function
%f(x) = exp(x)*cos(x)
% f\'\'(x) = -(2*exp(x)*sin(x));
analytical_derivative = -(2*exp(x)*sin(x));
% central_difference =(-0.0833*f(x-2*dx)+1.3333*f(x-dx)-2.5*f(x)+1.3333*f(x+dx)-0.0833*f(x+2*dx))/(dx)^2
% Fourth order approximation of second order derivative using central difference
central_difference =(-0.0833*exp(x-2*dx)*cos(x-2*dx)+1.3333*exp(x-dx)*cos(x-dx)-2.5*exp(x)*cos(x)+1.3333*exp(x+dx)*cos(x+dx)-0.0833*exp(x+2*dx)*cos(x+2*dx))/(dx)^2;
solution = abs(analytical_derivative - central_difference);
end
* Function program for 2nd order derivative for fourth-order approximation for skewed left side approximation
function solution = skewed_left_side_approximation(x,dx);
% Analytical function
%f(x) = exp(x)*cos(x)
% seccond order derivative
% f\'\'(x) = -(2*exp(x)*sin(x))
analytical_derivative = -(2*exp(x)*sin(x));
% central_difference =(-0.8333*f(x-5*dx)+5.0833*f(x-4*dx)-13*f(x-3*dx)+17.8333*f(x-2*dx)-12.833*f(x-dx)+3.75*(x))/(dx)^2
% Fourth order approximation of second order derivative using central difference
skewed_left_side_difference =(-0.8333*exp(x-5*dx)*cos(x-5*dx)+5.0833*exp(x-4*dx)*cos(x-4*dx)-13*exp(x-3*dx)*cos(x-3*dx)+17.8333*exp(x-2*dx)*cos(x-2*dx)-12.8333*exp(x-dx)*cos(x-dx)+3.75*exp(x)*cos(x))/(dx)^2;
solution = abs(analytical_derivative - skewed_left_side_difference);
end
* Function program for 2nd order derivative for fourth-order approximation for skewed right side approximation
function solution = skewed_right_side_approximation(x,dx);
% Analytical function
%f(x) = exp(x)*cos(x)
% seccond order derivative
% f\'\'(x) = -(2*exp(x)*sin(x))
analytical_derivative = -(2*exp(x)*sin(x));
% central_difference =(3.75*f(x)-12.3333*f(x+dx)+17.8333*f(x+2*dx)-13*f(x+3*dx)+5.0833*f(x+4*dx))-0.8333*f(x+5*dx))/(dx)^2
% Fourth order approximation of second order derivative using central difference
skewed_right_side_difference =(3.75*exp(x)*cos(x)-12.8333*exp(x+dx)*cos(x+dx)+17.8333*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.8333*exp(x+5*dx)*cos(x+5*dx))/(dx)^2;
solution = abs(analytical_derivative - skewed_right_side_difference);
end
*Graph
*Result
-we plot the graph taking the central approximation(five variable), skewed right side approximation (six variable), a skewed left side approximation (six variable).
- As we can see in the graph that the error in skewed right side differences maximum when the value of dx is greater but when the value of dx decreases, the error also decreases and come to a constant value.
- The error in skewed left side differences maximum when the value of dx is greater but when the value of dx decreases and after some value of dx it again increases and comes to a constant value.
- The error in the central difference is approximately constant at every value of dx we choose.
The skewed scheme is useful, why?
we can see that in CDS we require the values of forwarding and backward points and compute it at the same time so the effective points are not considered which are located in corners. whereas in a skewed scheme we can easily calculate the variable at the corners (either for the right or left scheme)
Another reason for using the skewed scheme is that when we using the information available only flows in one direction (fluid flow, wind flow...) so CDS is not the best option that time because it requires both side information, so a skewed scheme is used for that kind of problem which can define it easily.
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 5.2 - Literature review: ODE Stability
AIM: To understand the stability of an ODE and its effect on engineering simulation. Ordinary Differential Equation: It contains derivatives of one or more functions of an Independent variable. We need to determine the function or set of functions that satisfy the equation to solve an ODE. When does a ODE become…
29 Jan 2022 12:30 PM IST
Week 5.1 - Compact Notation Derivation for a simple Mechanism
AIM: Derive the compact Notation of simple Mechanism. Reaction Mechanism: In chemical kinetics, we use measurement of the macroscopic properties like,rate of change in the concentration of reactants or products with time, to discover the sequence of events that occur at the molecular level during a reaction. This…
21 Jan 2022 11:06 AM IST
Week 4.2 - Combustion Efficiency Calculation after Preheating
AIM To calculate the combustion efficiency after Preheating. OBJECTIVES Find the effect of the range of inlet air preheating from 298k to 600k on the adiabatic flame temperature. Find the effect of pre-heating temperature on combustion efficiency. Theory A Recuperator is often used in power engineering…
17 Jan 2022 11:14 AM IST
Week 4.1- Handling Mixtures with Cantera
AIM To work on the quantity class of the Cantera to create various mixtures. Objective Perform calculation of the adiabatic flame temperature of a gas mixture using quantity class. 1) Use the "moles" method/function of the A object(air) and explain how it was calculated. Now consider any hydrocarbon…
20 Apr 2021 07:08 PM 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.