({{, (RefLink[InterpolatingPolynomial, paclet:ref/InterpolatingPolynomial])[{(Subscript[f, 1]),(Subscript[f, 2]),…},x]
constructs an interpolating polynomial in x which reproduces the function values (Subscript[f, i]) at successive integer values 1, 2, … of x. }, {, (RefLink[InterpolatingPolynomial, paclet:ref/InterpolatingPolynomial])[{{(Subscript[x, 1]),(Subscript[f, 1])},{(Subscript[x, 2]),(Subscript[f, 2])},…},x]
constructs an interpolating polynomial for the function values (Subscript[f, i]) corresponding to x values (Subscript[x, i]).}, {, (RefLink[InterpolatingPolynomial, paclet:ref/InterpolatingPolynomial])[{{{(Subscript[x, 1]),(Subscript[y, 1]),…},(Subscript[f, 1])},{{(Subscript[x, 2]),(Subscript[y, 2]),…},(Subscript[f, 2])},…},{x,y,…}]
constructs a multidimensional interpolating polynomial in the variables x, y, ….}, {, (RefLink[InterpolatingPolynomial, paclet:ref/InterpolatingPolynomial])[{{{(Subscript[x, 1]),…},(Subscript[f, 1]),(Subscript[df, 1]),…},…},{x,…}]
constructs an interpolating polynomial that reproduces derivatives as well as function values.}})

OpenersNotesSection(Spacer1)Details and Options

The function values (Subscript[f, i]) and sample points (Subscript[x, i]), etc. can be arbitrary real or complex numbers, and in 1D can be arbitrary symbolic expressions.

With a 1D list of data of length n, (RefLink[InterpolatingPolynomial, paclet:ref/InterpolatingPolynomial]) gives a polynomial of degree n-1.

With any given specified set of data, there are infinitely many possible interpolating polynomials; (RefLink[InterpolatingPolynomial, paclet:ref/InterpolatingPolynomial]) always tries to find the one with lowest total degree.

(RefLink[InterpolatingPolynomial, paclet:ref/InterpolatingPolynomial]) gives the interpolating polynomial in a Horner form, suitable for numerical evaluation.

Different elements in the data can have different numbers of derivatives specified.

For multidimensional data, the n(^th) derivative can be given as a tensor with a structure corresponding to (RefLink[D, paclet:ref/D])[f,{{x,y,…},n}]. »

(RefLink[InterpolatingPolynomial, paclet:ref/InterpolatingPolynomial]) allows any function value or derivative to be given as (RefLink[Automatic, paclet:ref/Automatic]), in which case it will attempt to fill in the necessary information from derivatives or other function values. »

The option setting (RefLink[Modulus, paclet:ref/Modulus])->n specifies that the interpolating polynomial should be found modulo n. »

OpenersPrimaryExamplesSection(Spacer1)Examples  (19)

OpenersExampleSection0(Spacer1)Basic Examples  (2)

Construct an interpolating polynomial for the squares:

InterpolatingPolynomial[{1,4,9,16},x]

Check the result:

Expand[%]

Construct an interpolating polynomial through three points:

InterpolatingPolynomial[{{-1,4},{0,2},{1,6}},x]

Check the result at a single point:

%/.x->0

OpenersExampleSection1(Spacer1)Scope  (3)

InterpolatingPolynomial[{4,7,2,8,9},x]

Show[Plot[%,{x,0,6}],ListPlot[{4,7,2,8,9}]]

Make the polynomial have derivative 0 when it has value 8:

InterpolatingPolynomial[{4,7,2,{8,0},9},x]

Show[Plot[%,{x,0,6}],ListPlot[{4,7,2,8,9}]]

Interpolate values depending on 2 variables:

InterpolatingPolynomial[{{{0,0},1},{{1,0},7},{{0,1},10},{{2,1},40},{{3,3},151},{{1,2},47}},{x,y}]

ContourPlot[%,{x,0,3},{y,0,3},Epilog->{Red,Map[Point,{{0,0},{1,0},{0,1},{2,1},{3,3},{1,2}}]}]

OpenersExampleSection2(Spacer1)Generalizations & Extensions  (3)

Make the polynomial have zero derivative at -1 and 1 without specifying the values there:

InterpolatingPolynomial[{{-1,Automatic,0},{0,1,1},{1,Automatic,0}},x]

Plot[%,{x,-1,1}]

Specify some of the partial derivatives in 2 dimensions:

InterpolatingPolynomial[{{{0,0},1,{2,3}},{{1,0},7},{{0,1},10,{Automatic,15}}},{x,y}]

Interpolate values and a gradient in 3 variables:

InterpolatingPolynomial[{{{1,2,3},4,{5,6,7}},{{3,2,1},0}},{x,y,z}]

OpenersExampleSection3(Spacer1)Options  (1)

OpenersExampleSubsection0(Spacer1)Modulus  (1)

Find a polynomial interpolating the given points in arithmetic mod 47:

p=InterpolatingPolynomial[{{0,1},{4,2},{9,3},{16,4}},x,Modulus->47]

The polynomial takes on the specified values mod 47:

p /. x->{0,4,9,16}

Mod[%,47]

OpenersExampleSection4(Spacer1)Applications  (5)

Construct a polynomial with roots a, b, and c:

InterpolatingPolynomial[{{0,1},{a,0},{b,0},{c,0}},x]

Factor[%]

Newton–Cotes integration formulas with n points:

TableForm[Table[
abc=Range[0,n-1]/(n-1);
Integrate[InterpolatingPolynomial[Table[{x,f[x]},{x,abc}],x],{x,0,1}],
{n,2,8}]]

Centered finite difference formula of order k for approximating the first derivative:

TableForm[Table[
abc=Range[-k/2,k/2];
Together[D[InterpolatingPolynomial[Table[{s,f[x+s h]},{s,abc}],s],s]/h /. s->0],
{k,2,10,2}]]

Interpolate to find the characteristic polynomial of a matrix:

m=RandomInteger[1,{6,6}]

InterpolatingPolynomial[Table[Det[m-λ IdentityMatrix[6]],{λ,11}],x]

Expand[%]===CharacteristicPolynomial[m,x]

Create a tensor product interpolation:

{m,n}={4,4};
{xc,yc}={Range[m],Range[n]};
zc=RandomInteger[{-9,9},{m,n}];

Create an interpolating polynomial for each fixed x value:

yinterp=Map[InterpolatingPolynomial[Transpose[{yc,#}],y]&,zc]

Show the interpolation curves in the y direction:

points=Graphics3D[{PointSize[Medium],Red,Point@Flatten[Table[{xc[[i]],yc[[j]],zc[[i,j]]},{i,m},{j,n}],1]}];

Show[ParametricPlot3D[Evaluate@Table[{xc[[i]],y,yinterp[[i]]},{i,m}],{y,1,n},BoxRatios->{1,1,0.4}],points]

Interpolate between the curves in the x direction:

xyinterp=InterpolatingPolynomial[Transpose[{xc,yinterp}],x]

Show the interpolating surface and data points:

Show[Plot3D[xyinterp,{x,1,m},{y,1,n}],points]

OpenersExampleSection5(Spacer1)Properties & Relations  (2)

The interpolating polynomial always goes through the data points:

data={1,2,3,5,8,5};

InterpolatingPolynomial[data,x]

% /. x->Range[6]

(RefLink[ListInterpolation, paclet:ref/ListInterpolation]) creates a tensor product interpolation:

{m,n}={5,6};
{xc,yc}={Range[m],Range[n]};
zc=RandomInteger[{-9,9},{m,n}];

Create a numerical (RefLink[InterpolatingFunction, paclet:ref/InterpolatingFunction]) object:

linterp=ListInterpolation[zc,{xc,yc},InterpolationOrder->{m-1,n-1}]

Create a symbolic polynomial by interpolating in each dimension separately:

yinterp=Map[InterpolatingPolynomial[Transpose[{yc,#}],y]&,zc];
interp=InterpolatingPolynomial[Transpose[{xc,yinterp}],x];

Verify that results agree with random data points:

Max[Abs[Table[interp-linterp[x,y],{x,RandomReal[{1,m},2m]},{y,RandomReal[{1,n},2n]}]]]

OpenersExampleSection6(Spacer1)Possible Issues  (3)

Runge's function:

f[x_]:=1/(1+25 x^2);

Sampling at evenly spaced intervals in the interval from -1 to 1:

points=Table[{x,f[x]},{x,-1,1,.1}];

The polynomial that interpolates these points has large oscillations:

Plot[Evaluate[InterpolatingPolynomial[points,x]],{x,-1,1},PlotRange->All,Epilog->{Red,Map[Point,points]}]

(RefLink[Interpolation, paclet:ref/Interpolation]) uses a lower-order piecewise polynomial that does not have this problem:

Interpolation[points]

Plot[%[x],{x,-1,1},Epilog->{Red,Map[Point,points]}]

When derivatives are specified without function values an interpolant may not be found:

InterpolatingPolynomial[{{-1,1},{0,Automatic,0},{1,-1}},x]

There is no quadratic polynomial that satisfies the interpolation conditions:

Expand[InterpolatingPolynomial[{{-1,1},{0,a,0},{1,-1}},x]]

Points with abscissas lying on a line in 2 dimensions:

data={{{0,0},1},{{1,1},2},{{2,2},4}};

In multiple dimensions an interpolant may not be found for some arrangements of points:

InterpolatingPolynomial[data,{x,y}]

This polynomial interpolates the data above, but has total degree 2:

InterpolatingPolynomial[{{0,1},{1,2},{2,4}},x]

({{DocumentationFooterIconsRelatedFunction.png, ({{See Also}, {(RefLink[Interpolation, paclet:ref/Interpolation])  ▪  (RefLink[FunctionInterpolation, paclet:ref/FunctionInterpolation])  ▪  (RefLink[Fit, paclet:ref/Fit])  ▪  (RefLink[Roots, paclet:ref/Roots])  ▪  (RefLink[InterpolatingFunction, paclet:ref/InterpolatingFunction])  ▪  (RefLink[FindSequenceFunction, paclet:ref/FindSequenceFunction])  ▪  (RefLink[FindGeneratingFunction, paclet:ref/FindGeneratingFunction])}})}})

({{DocumentationFooterIconsRelatedTutorial.png, ({{Tutorials}, {▪(RefLinkPlain[Algebraic Operations on Polynomials, paclet:tutorial/AlgebraicOperationsOnPolynomials])}})}})

({{DocumentationFooterIconsRelatedGuide.png, ({{Related Guides}, {▪(RefLinkPlain[Curve Fitting & Approximate Functions, paclet:guide/CurveFittingAndApproximateFunctions])}})}})