({{, (RefLink[Interpolation, paclet:ref/Interpolation])[{(Subscript[f, 1]),(Subscript[f, 2]),…}]
constructs an interpolation of the function values (Subscript[f, i]), assumed to correspond to x values 1, 2, … . }, {, (RefLink[Interpolation, paclet:ref/Interpolation])[{{(Subscript[x, 1]),(Subscript[f, 1])},{(Subscript[x, 2]),(Subscript[f, 2])},…}]
constructs an interpolation of the function values (Subscript[f, i]) corresponding to x values (Subscript[x, i]).}, {, (RefLink[Interpolation, paclet:ref/Interpolation])[{{{(Subscript[x, 1]),(Subscript[y, 1]),…},(Subscript[f, 1])},{{(Subscript[x, 2]),(Subscript[y, 2]),…},(Subscript[f, 2])},…}]
constructs an interpolation of multidimensional data.}, {, (RefLink[Interpolation, paclet:ref/Interpolation])[{{{(Subscript[x, 1]),…},(Subscript[f, 1]),(Subscript[df, 1]),…},…}]
constructs an interpolation that reproduces derivatives as well as function values.}, {, (RefLink[Interpolation, paclet:ref/Interpolation])[data,x]
find an interpolation of data at the point x.}})

OpenersNotesSection(Spacer1)Details and Options

(RefLink[Interpolation, paclet:ref/Interpolation]) returns an (RefLink[InterpolatingFunction, paclet:ref/InterpolatingFunction]) object, which can be used like any other pure function.

The interpolating function returned by (RefLink[Interpolation, paclet:ref/Interpolation])[data] is set up so as to agree with data at every point explicitly specified in data.

The function values (Subscript[f, i]) can be real or complex numbers, or arbitrary symbolic expressions.

The (Subscript[f, i]) can be lists or arrays of any dimension.

The function arguments (Subscript[x, i]), (Subscript[y, i]), etc. must be real numbers.

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}].

Partial derivatives not specified explicitly can be given as (RefLink[Automatic, paclet:ref/Automatic]).

(RefLink[Interpolation, paclet:ref/Interpolation]) works by fitting polynomial curves between successive data points.

The degree of the polynomial curves is specified by the option (RefLink[InterpolationOrder, paclet:ref/InterpolationOrder]).

The default setting is (RefLink[InterpolationOrder, paclet:ref/InterpolationOrder])->3.

You can do linear interpolation by using the setting (RefLink[InterpolationOrder, paclet:ref/InterpolationOrder])->1.

(RefLink[Interpolation, paclet:ref/Interpolation])[data] generates an (RefLink[InterpolatingFunction, paclet:ref/InterpolatingFunction]) object that returns values with the same precision as those in data.

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

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

OpenersPrimaryExamplesSection(Spacer1)Examples  (24)

OpenersExampleSection0(Spacer1)Basic Examples  (2)

Construct an approximate function that interpolates the data:

f=Interpolation[{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}]]

Find the interpolated value immediately:

Interpolation[{1,2,3,5,8,5},2.5]

OpenersExampleSection1(Spacer1)Scope  (4)

Interpolate between points at arbitrary x values:

Interpolation[{{0,0},{0.1,.3},{0.5,.6},{1,-.2},{2,3}}]

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

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

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

Form the interpolation:

Interpolation[%]

Plot the interpolated function:

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

Create a list of multidimensional data:

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

Create an approximate interpolating function:

f=Interpolation[%]

Plot the interpolating function:

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

Form an interpolation from data given as a (RefLink[TimeSeries, paclet:ref/TimeSeries]):

ts=TimeSeries[];

ListPlot[ts,Filling->Axis]

fun=Interpolation[ts,InterpolationOrder->3]

Plot the interpolated function:

Plot[fun[x],{x,ts["FirstTime"],ts["LastTime"]}]

OpenersExampleSection2(Spacer1)Generalizations & Extensions  (5)

Create data that includes derivatives at each point:

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

Construct an interpolation:

Interpolation[%]

Plot the interpolation:

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

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

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

Interpolation[%]

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

Compare with data that does not include gradients:

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

Interpolation[%]

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

Also include tensors of second derivatives:

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

Interpolation[%]

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

Create a vector-valued (RefLink[InterpolatingFunction, paclet:ref/InterpolatingFunction]) of one variable from vector-valued data:

data = {{{0.},{1.,2.}}, {{1.2},{3.,4.}},{{2.1},{5.,4.}},{{3.},{0.,4.}}};

fun = Interpolation[data]

The value is a vector:

fun[1.5]

(RefLink[Plot, paclet:ref/Plot]) will show both components:

Plot[fun[t],{t,0,3}]

Create a vector-valued (RefLink[InterpolatingFunction, paclet:ref/InterpolatingFunction]) of two variables from vector-valued data:

data = Flatten[Table[{{x,y},{x Sin[π y], y Cos[π x],Tan[π x y]}},{x,0,1,.2},{y,0,1,.2}],1];

fun = Interpolation[data]

The value is a vector:

fun[.5,.5]

(RefLink[Plot3D, paclet:ref/Plot3D]) will show all three components:

Plot3D[fun[x,y],{x,0,1},{y,0,1}]

A single component may be plotted using (RefLink[Part, paclet:ref/Part]):

DensityPlot[Part[fun[x,y],3],{x,0,1},{y,0,1}]

Derivatives may also be included for Hermite interpolation:

jacobian = D[{x Sin[π y], y Cos[π x],Tan[π x y]},{{x,y}}]

With[{j = jacobian},ddata = Flatten[Table[{{x,y},{x Sin[π y], y Cos[π x],Tan[π x y]}, j},{x,0,1,.2},{y,0,1,.2}],1]];

hfun = Interpolation[ddata]

OpenersExampleSection3(Spacer1)Options  (5)

OpenersExampleSubsection0(Spacer1)InterpolationOrder  (3)

Make a zeroth-order interpolation:

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

Make a linear interpolation:

Plot[Interpolation[{1,5,7,2,3,1},InterpolationOrder->1][x],{x,1,6}]

Make a quadratic interpolation:

Plot[Interpolation[{1,5,7,2,3,1},InterpolationOrder->2][x],{x,1,6}]

OpenersExampleSubsection1(Spacer1)Method  (1)

Compare splines with piecewise Hermite interpolation for random data:

data = Transpose[{Range[0,10]/10,RandomReal[1,11]}];

sp = Interpolation[data, Method->"Spline"]

he = Interpolation[data, 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  (1)

Make an interpolating function that repeats periodically:

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

OpenersExampleSection4(Spacer1)Applications  (2)

Interpolate random data:

f=Interpolation[RandomReal[1,20]]

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

Find a continuous interpolation of the GCD function:

f=Interpolation[Flatten[Table[{{x,y},GCD[x,y]},{x,20},{y,20}],1]]

DensityPlot[f[x,y],{x,1,20},{y,1,20}]

OpenersExampleSection5(Spacer1)Properties & Relations  (2)

The interpolating function always goes through the data points:

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

f=Interpolation[data]

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

Find the integral of an interpolating function:

f=Interpolation[{1,2,3,-8,2,3}]

Integrate[f[x],x]

Plot the interpolating function and its integral:

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

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

OpenersExampleSection6(Spacer1)Possible Issues  (3)

Extrapolation is attempted to go beyond the original data:

Interpolation[{1,2,4,-2,1}]

Table[%[i],{i,6}]

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

Interpolation[{1,2,4}]

With a lower order, fewer points are needed:

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

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

f=Interpolation[RandomReal[1,10]]

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

OpenersExampleSection7(Spacer1)Neat Examples  (1)

Interpolate the sequence of primes:

f=Interpolation[Table[Prime[n],{n,30}]]

Plot[f[n]-f[n-1],{n,2,30}]

({{DocumentationFooterIconsRelatedFunction.png, ({{See Also}, {(RefLink[ListInterpolation, paclet:ref/ListInterpolation])  ▪  (RefLink[FunctionInterpolation, paclet:ref/FunctionInterpolation])  ▪  (RefLink[InterpolatingPolynomial, paclet:ref/InterpolatingPolynomial])  ▪  (RefLink[Fit, paclet:ref/Fit])  ▪  (RefLink[FindFit, paclet:ref/FindFit])  ▪  (RefLink[Quantile, paclet:ref/Quantile])  ▪  (RefLink[Nearest, paclet:ref/Nearest])  ▪  (RefLink[InterpolatingFunction, paclet:ref/InterpolatingFunction])  ▪  (RefLink[Piecewise, paclet:ref/Piecewise])  ▪  (RefLink[BSplineFunction, paclet:ref/BSplineFunction])  ▪  (RefLink[BezierFunction, paclet:ref/BezierFunction])  ▪  (RefLink[ListLinePlot, paclet:ref/ListLinePlot])  ▪  (RefLink[ListPlot3D, paclet:ref/ListPlot3D])  ▪  (RefLink[FindSequenceFunction, paclet:ref/FindSequenceFunction])  ▪  (RefLink[SequencePredict, paclet:ref/SequencePredict])}})}})

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

({{DocumentationFooterIconsRelatedGuide.png, ({{Related Guides}, {▪(RefLinkPlain[Curve Fitting & Approximate Functions, paclet:guide/CurveFittingAndApproximateFunctions])}, {▪(RefLinkPlain[Splines, paclet:guide/Splines])}, {▪(RefLinkPlain[Signal Processing, paclet:guide/SignalProcessing])}, {▪(RefLinkPlain[Time Series Processing, paclet:guide/TimeSeries])}, {▪(RefLinkPlain[Numerical Data, paclet:guide/NumericalData])}})}})