All Courses
All Courses
Courses by Software
Courses by Semester
Courses by Domain
Tool-focused Courses
Machine learning
POPULAR COURSES
Success Stories
AIM: Derive the following 4th order approximations of the second-order derivative. 1. Central difference 2. Skewed right-sided difference 3. Skewed left-sided difference After deriving these schemes, prove that your skewed schemes are fourth-order accurate Writing a program in Matlab to evaluate the second-order…
Naveen Gopan
updated on 02 Jun 2021
AIM:
Derive the following 4th order approximations of the second-order derivative.
1. Central difference
2. Skewed right-sided difference
3. Skewed left-sided difference
After deriving these schemes, prove that your skewed schemes are fourth-order accurate
Writing a program in Matlab to evaluate the second-order derivative of the analytical function ex⋅cos(x) and compare it with the 3 numerical approximations that you have derived.
Provide a plot that compares the absolute error between the above-mentioned schemes
THEORY:
TAYLOR TABLE FOR CENTRAL DIFFERENCE:
Number of Nodes = p+q-1
q = Order of Derivative = 2
p = Order of Approximation = 4
Number of Nodes/points = 2+4-1=5
△x2d2udx2=af(i−2)+bf(i−1)+cf(i)+df(i+1)+ef(i+2)
f(i) | △xf'(i) | △x2f''(x) | △x3f'''(x) | △x4f''''(x) | |
af(i-2) | a | -2a | 4a2 | −8a6 | 16a24 |
bf(i-1) | b | -b | b2 | −b6 | b24 |
cf(i) | c | 0 | 0 | 0 | 0 |
df(i+1) | d | d | d2 | d6 | d24 |
ef(i+2) | e | 2e | 4e2 | 8e6 | 16e24 |
0 | 0 | 1 | 0 | 0 |
From the above Taylor Table, the following algebraic equation can be formed:
a+b+c+d+e = 0
-2a-b+d+2e=0
4a2+b2+d2+4e2=1
−8a6+−b6+d6+8e6=0
16a24+b24+d24+16e24=0
This can be solved using the Matrix form AX=B, X= A−1B
TAYLOR TABLE FOR SKEWED RIGHT-SIDED DIFFERENCE:
Number of Nodes = p+q
q = Order of Derivative = 2
p = Order of Approximation = 4
Number of Nodes/points = 2+4=6
△x2d2udx2=af(i)+bf(i+1)+cf(i+2)+df(i+3)+ef(i+4)+gf(i+5)
f(i) | △xf'(i) | △x2f''(x) | △x3f'''(x) | △x4f''''(x) | △x5f'''''(x) | |
af(i) | a | 0 | 0 | 0 | 0 | 0 |
bf(i+1) | b | b | b2 | b6 | b24 | b120 |
cf(i+2) | c | 2c | 4c2 | 8c6 | 16c24 | 32c120 |
df(i+3) | d | 3d | 9d2 | 27d6 | 81d24 | 243d120 |
ef(i+4) | e | 4e | 16e2 | 64e6 | 256e24 | 1024e120 |
gf(i+5) | g | 5g | 25g2 | 125g6 | 625g24 | 3125g120 |
0 | 0 | 1 | 0 | 0 | 0 |
From the above Taylor Table, the following algebraic equation can be formed:
a+b+c+d+e+g = 0
b+2c+3d+4e+5g=0
b2+4c2+9d2+16e2+25g2=1
b6+8c6+27d6+64e6+125g6=0
b24+16c24+81d24+256e24+625g24=0
b120+32c120+243d120+1024e120+3125g120=0
This can be solved using the Matrix form AX=B, X= A−1B
TAYLOR TABLE FOR SKEWED LEFT-SIDED DIFFERENCE:
Number of Nodes = p+q
q = Order of Derivative = 2
p = Order of Approximation = 4
Number of Nodes/points = 2+4 = 6
△x2d2udx2=af(i−5)+bf(i−4)+cf(i−3)+df(i−2)+ef(i−1)+gf(i)
f(i) | △xf'(i) | △x2f''(x) | △x3f'''(x) | △x4f''''(x) | △x5f'''''(x) | |
af(i-5) | a | -5a | 25a2 | −125a6 | 625a24 | −3125a120 |
bf(i-4) | b | -4b | 16b2 | −64b6 | 256b24 | −1024b120 |
cf(i-3) | c | -3c | 9c2 | −27c6 | 81c24 | −243c120 |
df(i-2) | d | -2d | 4d2 | −8d6 | 16d24 | −32d120 |
ef(i-1) | e | -e | e2 | −e6 | e24 | −e120 |
gf(i) | g | 0 | 0 | 0 | 0 | 0 |
0 | 0 | 1 | 0 | 0 | 0 |
From the above Taylor Table, the following algebraic equation can be formed:
a+b+c+d+e+g = 0
5a+4b+3c+2d+e=0
25a2+16b2+9c2+4d2+e2=1
125a6+64b6+27c6+8d6+e6=0
625a24+256b24+81c24+16d24+e24=0
3125a120+1024b120+243c120+32d120+e120=0
This can be solved using the Matrix form AX=B, X= A−1B
FUNCTION:
f(x)=ex⋅cos(x)
f''(x)=−2⋅ex⋅sin(x)
x= π4
△x= linspace(π4,π40,40)
MATLAB CODE:
clear all
close all
clc
%finding the coefficients to the 4th order approximations
%central difference method
A = [1,1,1,1,1;-2,-1,0,1,2;4,1,0,1,4;-8,-1,0,1,8;16,1,0,1,16];
P = [0;0;2;0;0];
X1 = inv(A)*P
%skewed right side diffrence method
B = [1,1,1,1,1,1;0,1,2,3,4,5;0,1,4,9,16,25;0,1,8,27,64,125;0,1,16,81,256,625;0,1,32,243,1024,3125];
Q = [0;0;2;0;0;0];
X2=inv(B)*Q
%skewed LEFT side diffrence method
C = [1,1,1,1,1,1;5,4,3,2,1,0;25,16,9,4,1,0;125,64,27,8,1,0;625,256,81,16,1,0;3125,1024,243,32,1,0];
X3 = inv(C)*Q
% function input
x=pi/4;
dx=linspace(pi/4,pi/40,40);
y = exp(x)*cos(x);
exact_derivative = -2*exp(x)*sin(x)
% derivative w.r.t cental diffrence method
for i = 1:length(dx)
DR1(i) = ((X1(1)*exp(x-(2*dx(i)))*cos(x-(2*dx(i))))+(X1(2)*exp(x-dx(i))*cos(x-dx(i)))+(X1(3)*exp(x)*cos(x))+(X1(4)*exp(x+dx(i))*cos(x+dx(i)))+(X1(5)*exp(x+(2*dx(i)))*cos(x+(2*dx(i)))))/dx(i)^2;
central_error(i)=abs(exact_derivative-DR1(i));
end
% derivative w.r.t skewed right side diffrence method
for i = 1:length(dx)
DR2(i)=((X2(1)*exp(x)*cos(x))+(X2(2)*exp(x+dx(i))*cos(x+dx(i)))+(X2(3)*exp(x+(2*dx(i)))*cos(x+(2*dx(i))))+(X2(4)*exp(x+(3*dx(i)))*cos(x+(3*dx(i))))+(X2(5)*exp(x+(4*dx(i)))*cos(x+(4*dx(i))))+(X2(6)*exp(x+(5*dx(i)))*cos(x+(5*dx(i)))))/dx(i)^2;
Skewed_right_error(i) = abs(exact_derivative-DR2(i));
end
% derivative w.r.t skewed left side diffrence method
for i = 1:length(dx)
DR3(i)= ((X3(1)*exp(x-(5*dx(i)))*cos(x-(5*dx(i))))+(X3(2)*exp(x-(4*dx(i)))*cos(x-(4*dx(i))))+(X3(3)*exp(x-(3*dx(i)))*cos(x-(3*dx(i))))+(X3(4)*exp(x-(2*dx(i)))*cos(x-(2*dx(i))))+(X3(5)*exp(x-dx(i))*cos(x-dx(i)))+(X3(6)*exp(x)*cos(x)))/dx(i)^2;
Skewed_left_error(i) = abs(exact_derivative-DR3(i));
end
%comparison plots
loglog(dx,central_error,dx,Skewed_right_error,dx,Skewed_left_error)
xlabel('dx')
ylabel('Truncation Errors')
legend('Central Difference Error','Skewed Right Sided Error','Skewed Left Sided Error')
title('Variation of Absolute Error of Diffrent Schemes With Respect To The Variation In dx')
OBSERVATION/OUTPUT:
CONCLUSION:
Central Difference < Skewed Left Side ~< Skewed Right Side
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 3.5 - Deriving 4th order approximation of a 2nd order derivative using Taylor Table method
AIM: Derive the following 4th order approximations of the second-order derivative. 1. Central difference 2. Skewed right-sided difference 3. Skewed left-sided difference After deriving these schemes, prove that your skewed schemes are fourth-order accurate Writing a program in Matlab to evaluate the second-order…
02 Jun 2021 02:17 PM IST
SIMULATION OF DAMPED HARMONIC MOTION OF A SIMPLE PENDULUM USING MATLAB
AIM: To write a program that solves the ODE representing the equation of motion of a simple pendulum with damping and to produce the simulation of motion for this damped oscillation. OBJECTIVE: To write the neccessary code to solve the 2nd order ODE of damped harmonic motion using MATLAB. To plot the angular displacement…
27 May 2021 01:49 PM IST
STOICHIOMETRIC COMBUSTION COEFFICIENT CALCULATOR USING MATLAB
AIM: 1. Write functions to calculate the stoichiometric co-efficient (ar) for each fuel 2. Show a plot that compares the effect of number of atoms of carbon on the stoichiometric co-efficient "ar". Compare how this trend changes with the fuel type (alkane, alkene and alkyne). THEORY: Combustion or burning is a high…
25 May 2021 11:08 AM IST
DESIGN OF A BY-PASS VALVE
AIM: Design of a Solenoid in-line By-Pass Valve with Inlet Día of ∅9 mm and Outlet Día of ∅11 mm using Autodesk Inventor. SOLENOID VALVE: A solenoid valve is an electromechanically operated valve. Solenoid valves differ in the characteristics of the electric current they use, the strength of the…
01 Nov 2020 10:12 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.