({{, (RefLink[ListInterpolation, paclet:ref/ListInterpolation])[array]
constructs an (RefLink[InterpolatingFunction, paclet:ref/InterpolatingFunction]) object that represents an approximate function that interpolates the array of values given. }, {, (RefLink[ListInterpolation, paclet:ref/ListInterpolation])[array,{{(Subscript[x, min]),(Subscript[x, max])},{(Subscript[y, min]),(Subscript[y, max])},…}]
specifies the domain of the grid from which the values in array are assumed to come. }})

OpenersNotesSection(Spacer1)Details and Options

You can replace {(Subscript[x, min]),(Subscript[x, max])} etc. by explicit lists of positions for grid lines. The grid lines are otherwise assumed to be equally spaced.

(RefLink[ListInterpolation, paclet:ref/ListInterpolation])[array] assumes grid lines at integer positions in each direction.

array can be an array in any number of dimensions, corresponding to a list with any number of levels of nesting.

(RefLink[ListInterpolation, paclet:ref/ListInterpolation])[array,domain] generates an (RefLink[InterpolatingFunction, paclet:ref/InterpolatingFunction]) object that returns values with the same precision as those in {array,domain}.

(RefLink[ListInterpolation, paclet:ref/ListInterpolation]) supports a (RefLink[Method, paclet:ref/Method]) option. Possible settings include "Spline" for spline interpolation and "Hermite" for Hermite interpolation.

OpenersPrimaryExamplesSection(Spacer1)Examples  (23)

OpenersExampleSection0(Spacer1)Basic Examples  (3)

Construct an approximate function that interpolates the data:

f=ListInterpolation[{1,2,3,5,8,5}]

Apply the function to find interpolated values:

f[2.5]

Plot the interpolation function:

Plot[f[x],{x,1,6}]

Compare with the original data:

Show[%,ListPlot[{1,2,3,5,8,5}]]

Construct an approximate function with the x values equally spaced on the interval [0,1]:

g=ListInterpolation[{1,2,3,5,8,5},{{0,1}}]

Apply the function to find interpolated values:

g[0.5]

Plot the interpolation function with the original data:

Plot[g[x],{x,0,1},Epilog->MapIndexed[Point[{(#2[[1]]-1)/5,#1}]&,{1,2,3,5,8,5}]]

Construct an approximate function that interpolates the values from an array of values:

f=ListInterpolation[Table[Sin[x y],{x,0,1,.25},{y,0,2,.25}],{{0,1},{0,2}}]

Plot the function with the original data:

Show[{Plot3D[f[x,y],{x,0,1},{y,0,2}],Graphics3D[{Red,PointSize[0.03],Table[Point[{x,y,Sin[x y]}],{x,0,1,.25},{y,0,2,.25}]}]}]

OpenersExampleSection1(Spacer1)Scope  (4)

Interpolate between points at arbitrary x values:

f=ListInterpolation[{0,.3,.6,-.2,3},{{0,.1,.5,1,2}}]

Plot[f[x],{x,0,2}]

The x values may be included in the data directly:

Plot[ListInterpolation[{{{0},0},{{0.1},0.3},{{0.5},0.6},{{1},-0.2},{{2},3}}][x],{x,0,2}]

Create data with (RefLink[Table, paclet:ref/Table]):

Table[{{x},Sin[4x]},{x,0,3,0.5}]

Form the interpolation:

f=ListInterpolation[%]

Plot the interpolated function:

Plot[f[x],{x,0,3}]

Create a list of multidimensional data:

Table[LCM[x,y],{x,4},{y,4}]

Create an approximate interpolating function:

f=ListInterpolation[%]

Plot the interpolating function:

ContourPlot[f[x,y],{x,1,4},{y,1,4}]

OpenersExampleSection2(Spacer1)Generalizations & Extensions  (3)

Create data including derivative values:

Table[Evaluate[{Sin[8x],D[Sin[8 x],x]}],{x,0,3,0.5}]

Construct an interpolation:

f=ListInterpolation[%,{{0,3}}]

Plot the interpolation:

Plot[f[x],{x,0,3}]

Create 2D data that includes a gradient vector at each point:

Table[Evaluate[{Sin[x y],D[Sin[x y],{{x,y}}]}],{x,0,3,1.},{y,0,3,1.}]

f=ListInterpolation[%,{{0,3},{0,3}}]

ContourPlot[f[x,y],{x,0,3},{y,0,3}]

Compare with data that does not include gradients:

Table[Sin[x y],{x,0,3,1.},{y,0,3,1.}]

f=ListInterpolation[%,{{0,3},{0,3}}]

ContourPlot[f[x,y],{x,0,3},{y,0,3}]

Also include tensors of second derivatives:

Table[Evaluate[{Sin[x y],D[Sin[x y],{{x,y}}],D[Sin[x y],{{x,y},2}]}],{x,0,3,1.},{y,0,3,1.}]

f=ListInterpolation[%,{{0,3},{0,3}}]

ContourPlot[f[x,y],{x,0,3},{y,0,3}]

OpenersExampleSection3(Spacer1)Options  (7)

OpenersExampleSubsection0(Spacer1)InterpolationOrder  (4)

Make a 0(^th)-order interpolation:

Plot[ListInterpolation[{1,5,7,2,3,1},{{0,1}},InterpolationOrder->0][x],{x,0,1}]

Make a linear interpolation:

Plot[ListInterpolation[{1,5,7,2,3,1},{{0,1}},InterpolationOrder->1][x],{x,0,1}]

Make a quadratic interpolation:

Plot[ListInterpolation[{1,5,7,2,3,1},{{0,1}},InterpolationOrder->2][x],{x,0,1}]

Make an interpolation linear in the first dimension and quadratic in the second:

Plot3D[ListInterpolation[IdentityMatrix[4],{{0,1},{0,1}},InterpolationOrder->{1,2}][x,y],{x,0,1},{y,0,1}]

OpenersExampleSubsection1(Spacer1)Method  (1)

Compare splines with piecewise Hermite interpolation for random data:

data = RandomReal[1,10];

sp = ListInterpolation[data, {{0,1}},Method->"Spline"]

he = ListInterpolation[data, {{0,1}},Method->"Hermite"]

The curves appear close, but the spline has a continuous derivative:

Row[{Plot[{sp[x],he[x]},{x,0,1},PlotRange->All],
Plot[{sp'[x],he'[x]},{x,0,1},PlotRange->All]}]

OpenersExampleSubsection2(Spacer1)PeriodicInterpolation  (2)

Make an interpolating function that repeats periodically:

Plot[ListInterpolation[{1,5,7,2,3,1},{{0,2 Pi}},PeriodicInterpolation->True][x],{x,1,20}]

Make an interpolating function that repeats periodically in the second dimension only:

Plot3D[ListInterpolation[PadRight[IdentityMatrix[4],{4,6},0,{0,1}],{{0,1},{0,1}},PeriodicInterpolation->{False,True}][x,y],{x,0,1},{y,-1,2}]

OpenersExampleSection4(Spacer1)Properties & Relations  (2)

The interpolating function always goes through the data points:

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

f=ListInterpolation[data]

Show[ListPlot[data],Plot[f[x],{x,1,6}]]

Find the integral of an interpolating function:

f=ListInterpolation[{1,2,3,-3,-2,-1,0,1},{{0,1}}]

fi[x_]=Integrate[f[x],x]

Plot the interpolating function and its integral:

Plot[{f[x],fi[x]},{x,0,1}]

Find a root of the integral:

r=FindRoot[fi[x],{x,.5}]

OpenersExampleSection5(Spacer1)Possible Issues  (4)

Beyond the domain defined by the original data extrapolation is used:

f=ListInterpolation[Table[Sin[2 Pi x],{x,0,1,.1}],{{0,1}}]

f[1.5]

A plot shows the inaccuracy of extrapolation:

Plot[{Sin[2 Pi x],f[x]},{x,-.5,1.5}]

With the default choice of order, at least 4 points are needed in each dimension:

ListInterpolation[{1,2,4}]

With a lower order, fewer points are needed:

ListInterpolation[{1,2,4},InterpolationOrder->2]

The interpolation function will always be continuous, but may not be differentiable:

f=ListInterpolation[RandomReal[1,10],{{0,1}}]

Plot[Evaluate[{f[x],D[f[x],x]}],{x,0,1}]

If k derivatives are specified, the interpolation function will have a continuous k(^th) derivative:

f=ListInterpolation[RandomReal[1,{6,3}],{{0,25}}]

Plot[Evaluate[Table[D[f[x],{x,k}],{k,0,3}]],{x,0,25}]

({{DocumentationFooterIconsRelatedFunction.png, ({{See Also}, {(RefLink[Interpolation, paclet:ref/Interpolation])  ▪  (RefLink[FunctionInterpolation, paclet:ref/FunctionInterpolation])  ▪  (RefLink[ListContourPlot, paclet:ref/ListContourPlot])  ▪  (RefLink[Quantile, paclet:ref/Quantile])}})}})

({{DocumentationFooterIconsRelatedTutorial.png, ({{Tutorials}, {▪(RefLinkPlain[Approximate Functions and Interpolation, paclet:tutorial/ApproximateFunctionsAndInterpolation])}})}})

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