Skip to main content
deleted 25 characters in body
Source Link

There is no documented built-in way to convert the InterpolatingFunction object into explicit Piecewise form (thanks to @MichaelE2 for the link!). So the only possibility to get an explicit interpolating function is to re-implement the built-intin Interpolation in the high-level Mathematica language. I have already done this for the built-in "Spline" method with InterpolationOrder -> 2 (quadricquadratic spline interpolation with splicing points in the middle of adjacent interpolation points). Spline interpolation in general gives much better results than the default "Hermite" method.

You can use my implementation of quadric spline interpolation in MathemeticaMathematica to produce an explicit Piecewise function interpolating your data (as opposed to the built-in, it supports arbitrary precision!):

data = Transpose[{Range[Length[#]], #}] &@{2, 5, 9, 15, 22, 33, 50, 70, 100, 145};
spline[\[FormalX]_] = makeSpline[toSplineData[data], \[FormalX]]

screenshot

Here is a comparison with the original data and with the built-in Interpolation:

Table[data[[x, 2]] - spline[x], {x, 10}]
f = Interpolation[data, Method -> "Spline", InterpolationOrder -> 2];
Table[f[x] - spline[x], {x, 10}]
Plot[(f[x] - spline[x])/spline[x], {x, 1, 10}, PlotRange -> All]
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
{0., 0., 0., 1.77636*10^-15, 0., 0., 0., 0., 0., 0.}

enter image description hereplot

There is no documented built-in way to convert the InterpolatingFunction object into explicit Piecewise form (thanks to @MichaelE2 for the link!). So the only possibility to get an explicit interpolating function is to re-implement the built-int Interpolation in the high-level Mathematica language. I have already done this for the built-in "Spline" method with InterpolationOrder -> 2 (quadric spline interpolation with splicing points in the middle of adjacent interpolation points). Spline interpolation in general gives much better results than the default "Hermite" method.

You can use my implementation of quadric spline interpolation in Mathemetica to produce an explicit Piecewise function interpolating your data (as opposed to the built-in, it supports arbitrary precision!):

data = Transpose[{Range[Length[#]], #}] &@{2, 5, 9, 15, 22, 33, 50, 70, 100, 145};
spline[\[FormalX]_] = makeSpline[toSplineData[data], \[FormalX]]

screenshot

Here is a comparison with the original data and with the built-in Interpolation:

Table[data[[x, 2]] - spline[x], {x, 10}]
f = Interpolation[data, Method -> "Spline", InterpolationOrder -> 2];
Table[f[x] - spline[x], {x, 10}]
Plot[(f[x] - spline[x])/spline[x], {x, 1, 10}, PlotRange -> All]
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
{0., 0., 0., 1.77636*10^-15, 0., 0., 0., 0., 0., 0.}

enter image description here

There is no documented built-in way to convert the InterpolatingFunction object into explicit Piecewise form (thanks to @MichaelE2 for the link!). So the only possibility to get an explicit interpolating function is to re-implement the built-in Interpolation in the high-level Mathematica language. I have already done this for the built-in "Spline" method with InterpolationOrder -> 2 (quadratic spline interpolation with splicing points in the middle of adjacent interpolation points). Spline interpolation in general gives much better results than the default "Hermite" method.

You can use my implementation of quadric spline interpolation in Mathematica to produce an explicit Piecewise function interpolating your data (as opposed to the built-in, it supports arbitrary precision!):

data = Transpose[{Range[Length[#]], #}] &@{2, 5, 9, 15, 22, 33, 50, 70, 100, 145};
spline[\[FormalX]_] = makeSpline[toSplineData[data], \[FormalX]]

screenshot

Here is a comparison with the original data and with the built-in Interpolation:

Table[data[[x, 2]] - spline[x], {x, 10}]
f = Interpolation[data, Method -> "Spline", InterpolationOrder -> 2];
Table[f[x] - spline[x], {x, 10}]
Plot[(f[x] - spline[x])/spline[x], {x, 1, 10}, PlotRange -> All]
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
{0., 0., 0., 1.77636*10^-15, 0., 0., 0., 0., 0., 0.}

plot

replaced http://mathematica.stackexchange.com/ with https://mathematica.stackexchange.com/
Source Link

There is no documented built-in way to convert the InterpolatingFunction object into explicit Piecewise form (thanks to @MichaelE2 for the link!). So the only possibility to get an explicit interpolating function is to re-implement the built-int Interpolation in the high-level Mathematica language. I have already done this for the built-in "Spline" method with InterpolationOrder -> 2 (quadric spline interpolation with splicing points in the middle of adjacent interpolation points). Spline interpolation in general gives much better results than the default "Hermite" method.

You can use my implementation of quadric spline interpolation in Mathemeticamy implementation of quadric spline interpolation in Mathemetica to produce an explicit Piecewise function interpolating your data (as opposed to the built-in, it supports arbitrary precision!):

data = Transpose[{Range[Length[#]], #}] &@{2, 5, 9, 15, 22, 33, 50, 70, 100, 145};
spline[\[FormalX]_] = makeSpline[toSplineData[data], \[FormalX]]

screenshot

Here is a comparison with the original data and with the built-in Interpolation:

Table[data[[x, 2]] - spline[x], {x, 10}]
f = Interpolation[data, Method -> "Spline", InterpolationOrder -> 2];
Table[f[x] - spline[x], {x, 10}]
Plot[(f[x] - spline[x])/spline[x], {x, 1, 10}, PlotRange -> All]
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
{0., 0., 0., 1.77636*10^-15, 0., 0., 0., 0., 0., 0.}

enter image description here

There is no documented built-in way to convert the InterpolatingFunction object into explicit Piecewise form (thanks to @MichaelE2 for the link!). So the only possibility to get an explicit interpolating function is to re-implement the built-int Interpolation in the high-level Mathematica language. I have already done this for the built-in "Spline" method with InterpolationOrder -> 2 (quadric spline interpolation with splicing points in the middle of adjacent interpolation points). Spline interpolation in general gives much better results than the default "Hermite" method.

You can use my implementation of quadric spline interpolation in Mathemetica to produce an explicit Piecewise function interpolating your data (as opposed to the built-in, it supports arbitrary precision!):

data = Transpose[{Range[Length[#]], #}] &@{2, 5, 9, 15, 22, 33, 50, 70, 100, 145};
spline[\[FormalX]_] = makeSpline[toSplineData[data], \[FormalX]]

screenshot

Here is a comparison with the original data and with the built-in Interpolation:

Table[data[[x, 2]] - spline[x], {x, 10}]
f = Interpolation[data, Method -> "Spline", InterpolationOrder -> 2];
Table[f[x] - spline[x], {x, 10}]
Plot[(f[x] - spline[x])/spline[x], {x, 1, 10}, PlotRange -> All]
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
{0., 0., 0., 1.77636*10^-15, 0., 0., 0., 0., 0., 0.}

enter image description here

There is no documented built-in way to convert the InterpolatingFunction object into explicit Piecewise form (thanks to @MichaelE2 for the link!). So the only possibility to get an explicit interpolating function is to re-implement the built-int Interpolation in the high-level Mathematica language. I have already done this for the built-in "Spline" method with InterpolationOrder -> 2 (quadric spline interpolation with splicing points in the middle of adjacent interpolation points). Spline interpolation in general gives much better results than the default "Hermite" method.

You can use my implementation of quadric spline interpolation in Mathemetica to produce an explicit Piecewise function interpolating your data (as opposed to the built-in, it supports arbitrary precision!):

data = Transpose[{Range[Length[#]], #}] &@{2, 5, 9, 15, 22, 33, 50, 70, 100, 145};
spline[\[FormalX]_] = makeSpline[toSplineData[data], \[FormalX]]

screenshot

Here is a comparison with the original data and with the built-in Interpolation:

Table[data[[x, 2]] - spline[x], {x, 10}]
f = Interpolation[data, Method -> "Spline", InterpolationOrder -> 2];
Table[f[x] - spline[x], {x, 10}]
Plot[(f[x] - spline[x])/spline[x], {x, 1, 10}, PlotRange -> All]
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
{0., 0., 0., 1.77636*10^-15, 0., 0., 0., 0., 0., 0.}

enter image description here

added 77 characters in body
Source Link
Alexey Popkov
  • 62.3k
  • 7
  • 154
  • 375

There is no documented built-in way to convert the InterpolatingFunction object into explicit Piecewise form (thanks to @MichaelE2 for the link!). So the only possibility to get an explicit interpolating function is to re-implement the built-int Interpolation in the high-level Mathematica language. I have already done this for the built-in "Spline" method with InterpolationOrder -> 2 (quadric spline interpolation with splicing points in the middle of adjacent interpolation points). Spline interpolation in general gives much better results than the default "Hermite" method.

You can use my implementation of quadric spline interpolation in Mathemetica to produce an explicit Piecewise function interpolating your data (as opposed to the built-in, it supports arbitrary precision!):

data = Transpose[{Range[Length[#]], #}] &@{2, 5, 9, 15, 22, 33, 50, 70, 100, 145};
spline[\[FormalX]_] = makeSpline[toSplineData[data], \[FormalX]]

screenshot

Here is a comparison with the original data and with the built-in Interpolation:

Table[data[[x, 2]] - spline[x], {x, 10}]
f = Interpolation[data, Method -> "Spline", InterpolationOrder -> 2];
Table[f[x] - spline[x], {x, 10}]
Plot[f[x]Plot[(f[x] - spline[x])/spline[x], {x, 1, 10}, PlotRange -> All]
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
{0., 0., 0., 1.77636*10^-15, 0., 0., 0., 0., 0., 0.}
 

plotenter image description here

There is no documented built-in way to convert the InterpolatingFunction object into explicit Piecewise form (thanks to @MichaelE2 for the link!). So the only possibility to get an explicit interpolating function is to re-implement the built-int Interpolation in the high-level Mathematica language. I have already done this for the built-in "Spline" method with InterpolationOrder -> 2 (quadric spline interpolation with splicing points in the middle of adjacent interpolation points). Spline interpolation in general gives much better results than the default "Hermite" method.

You can use my implementation of quadric spline interpolation in Mathemetica to produce an explicit Piecewise function interpolating your data (as opposed to the built-in, it supports arbitrary precision!):

data = Transpose[{Range[Length[#]], #}] &@{2, 5, 9, 15, 22, 33, 50, 70, 100, 145};
spline[\[FormalX]_] = makeSpline[toSplineData[data], \[FormalX]]

screenshot

Here is a comparison with the original data and with the built-in Interpolation:

Table[data[[x, 2]] - spline[x], {x, 10}]
f = Interpolation[data, Method -> "Spline", InterpolationOrder -> 2];
Table[f[x] - spline[x], {x, 10}]
Plot[f[x] - spline[x], {x, 1, 10}, PlotRange -> All]
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
{0., 0., 0., 1.77636*10^-15, 0., 0., 0., 0., 0., 0.}
 

plot

There is no documented built-in way to convert the InterpolatingFunction object into explicit Piecewise form (thanks to @MichaelE2 for the link!). So the only possibility to get an explicit interpolating function is to re-implement the built-int Interpolation in the high-level Mathematica language. I have already done this for the built-in "Spline" method with InterpolationOrder -> 2 (quadric spline interpolation with splicing points in the middle of adjacent interpolation points). Spline interpolation in general gives much better results than the default "Hermite" method.

You can use my implementation of quadric spline interpolation in Mathemetica to produce an explicit Piecewise function interpolating your data (as opposed to the built-in, it supports arbitrary precision!):

data = Transpose[{Range[Length[#]], #}] &@{2, 5, 9, 15, 22, 33, 50, 70, 100, 145};
spline[\[FormalX]_] = makeSpline[toSplineData[data], \[FormalX]]

screenshot

Here is a comparison with the original data and with the built-in Interpolation:

Table[data[[x, 2]] - spline[x], {x, 10}]
f = Interpolation[data, Method -> "Spline", InterpolationOrder -> 2];
Table[f[x] - spline[x], {x, 10}]
Plot[(f[x] - spline[x])/spline[x], {x, 1, 10}, PlotRange -> All]
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
{0., 0., 0., 1.77636*10^-15, 0., 0., 0., 0., 0., 0.}

enter image description here

added 113 characters in body
Source Link
Alexey Popkov
  • 62.3k
  • 7
  • 154
  • 375
Loading
added 251 characters in body
Source Link
Alexey Popkov
  • 62.3k
  • 7
  • 154
  • 375
Loading
deleted 2 characters in body
Source Link
Alexey Popkov
  • 62.3k
  • 7
  • 154
  • 375
Loading
added 17 characters in body
Source Link
Alexey Popkov
  • 62.3k
  • 7
  • 154
  • 375
Loading
added 691 characters in body
Source Link
Alexey Popkov
  • 62.3k
  • 7
  • 154
  • 375
Loading
Source Link
Alexey Popkov
  • 62.3k
  • 7
  • 154
  • 375
Loading