# Better fit for points with exaggerated deviations

I used the InterpolatingPolynomial function to get a polynomial that meets my points.

But I noticed that there is a deviation in the final intervals.

ClearAll["Global*"]
dados16={{10,0.37},{15,0.47},{20,0.54},{25,0.61},{30,0.70},{40,0.80},{50,0.90},{60,1.01},{70,1.10},{80,1.20},{90,1.31},{100,1.42},{110,1.53}};
B16[l_]=InterpolatingPolynomial[dados16,l]//Expand;
Plot[B16[l],{l,0,110},Epilog->{{Red,PointSize[.02],Point[dados16]}}]


What would be the best function to have a better result?

• Can you use Interpolation or you do want to have the symbolic formula of the polynomial? Can you use other types of polynomials, say, found with FindFormula? – Anton Antonov Sep 19 at 17:27
• Yes. Could be through these functions that commented. Could you demonstrate in an answer? – LCarvalho Sep 19 at 17:47

## 2 Answers

Basically in all variants below we are trying to not let high degree polynomials be used. (Less than degree 12 produced by InterpolatingPolynomial.)

## Interpolation

Using Interpolation instead of InterpolatingPolynomial.

Clear[B16]
B16[l_] :=
Evaluate[Interpolation[dados16, l, InterpolationOrder -> 2] //
Expand];
Plot[B16[l], {l, Min[dados16[[All, 1]]], Max[dados16[[All, 1]]]},
Epilog -> {{Red, PointSize[.02], Point[dados16]}}]


## FindFormula

FindFormula does not give better result than InterpolatingPolynomial. (Obviously "just" a fit.)

Clear[FF]
FF[x_] :=
Evaluate[FindFormula[dados16, x, PerformanceGoal -> "Speed"]];
Plot[FF[l], {l, Min[dados16[[All, 1]]], Max[dados16[[All, 1]]]},
Epilog -> {{Red, PointSize[.02], Point[dados16]}}, PlotRange -> All]


## Chebyshev polynomials

Better results are obtained with Chebyshev polynomials (ChebyshevT). (If of interest I can expand on that.)

• The goal was to get a function that would give me more accurate values. I tested B16 [32] and I got a satisfactory value: 0.728533. Thanks for your reply – LCarvalho Sep 19 at 19:25
• Sure, no problem! – Anton Antonov Sep 19 at 19:39
• @Anton how exactly did you do it with ChebyshevT? Thanks – floyd17 Sep 22 at 10:51
• @floyd17 The software monad QRMon has functions for doing Quantile Regression and Least Squares Fit using a user provided basis of functions, with a default basis made with Chebyshev polynomials. See the section "Default basis to fit (using Chebyshev polynomials)" in this QRMon document. – Anton Antonov Sep 22 at 13:00

Does the function have to go through all of the points? If not, how about fitting instead of interpolating.

dados16 = {{10, 0.37}, {15, 0.47}, {20, 0.54}, {25, 0.61}, {30, 0.70}, {40, 0.80},{50, 0.90}, {60, 1.01}, {70, 1.10}, {80, 1.20}, {90, 1.31}, {100, 1.42}, {110, 1.53}};

fit = Fit[dados16, {1, x, x^(1/2)}, x]


0.104065 + 0.0701194 Sqrt[x] + 0.00609645 x

Plot[fit, {x, 0, 110},
Epilog -> {{Red, PointSize[.02], Point[dados16]}}]
`