All Courses
All Courses
Courses by Software
Courses by Semester
Courses by Domain
Tool-focused Courses
Machine learning
POPULAR COURSES
Success Stories
Objective : To find the fourth order approximations of second order derivative , using central and skewed scheme. Compare all schemes. Central Symmetric Scheme : Fourth Order Approximation of second order derivative Since , Fourth order Approximation we need four discrete neighbour points . Central , so same number…
Epuri Yoga Narasimha
updated on 25 Jan 2021
Objective :
Central Symmetric Scheme : Fourth Order Approximation of second order derivative
Since , Fourth order Approximation we need four discrete neighbour points .
Central , so same number of nodes on both sides.
Method:
d2fdx2=a⋅f(i-2)+b⋅f(i-1)+c⋅f(i)+d⋅f(i+1)+e⋅f(i+2)+...d2fdx2=a⋅f(i−2)+b⋅f(i−1)+c⋅f(i)+d⋅f(i+1)+e⋅f(i+2)+... ------->(1)
Using Taylor Series Expansion:
a⋅f(i-2)≈a⋅f(xi)-a⋅f1(xi)⋅2⋅h+a2⋅f2(xi)2!⋅(2⋅h)2-a⋅f3(xi)3!⋅(2⋅h)3+a⋅f4(xi)4!⋅(2⋅h)4-a⋅f5(xi)5!⋅(2⋅h)5+... -->(2)
b⋅f(i-1)≈b⋅f(xi)-b⋅f1(xi)⋅h+b⋅f2(xi)2!⋅(⋅h)2-b⋅f3(xi)3!⋅(h)3+b⋅f4(xi)4!⋅(h)4-b⋅f5(xi)5!⋅(h)5+... -->(3)
câ‹…f(i)=câ‹…f(xi) -->(4)
b⋅f(i+1)≈b⋅f(xi)+b⋅f1(xi)⋅h+b⋅f2(xi)2!⋅(⋅h)2+b⋅f3(xi)3!⋅(h)3+b⋅f4(xi)4!⋅(h)4+b⋅f5(xi)5!⋅(h)5+... -->(5)
a⋅f(i+2)≈a⋅f(xi)+a⋅f1(xi)⋅2⋅h+a2⋅f2(xi)2!⋅(2⋅h)2+a⋅f3(xi)3!⋅(2⋅h)3+a⋅f4(xi)4!⋅(2⋅h)4+a⋅f5(xi)5!⋅(2⋅h)5+... -->(6)
Here taken , h = grid space.
Taking common terms and equating to L.H.S , represented in table
f(xi) | f1(xi)⋅Δx | f2(xi)⋅(Δx)2 | f3(xi)(Δx)3 | f4(xi)⋅(Δx)4 | f5(xi)⋅(Δx)5 | f6(xi)⋅(Δx)6 | |
aâ‹…fi-2 | a | -2â‹…a | 2â‹…a | -8â‹…a3 | 16â‹…a24 | -32â‹…a120 | 266!â‹…e |
bâ‹…fi-1 | b | -b | b2 | -b6 | b24 | -b120 | 16!â‹…e |
câ‹…fi | c | 0 | 0 | 0 | 0 | 0 | 0 |
dâ‹…fi+1 | d | d | d2 | d6 | d24 | d120 | d6!â‹…e |
eâ‹…fi+2 | e | 2â‹…e | 2â‹…e | 8â‹…e6 | 16â‹…e24 | 32â‹…e120 | 266!â‹…e |
0 | 0 | 1 | 0 | 0 | ? | ? |
Considered five relations , since we required five unknown values using ,matlab
close all
clear all
clc
a = [1 1 1 1 1 ; -2 -1 0 1 2 ; 2 1/2 0 1/2 2 ; -4/3 -1/6 0 1/6 4/3 ; 2/3 1/24 0 1/24 2/3];
b = [0 ; 0 ; 1 ; 0 ; 0];
x = inv(a)*b;
Got values as ,
a = -0.0833
b = 1.3333
c = -2.5000
d = 1.3333
e = -0.0833
∂2f∂x2≈a⋅f(xi-2)+b⋅f(xi-1)+c⋅f(xi)+d⋅f(xi+1)+e⋅f(xi+2)≈(-2⋅a-b+d+2⋅d)⋅f2(x)⋅h2+O(h6) --> (7)
On simple manipulating the equation by using all equation data about , we got equation (7)
∂2f∂x2≈-0.0833⋅f(xi-2)+1.3333⋅f(xi-1)±2.5000⋅f(xi)+1.3333⋅f(xi+1)+0.0833⋅f(xi+2)(Δx)2≈(-2⋅0.0833+12⋅1.3333+12⋅1.3333+2⋅0.0833)⋅f2(x)+O(h4)`
∂2f∂x2≈-0.0833⋅f(xi-2)+1.3333⋅f(xi-1)±2.5000⋅f(xi)+1.3333⋅f(xi+1)+0.0833⋅f(xi+2)(Δx)2≈(1.3333)⋅f2(x)+O(h4)`
Forward Difference (or) Skewed right scheme :
Same approach for any scheme , either central or skewed.
Here , we take 6 nodes(4+2) , all aligned in right side.
∂2f∂x2≈a⋅f(i)+b⋅f(i+1)+c⋅f(i+2)+d⋅f(i+3)+d⋅f(i+4)+e⋅f(i+5) ----> (2a)
close all
clear all
clc
a = [1 1 1 1 1 1 ; 0 1 2 3 4 5 ; 0 1/2 2 9/2 8 25/2 ; 0 1/6 4/3 9/2 32/3 125/6 ; 0 1/24 2/3 27/8 32/3 625/24 ; 0 1/120 32/120 243/120 1024/120 3125/120];
b = [0 ; 0 ; 1 ; 0 ; 0 ; 0];
x = inv(a)*b;
Results :
a = 3.7500
b = -12.8333
c = 17.8333
d = -13.0000
e = 5.0833
e = -0.83333
Substitute values in equaiton (2a)
∂2f∂x2≈3.7500⋅f(i)-12.8333⋅f(i+1)+17.8333⋅f(i+2)-13.0000⋅f(i+3)+5.0833⋅f(i+4)-0.8333⋅f(i+5)(1.0001⋅dx2)
Backward Difference (or) Skewed-Left scheme :
∂2f∂x2≈a⋅f(i)+b⋅f(i-1)+c⋅f(i-2)+d⋅f(i-3)+d⋅f(i-4)+e⋅f(i-5) ` -----> (3a)
%%
clc
a3 = [1 1 1 1 1 1 ; 0 -1 -2 -3 -4 -5 ; 0 1/2 4/2 9/2 16/2 25/2 ; 0 -1/6 -2^3/6 -3^3/6 -4^3/6 -5^3/6; b30 1/24 2^4/24 3^4/24 4^4/24 5^4/24 ;0 -1/120 -2^5/120 -3^5/120 -4^5/120 -5^5/120 ];
c3 = [0; 0; 1; 0; 0; 0];
b3 = inv(a3)*c3;
Results :
a = 3.7500
b = -12.8333
c = 17.8333
d = -13.0000
e = 5.0833
e = -0.83333
∂2f∂x2≈3.7500⋅f(i)-12.8333⋅f(i-1)+17.8333⋅f(i-2)-13.0000⋅f(i-3)+5.0833⋅f(i-4)-0.8333⋅f(i-5)(1.0001⋅dx2) `
Main code snippet:
%%
close all
clear all
clc
% central , skewed-left , skewed right appproimations of second order
% derivative
% considered target node , x = pi/3;
x = pi/3;
% Grid values
dx = linspace(pi/4,pi/4000,20);
for i = 1:length(dx)
[sk_ri(i)] = skewed_right(x,dx(i));
[sk_le(i)] = skewed_left(x,dx(i));
[ce_Ap(i)] = central_Approx_Taylor(x,dx(i));
end
loglog(dx,sk_ri)
hold on
loglog(dx,sk_le)
loglog(dx,ce_Ap)
xlabel('grid sizen on loglog scale')
ylabel('error values')
legend('skewed-right','skewed-left','central-approximation')
grid on
figure(2)
plot(log10(dx),log10(sk_ri),'color','b')
hold on
plot(log10(dx),log10(sk_le),'color','r')
plot(log10(dx),log10(ce_Ap),'color','m')
xlabel('grid sizen on log10 scale')
ylabel('error values')
legend('skewed-right','skewed-left','central-approximation')
grid on
figure(3)
plot(dx,sk_ri,'color','r')
plot(dx,sk_le,'color','b')
plot(dx,ce_Ap,'color','m')
xlabel('grid size')
ylabel('error values')
legend('skewed-right','skewed-left','central-approximation')
grid on
Central_Approx_code_Snippet:
function [out_central] =central_Approx_Taylor(x,dx)
out_fourth = ((-0.0833*dis_r(x-2*dx) + 1.3333*dis_r(x-dx)-2.5000*dis_r(x) + 1.3333*dis_r(x+dx) + 0.0833-dis_r(x+2*dx)))/(1.3333*dx^2);
True_value = -2*exp(x)*sin(x);
out_central = abs(True_value-out_fourth);
end
Skewed_left_Approx_code_Snippet:
function [out_left] = skewed_left(x,dx)
out_left1 = ((3.7500*dis_r(x) - 12.8333*dis_r(x-dx)+17.8333*dis_r(x-2*dx) -13.0000*dis_r(x-3*dx) + 5.0833*dis_r(x-4*dx) - 0.8333*dis_r(x-5*dx)))/(1.0001*dx^2);
True_value = -2*exp(x)*sin(x);
out_left = abs(True_value-out_left1);
end
Skewed_Right_Approx_code_Snippet:
function [out_right] = skewed_right(x,dx)
out_fourth = ((3.7500*dis_r(x) - 12.8333*dis_r(x+dx)+17.8333*dis_r(x+2*dx) -13.0000*dis_r(x+3*dx) + 5.0833*dis_r(x+4*dx) - 0.8333*dis_r(x+5*dx)))/(1.0001*dx^2);
True_value = -2*exp(x)*sin(x);
out_right = abs(True_value-out_fourth);
end
Function :
function [z] = dis_r(x)
z = exp(x)*cos(x);
end
Explanation of code :
1. Assigned required variables for computations -> Target node and grid size.
2. Declared Functions for all 3 schemes for second order derivative.
3. Using these function got the error for all schemes for different grid sizes.
4. plotted the data using loglog command.
As observed from the graph , central Approximation giving more error , for second order derivative for fourth order approximation , may be due to round-off erros in computations.
Ceantral Approximation are not useful in some applications , when the path of study in unidirectional , like Heat tranfer from a boundary.
In this case we can't use central Approximation.
So , we should consider the numerical scheme carefully , that depends on approximation order and h reinfinement.
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...
Project 4
Objective 1. Detect lanes using Hough Transform Method. Steps in lane Detection 1. Detect Edges using Canny Edge Detection Method. 2. Capture the Region of Interest in Image. 3. Detect lines using Hough Transform. 4. Calculate the actual left and right lanes from all lines. 6. Find the coordinates of the lines. 7. Display…
21 Feb 2023 05:22 AM IST
Lane Detection using Hough Transform
Objective 1. Detect lanes using Hough Transform Method. Steps in lane Detection 1. Detect Edges using Canny Edge Detection Method. 2. Capture the Region of Interest in Image. 3. Detect lines using Hough Transform. 4. Calculate the actual left and right lanes from all lines. 6. Find the coordinates of the lines. 7. Display…
21 Feb 2023 05:20 AM IST
Edge Detection and Hough Transform
Objective: Detecting Edges using Canny Edge Detector. Understand and display the outputs of all steps in the canny Edge Detection process. Effect on the output on changing the parameters of the Non-Maximum Suppression. Understand Hough Transform and Lane Detection using Hough Transform. Steps Follow in the Discussion:…
28 Dec 2022 09:58 PM IST
week 2 : Image Filtering
Objective: Apply Prewitt and Laplacian filter on the image Libraries used: Opencv Open Source computer vision library. cross-platform supported. can perform through c, c++, and python. numpy Mathematical library to work in the domain of Linear algebra, Fourier transform, and matrices. Image Filtering…
09 Jul 2022 06:36 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.