# How do I interpolate sparse data with a spline?

I have this data:

data =
{{0.2, 103}, {2, 13.9}, {20, 2.72}, {200, 0.8}, {2000, 0.401}, {20000, 0.433}}


Is there any way of finding value at $x=5$ using splines and not an interpolating polynomial?

• Interpolation[data, Method -> "Spline", InterpolationOrder -> 3] Dec 15, 2017 at 20:03
• recommend InterpolationOrder -> 1 here. With that data the higher order interpolation oscillates pretty wildly. Dec 15, 2017 at 20:31
• Interpolation and SplineFit are not the same : Interpolation[...,Method-> "Spline"...] returns a piecewise polynomial function x->y. SplineFit returns a parametric function t->{x,y}. This last function can represent a curve that goes in every directions, like a circle for example (x get greater, then smaller etc...). For one x there may be several y. Dec 15, 2017 at 20:47

I think I would rescale the domain (logarithmically) to get better spacing between nodes:

ifn = Evaluate[
Interpolation[
Transpose[{Log@data[[All, 1]], data[[All, 2]]}],
Method -> "Spline"
][Log@#]
] &;

LogLogPlot[{ifn[x]}, {x, 0.2, 20000},
Epilog -> {Red, PointSize[Medium], Point@Log@data}, PlotRange -> All] ifn
(*  4.83159  *)

• For me, it is still unclear if the OP wants piecewise interpolation or if he wants to interpolate the whole region with one function. Nowadays the questions are so vague and incomplete... +1 Dec 16, 2017 at 13:04
• @halirutan Thanks. I assumed "spline" meant spline and the original Q said "not InterpolatingPolynomial". I took it that the OP possibly didn't know the spline option to Interpolation. But if the question is a real problem, then probably what is wanted is linear interpolation, suggested by george2079, or splines with tension, which I don't think is built in M. The inflection points in my answer suggest the interpolation is not very accurate much past the point at $x=2$. Dec 16, 2017 at 15:30