When to use Newtons backward interpolation formula

Named after Sir Isaac Newton, Newton’s Interpolation is a popular polynomial interpolating technique of numerical analysis and mathematics. Here, the coefficients of polynomials are calculated by using divided difference, so this method of interpolation is also known as Newton’s divided difference interpolation polynomial. Newton polynomial interpolation consists of Newton’s forward difference formula and Newton’s backward difference formula.

In this tutorial, we’re going to write Matlab programs for Newton’s forward interpolation as well as Newton’s backward interpolation, going through the mathematical derivation of the interpolation technique in general. You can also check out our earlier tutorials where we discussed C programs for Newton’s forward interpolation and Newton’s divided difference.

Derivation of Newton’s Interpolation:

Let us consider a set of k+1 data points (x0, y0) , (x1, y1), (x2, y2), . … . .(xk, yk).

where, every xj is unique.

The given interpolation of polynomial in Newton’s form can be expressed in linear combination of Newton basis polynomial as follows:

Again, the Newton basis Polynomials can be defined as:

which is valid for j > 0 and n0(x) ≡ 1

Similarly, the coefficients are defined as:

aj := [y0, y1, y2, .. . . . . .yj]

where, [y0, y1, y2, .. . . . . .yj] is the notation of divided difference.

Now, Newton’s interpolation or polynomial can be expressed as:

N(x) = [y0] + [y0, y1] (x –x0) + . . . + [y0, . . .yk]( x – x0) ( x – x1) . . . ( x – xk-1)

This form of Newton’s polynomial can be simplified by arranging xo, x1, x2, … xk in consecutively equal space.

For simplicity, use the notation h = xi+1 – xi

where, i = 0, 1, . . . .k- 1 and x = x0 + sh

Again, the difference x – xi is written as ( s – i )h.

Finally, the above expression for Newton polynomial above becomes:

N(x) = [y0] + [ y0, y1]sh + . . . + [y0, y1, . . . .yk] s(s – 1) . . . (s – k +1) hk

which is called Newton’s forward difference formula.

If the nodes are recorded from backward as xk, xk-1, . . . , x0

The Newton’s Polynomial can be expresses as:

N(x) = [yk] + [yk, yk-1] (x – xk) + . . . + [yk, yk-1, . . . y0] (x – xk) ( x – xk-1) . . . (x – x1)

If the xk, xk-1, . . .  . x0 are equally spaced and x = xk + sh and xi = xk– ( k –i)h for i = 0, 1, . . k

Now, Newton’s polynomial becomes:

N(x) = [yk] + [ yk, yk-1]sh + . . . + [ yk, yk-1, . . . .y0]s(s+1) . . . (s+ k – 1) hk

which is called Newton’s Backward Difference Formula.

Newton’s Interpolation in MATLAB:

Here are two different MATLAB codes for Newton’s forward as well as backward interpolation, written on the basis of aforementioned derivation cum formula.

Forward Interpolation using MATLAB:

The above source code for Newton’s Interpolation using forward difference formula doesn’t need any input value. All the input values required for the interpolation are embedded within the source code. The values of x and y used in above source code are 0 2 4 7 10 12 and 20 20 12 7 6 6 respectively. The sample output of the program is given below:

Backward Interpolation using MATLAB:

The above source code in MATLAB for Newton’s interpolation by using backward difference formula is to solve the following data:

X: 0 8 16 24 32 40

Y :14.621 11.843 9.870 8.418 7.305 6.413

Since, all the input data are already defined in the source code, the user doesn’t need to input any value to the program while running. The sample output of the above Matlab code is given below:

If you have any questions regarding the above two Newton’s interpolation techniques, their derivation or MATLAB programs, bring them up from the comments section. You can find more Numerical Methods tutorial using MATLAB here.

 1234567891011121314151617181920212223242526272829303132333435363738 %Newton’sForwardDifferenceFormulaMATLABProgram x=[02471012];% inputting values of x fx=[202012766];% inputting values of ydt=zeros(6,10);% function fori=1:6dt(i,1)=x(i);% for loop dt(i,2)=fx(i);% calling function endn=5;% number of iterations forj=3:10fori=1:ndt(i,j)=dt(i+1,j-1)-dt(i,j-1)endn=n-1;endh=x(2)-x(1)% finding the value of hxp=1.5;% defining the value of xp fori=1:5q=(xp-x(i))/h;% calculating number of intervals if(q>0&&q<1)p=q;endendpl=xp-(p*h)fori=1:5if(l==x(i))r=i;endend% calculating different value of yf0=fx(r);f01=dt(r,3);f02=dt(r,(3+1));f03=dt((r),(3+2));f04=dt((r),(3+3));%usingtheforwardinterpolationformula fp=(f0)+((p*f01)+(p*(p-1)*f02)/(2))+((p*(p-1)*(p-2)*f03)/(6))+((p*(p-1)*(p-2)*(p-3)*f04)/(24))
 12345678910111213141516171819202122232425262728293031323334353637383940 %Newton’sBackwardDifferenceFormulaMATLABProgram x=[0816243240];% inputting the values of x fx=[14.62111.8439.8708.4187.3056.413];% inputting the value of y dt=zeros(6,7);% declaring function fori=1:6% stating loop dt(i,1)=x(i);dt(i,2)=fx(i);endn=5;forj=3:7fori=1:n% using for loop dt(i,j)=dt(i+1,j-1)-dt(i,j-1)% defining dt endn=n-1;endh=x(2)-x(1)% finding the value of hxp=27;% defining xpfori=1:6q=(xp-x(i))/h;if(q>0&&q<1)p=q;endendpl=xp-(p*h)fori=1:6if(l==x(i))r=i;endend%findingdifferentvalueofy f0=fx(r);f01=dt((r-1),3);f02=dt((r-2),(3+1));f03=dt((r-3),(3+2));f04=dt((r-4),(3+3));%usingbackwarddifferenceformula fp=(f0)+((p*f01)+(p*(p+1)*f02)/(2))+((p*(p+1)*(p+2)*f03)/(6))

Rajendra Bohara