All Courses
All Courses
Courses by Software
Courses by Semester
Courses by Domain
Tool-focused Courses
Machine learning
POPULAR COURSES
Success Stories
Objective : To compare the accuracy of different Numerical Difference methods with Analytical Solution. Numerical Methods : Numerical Methods are really helpful in analysing the physical behaviours using computations. They provide flexibility , and complexity in solving for results. As in numerical methods , we convert…
Epuri Yoga Narasimha
updated on 23 Jan 2021
Objective :
To compare the accuracy of different Numerical Difference methods with Analytical Solution.
Numerical Methods :
Numerical Methods are really helpful in analysing the physical behaviours using computations.
They provide flexibility , and complexity in solving for results.
As in numerical methods , we convert complex function into Algebraic (polynomial) equaition , so that we can easily quanitify the problem.
Easy to compare things.
Considered Four Methods :
1. Forward Difference Approximation.
f′=f(x+dx)-f(x)dx
2. Backward Difference Approximation.
f′=f(x)-f(x-dx)dx
3. Central Difference Approximation.
f′=f(x+dx)-f(x-dx)2⋅dx
4. Central 4th order Approximation.
f′=f(x-2⋅dx)-8⋅f(x-dx)+8⋅f(x+dx)-f(x+2⋅dx)12⋅dx
Just imagine a tangent curve at the peak of curve of red curve , that our actual study.
But we study the secent lines represented in graph.
As can observe that central difference approximation is near to the model(more accurate).
Taylor Series Expansion :
f(x)=f(a)+f′(a)1!⋅(x-a)1+f′′(a)2!⋅(x-a)2+f′′′(a)!⋅(xi+1-f(xi))3+...
For Foward Difference , put x = xi+1.
a = xi.
f(xi+1)=f(xi)+f′(xi)1!⋅(xi+1-xi)+f′′(xi)2!⋅(xi+1-xi)2+f′′′(xi)3!.(xi+1-xi)3+... --------->1
f(xi+1)-f(xi)h=f′(xi)+O(h)
For Backward Difference , put x = xi-1.
a = xi.
f(xi-1)=f(xi)-f′(xi)1!⋅(xi-1-xi)+f′′(xi)2!⋅(xi-1-xi)2-f′′′(xi)3!.(xi-1-xi)3+... ----------->2
f(xi-xi-1)h=f′(x)+O(h)
For Centeral Difference Approximation :
Subtract equation 2 from equation 1, we get
f(xi+1)-f(xi-1)=2⋅f′(xi)1!⋅(h)1+2⋅f′′′(xi)3!⋅(h)3+...
Divide by 2h on both sides
f(xi+1)-f(xi-1)(2⋅h)=f′(xi)1!+f′′′(xi)3!⋅(h)2+...
Can observe that order of Error is : O(h2)
For centeral 4th order Approximation :
This can be solved by 'method of unknown variables' .
This method use the neighbour values for to find approximate at the particular points.
Number of terms depends on the order of approximation (or) order of error to be made.
since , our investigation is for 4th order approximation , we need four neighboring points.
And point consideration depends on the flow , like forward , backward , central Numerical scheme depends on the physical behaviour of model.
f′(x)=A1⋅f(x-2h)+A2⋅f(x-h)+A3⋅f(x)+A4⋅f(x+h)+A5⋅f(x+2h)h
Eapand the terms using Taylor sereies , by comparing the left and right oreder terms , we get algebraic equaitons
Considered 5 equations , as 5 unknown variables
As you can see , calculated the unknown variables , keep in above equation , we get the required format.
ORDER OF ERROR -> O(h^4) -> Since we considered 5 equations , so the leading term will be O(h^4) , if that term not equal to zero .
If that term equal to zero , then move the next term in the flow.
Code Snippet :
%% clearing commands
close all ; clear all ; clc ;
% Analytical function
% f(x) = sin(x)/x^3;
x = pi/3;
dx = pi/40;
True_value = (x^3*(cos(x)) - sin(x)*3*x^2)/(x^6);
Forward_Difference = (dis_r(x+dx) - dis_r(x))/dx;
Backward_Difference = (dis_r(x) - dis_r(x-dx))/dx;
Central_Difference = (dis_r(x+dx) - dis_r(x-dx))/(2*dx);
Central_4th_order = (dis_r(x-2*dx) - 8*dis_r(x-dx) + 8*dis_r(x+dx) - dis_r(x+2*dx))/(12*dx);
% error
error_Forward_Difference = abs(True_value - Forward_Difference);
error_Backward_Difference = abs(True_value - Backward_Difference);
error_Central_Difference = abs(True_value - Central_Difference);
error_Central_4th_Difference = abs(True_value - Central_4th_order);
%% Bar plot
bar(1,error_Forward_Difference)
hold on
bar(2,error_Backward_Difference)
bar(3,error_Central_Difference)
bar(4,error_Central_4th_Difference)
legend('Forward Difference','Backward Difference','Central Difference','Central 4th order Approximation')
xlabel('Approximation Methods')
ylabel('Absolute errors')
Explanation of code:
1. At first used clearing commands , to clear the present data on the interface.
2. Assigned given data variables.
3. Calculated True value (analytical Method) , and Numerical Method(By respective relations).
4. And got the absolute error for all methods.
5. Plotted the data using bar command.
7. Labeled the plot.
Function Snippet :
function [z] = dis_r(x)
z = sin(x)/x^3;
end
1. Used function to reduce the complexity in representing the equation.
RESULTS :
CONCLUSIONS:
1 . From the bar observed , as increase in the order of approximation order of accuracy increases and error decreases.
2. Forward difference approximation is more accurate than Backward difference approximation.
3. Central difference Approximation is more accurate than Forward and Backward Approximations.
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.