Up until now, I have been trying to obtain an expression for an InterpolatingFunction obtained from NDSolve, by using the function Fit like this:
xTab = Table[{t, var[t]}, {t, 0, 2.0, 0.01}];
xFit = Fit[xTab, {1, x, x^2, x^3, x^4, x^5}, x]
giving the an expression as the following one:
0.359718 - 7.45916 x + 28.9826 x^2 - 38.8259 x^3 + 20.7638 x^4 -
3.81347 x^5
However, good approximations are dependent on the particular shape of each curve, and in this case, when we plot the original curve (blue) versus de Fit version of it (gold), we see the evident error
I am aware that I could add functions/terms in the Fit function like higher order polynomials or even trigonometric functions to improve the interpolation approximation, however the InterpolatingFunction at hand is (apparently) already an Hermite interpolating function of order 3:
How can I extract an expression for this particular InterpolatingFunction?



varwas constructed withInterpolation[data], for some data, then it's a piecewise polynomial interpolation of the form in the question linked by @ChrisK. If you got it fromNDSolve, the form is probably different. In all cases, it's a piecewise function with degree-3 polynomial pieces, probably a lot of pieces if you got it fromNDSolve. What do you want to do with the algebraic expression? There may be better alternatives. – Michael E2 Jan 10 '20 at 18:49yFN = NDSolveValue[{y''[x] + x y[x] == 0, y[0] == 1, y'[0] == 0}, y, {x, 0, 2}]displays the same information as yourvar, butPlot[{yFN'''''[x], yFN''''''[x]}, {x, 0, 2}, PlotLegends -> "Expressions"]shows thatyFNis a piecewise order-5 interpolation, not an order-3 one as its display claims. – Michael E2 Jan 10 '20 at 18:56