SlideShare a Scribd company logo
3
Most read
4
Most read
11
Most read
PRACTICAL
Name- Saloni Singhal
M.Sc. (Statistics) II-Sem.
Roll No: 2046398
Course- MATH-409 L
Numerical Analysis Lab
Submitted To: Dr. S.C. Pandey
OBJECTIVE
1. Create an M-file to implement
Newton Gregory Forward Interpolation.
1. Curve Fitting- Least Square nth order
polynomial to data.
Theory
Then the process of knowing the value of f(x ) for some unknown
value of x not explicitly given in the interval [a, b] is called
interpolation. The value thus, determined is known as Interpolated
value.
This Newton Gregory Forward Interpolation formula is particularly
useful for interpolating the values of f(x) near the beginning of the
set of values given. h is called the interval of difference and u = (
x – a ) / h, Here a is the first term.
Error term of the formula:
Program
clear;
%input number of data points
n= input('enter number of data points=');
%input abscissa and ordinate value
for a=1:n
X(a)= input('enter X'+string(a));
end
for b=1:n
Y(b)= input('enter Y'+string(b));
end %enter the value to be interpolated using
forward interpolation
x=input('enter value of x to be interpolated');
%step size h and d gives the forward difference
table
h=X(2)-X(1);
for i=1:n-1
d(i,1)=Y(i+1)-Y(i);
end
for j=2:n-1
for i=1:n-j
d(i,j)=d(i+1,j-1)-d(i,j-1);
end
end
Program Contd.
P1=linspace(min(X),max(X),51);
P2=zeros(51,1);
for i=1:51
P2(i)=nf(P1(i),X,Y,n,d);
end
%plot for the given points
plot(X,Y)
hold on
%plot for the interpoated curve
plot(P1,P2)
hold off
d
nf(x,X,Y,n,d)
% function to calculate the forward inoterpolation
function y=nf(u,X,Y,n,d)
h=X(2)-X(1);
p=(u-X(1))/h;
prod=1;
y=Y(1);
for t=1:n-1
prod=prod*(p-t+1)/t;
y=y+prod*d(1,t);
end
end
Time Complexity
6
For the given program it is calculated as:
For line 14= 2(n-1) since loop
For line 16= (n-1)+1 since loop from 1:n-1
For line 18= 2(n-1)(n-2) for nested loop
For line 24= 51(6n-3) since linspace generates 51
values(given) and min/max has time complexity n
For line 36= (6n-3) since loop is from i to n-1
on adding the above dominant value is =O(n2)
Big O notation is the most common metric for calculating time complexity. It
describes the execution time of a task in relation to the number of steps
required to complete it.
We calculate the
no of operations in
respective loops
and function.
Big ‘O’ notation
takes its dominant
value
Output
Plot of the given data points and interpolated curve
Reference:
— Data Points
plot
—Interpolated
curve
Curve Fitting
Syntax:
p = polyfit(x,y,n)
returns the coefficients
for a polynomial p(x) of
degree n that is a best
fit (in a least-squares
sense) for the data in y.
The coefficients in p are
in descending powers,
and the length of p is
n+1
Conclusion
• The interpolated value of the point is as shown
in figure.
• Polyfit (order 3) verifies the actual cubic
formula for the given set of data points i.e. y=
x³+2x-3.
Caveats
It can be observed that this formula is appropriate when
the value to be interpolated (xs) lie almost in the beginning
of the data table. More explicitly, when xs lies almost in the
end of the data table then only first two or three terms of
(1) can be taken into consideration to keep | s | < 1.
and hence the result will not be sufficiently accurate.
To overcome this problem, we go for next formula named
Newton’s Backward difference formula.

More Related Content

PPTX
Newton Backward Interpolation
PPTX
Lagrange Interpolation
PPTX
Interpolation
PPTX
Numerical Methods
PPTX
PDF
a) Use Newton’s Polynomials for Evenly Spaced data to derive the O(h.pdf
PPTX
numericai matmatic matlab uygulamalar ali abdullah
Newton Backward Interpolation
Lagrange Interpolation
Interpolation
Numerical Methods
a) Use Newton’s Polynomials for Evenly Spaced data to derive the O(h.pdf
numericai matmatic matlab uygulamalar ali abdullah

Similar to Newton Forward Interpolation (20)

PDF
me310_6_interpolation.pdf for numerical method
PDF
Fortran chapter 2.pdf
PDF
Intro. to computational Physics ch2.pdf
PPTX
DIFFERENCE COEFFICIENT with good explanation
DOCX
Assignmnt 4
PPTX
Interpolation In Numerical Methods.
PPTX
formulanonekjdhdihddhkdddnfdbfdjfkddk.pptx
PDF
Computational methods for engineering...
PPTX
18 Interpolation using numerical methods
PPTX
Interpolation and its applications
PDF
2. polynomial interpolation
PPT
Maths Topic on spline interpolation methods
PDF
Lecture about interpolation
PPTX
Interpolation-and-Approximation-Bridging-Data-Gaps-and-Modelling-Reality.pptx
PPTX
Interpolation.pptx
PPTX
PDF
Data fitting in Scilab - Tutorial
PDF
Matlab lecture 8 – newton's forward and backword interpolation@taj copy
PPTX
Numerical Methods.pptx
PDF
me310_6_interpolation.pdf for numerical method
Fortran chapter 2.pdf
Intro. to computational Physics ch2.pdf
DIFFERENCE COEFFICIENT with good explanation
Assignmnt 4
Interpolation In Numerical Methods.
formulanonekjdhdihddhkdddnfdbfdjfkddk.pptx
Computational methods for engineering...
18 Interpolation using numerical methods
Interpolation and its applications
2. polynomial interpolation
Maths Topic on spline interpolation methods
Lecture about interpolation
Interpolation-and-Approximation-Bridging-Data-Gaps-and-Modelling-Reality.pptx
Interpolation.pptx
Data fitting in Scilab - Tutorial
Matlab lecture 8 – newton's forward and backword interpolation@taj copy
Numerical Methods.pptx
Ad

More from Saloni Singhal (20)

PPTX
Finite Difference Method
PPTX
Runge Kutta Method
PPTX
Euler Method
PPTX
Simpson's Three-Eighth Method
PPTX
Trapezoidal Rule
PPTX
Simpson One-Third
PPTX
Forward & Backward Differenece Table
PPTX
Bisection Method
PPTX
Newton's Raphson method
PPTX
Fixed Point Interation
PPTX
Power Method
PPTX
Eigen Show
PPTX
Inverse Power Method
PPTX
Convergence Analysis
PPTX
MARLAB codes for Gauss Seidel
PPTX
MATLAB Codes for Jacobi method
PPTX
L-U Decomposition
PPTX
Gauss Elimination (without pivot).pptx
PPTX
Gauss Elimination (With Partial Pivot)
PPTX
Error analysis
Finite Difference Method
Runge Kutta Method
Euler Method
Simpson's Three-Eighth Method
Trapezoidal Rule
Simpson One-Third
Forward & Backward Differenece Table
Bisection Method
Newton's Raphson method
Fixed Point Interation
Power Method
Eigen Show
Inverse Power Method
Convergence Analysis
MARLAB codes for Gauss Seidel
MATLAB Codes for Jacobi method
L-U Decomposition
Gauss Elimination (without pivot).pptx
Gauss Elimination (With Partial Pivot)
Error analysis
Ad

Recently uploaded (20)

PPT
Reliability_Chapter_ presentation 1221.5784
PPTX
Acceptance and paychological effects of mandatory extra coach I classes.pptx
PPTX
Business Ppt On Nestle.pptx huunnnhhgfvu
PPTX
Introduction-to-Cloud-ComputingFinal.pptx
PDF
Recruitment and Placement PPT.pdfbjfibjdfbjfobj
PDF
Fluorescence-microscope_Botany_detailed content
PPTX
iec ppt-1 pptx icmr ppt on rehabilitation.pptx
PPTX
AI Strategy room jwfjksfksfjsjsjsjsjfsjfsj
PPTX
climate analysis of Dhaka ,Banglades.pptx
PPTX
Introduction to Knowledge Engineering Part 1
PPTX
Microsoft-Fabric-Unifying-Analytics-for-the-Modern-Enterprise Solution.pptx
PPTX
IBA_Chapter_11_Slides_Final_Accessible.pptx
PPTX
STUDY DESIGN details- Lt Col Maksud (21).pptx
PDF
Mega Projects Data Mega Projects Data
PPTX
The THESIS FINAL-DEFENSE-PRESENTATION.pptx
PPTX
01_intro xxxxxxxxxxfffffffffffaaaaaaaaaaafg
PPT
Miokarditis (Inflamasi pada Otot Jantung)
PPTX
mbdjdhjjodule 5-1 rhfhhfjtjjhafbrhfnfbbfnb
PPTX
Introduction to Firewall Analytics - Interfirewall and Transfirewall.pptx
PPTX
Supervised vs unsupervised machine learning algorithms
Reliability_Chapter_ presentation 1221.5784
Acceptance and paychological effects of mandatory extra coach I classes.pptx
Business Ppt On Nestle.pptx huunnnhhgfvu
Introduction-to-Cloud-ComputingFinal.pptx
Recruitment and Placement PPT.pdfbjfibjdfbjfobj
Fluorescence-microscope_Botany_detailed content
iec ppt-1 pptx icmr ppt on rehabilitation.pptx
AI Strategy room jwfjksfksfjsjsjsjsjfsjfsj
climate analysis of Dhaka ,Banglades.pptx
Introduction to Knowledge Engineering Part 1
Microsoft-Fabric-Unifying-Analytics-for-the-Modern-Enterprise Solution.pptx
IBA_Chapter_11_Slides_Final_Accessible.pptx
STUDY DESIGN details- Lt Col Maksud (21).pptx
Mega Projects Data Mega Projects Data
The THESIS FINAL-DEFENSE-PRESENTATION.pptx
01_intro xxxxxxxxxxfffffffffffaaaaaaaaaaafg
Miokarditis (Inflamasi pada Otot Jantung)
mbdjdhjjodule 5-1 rhfhhfjtjjhafbrhfnfbbfnb
Introduction to Firewall Analytics - Interfirewall and Transfirewall.pptx
Supervised vs unsupervised machine learning algorithms

Newton Forward Interpolation

  • 1. PRACTICAL Name- Saloni Singhal M.Sc. (Statistics) II-Sem. Roll No: 2046398 Course- MATH-409 L Numerical Analysis Lab Submitted To: Dr. S.C. Pandey
  • 2. OBJECTIVE 1. Create an M-file to implement Newton Gregory Forward Interpolation. 1. Curve Fitting- Least Square nth order polynomial to data.
  • 3. Theory Then the process of knowing the value of f(x ) for some unknown value of x not explicitly given in the interval [a, b] is called interpolation. The value thus, determined is known as Interpolated value. This Newton Gregory Forward Interpolation formula is particularly useful for interpolating the values of f(x) near the beginning of the set of values given. h is called the interval of difference and u = ( x – a ) / h, Here a is the first term. Error term of the formula:
  • 4. Program clear; %input number of data points n= input('enter number of data points='); %input abscissa and ordinate value for a=1:n X(a)= input('enter X'+string(a)); end for b=1:n Y(b)= input('enter Y'+string(b)); end %enter the value to be interpolated using forward interpolation x=input('enter value of x to be interpolated'); %step size h and d gives the forward difference table h=X(2)-X(1); for i=1:n-1 d(i,1)=Y(i+1)-Y(i); end for j=2:n-1 for i=1:n-j d(i,j)=d(i+1,j-1)-d(i,j-1); end end
  • 5. Program Contd. P1=linspace(min(X),max(X),51); P2=zeros(51,1); for i=1:51 P2(i)=nf(P1(i),X,Y,n,d); end %plot for the given points plot(X,Y) hold on %plot for the interpoated curve plot(P1,P2) hold off d nf(x,X,Y,n,d) % function to calculate the forward inoterpolation function y=nf(u,X,Y,n,d) h=X(2)-X(1); p=(u-X(1))/h; prod=1; y=Y(1); for t=1:n-1 prod=prod*(p-t+1)/t; y=y+prod*d(1,t); end end
  • 6. Time Complexity 6 For the given program it is calculated as: For line 14= 2(n-1) since loop For line 16= (n-1)+1 since loop from 1:n-1 For line 18= 2(n-1)(n-2) for nested loop For line 24= 51(6n-3) since linspace generates 51 values(given) and min/max has time complexity n For line 36= (6n-3) since loop is from i to n-1 on adding the above dominant value is =O(n2) Big O notation is the most common metric for calculating time complexity. It describes the execution time of a task in relation to the number of steps required to complete it. We calculate the no of operations in respective loops and function. Big ‘O’ notation takes its dominant value
  • 8. Plot of the given data points and interpolated curve Reference: — Data Points plot —Interpolated curve
  • 9. Curve Fitting Syntax: p = polyfit(x,y,n) returns the coefficients for a polynomial p(x) of degree n that is a best fit (in a least-squares sense) for the data in y. The coefficients in p are in descending powers, and the length of p is n+1
  • 10. Conclusion • The interpolated value of the point is as shown in figure. • Polyfit (order 3) verifies the actual cubic formula for the given set of data points i.e. y= x³+2x-3.
  • 11. Caveats It can be observed that this formula is appropriate when the value to be interpolated (xs) lie almost in the beginning of the data table. More explicitly, when xs lies almost in the end of the data table then only first two or three terms of (1) can be taken into consideration to keep | s | < 1. and hence the result will not be sufficiently accurate. To overcome this problem, we go for next formula named Newton’s Backward difference formula.