4
$\begingroup$

I have a very weird problem:

I have a data list:

list1 = {{2.991592653589793`, 
0.9714808068326763`}, {3.001592653589793`, 
0.9752464325262729`}, {3.0115926535897932`, 
0.9751839638323045`}, {3.021592653589793`, 
0.9751260463868021`}, {3.0315926535897932`, 
0.9750726977562348`}, {3.041592653589793`, 
0.9750239340963618`}, {3.0515926535897933`, 
0.9749797701536178`}, {3.061592653589793`, 
0.9749402192661547`}, {3.0715926535897933`, 
0.9749052933651084`}, {3.081592653589793`, 
0.9748750029754825`}, {3.0915926535897933`, 
0.9748493572170551`}, {3.101592653589793`, 
0.9748283638052356`}, {3.1115926535897933`, 
0.9748120290516745`}, {3.121592653589793`, 
0.9748003578648844`}, {3.1315926535897933`, 
0.9747933537505974`}, {3.141592653589793`, 
0.9747910188121406`}, {3.151592653589793`, 
0.9747933537505988`}, {3.161592653589793`, 
0.9748003578648942`}, {3.171592653589793`, 
0.9748120290516763`}, {3.181592653589793`, 
0.974828363805238`}, {3.191592653589793`, 
0.9748493572170566`}, {3.201592653589793`, 0.9748750029754883`},
{3.211592653589793`, 0.9749052933651294`}, {3.221592653589793`, 
0.9749402192661758`}, {3.231592653589793`, 
0.9749797701536135`}, {3.241592653589793`, 
0.9750239340963711`}, {3.251592653589793`, 
0.9750726977562387`}, {3.2615926535897932`, 
0.9751260463868172`}, {3.271592653589793`, 
0.975183963832316`}, {3.2815926535897932`, 
0.9752464325262769`}, {3.291592653589793`, 0.9714808068327093`}};

Then I would like to fit a quadratic function:

parabola = Fit[list1, {1, x, x^2}, x]

howevever, when I compare the list with the fitted function,

Show[Plot[parabola , {x, \[Pi] - 0.1, \[Pi] + 0.1}], ListPlot[list1]]

I get this:

fitted funtion (solid line), list1 (dots)

What is wrong here?

$\endgroup$
2
  • $\begingroup$ I confirm to see this behavior (Win7, Mma 11.2). I also checked that FindFitalso gives a paradoxical result with the negative c. $\endgroup$ Commented May 8, 2018 at 14:29
  • 4
    $\begingroup$ Have you plotted your list1 with PlotRange -> All? That should show you why. $\endgroup$
    – TimRias
    Commented May 8, 2018 at 14:38

1 Answer 1

12
$\begingroup$

Your endpoints are so far of the curve that they do not show up on the plot. These scew the result massively.

Fit[list1[[2 ;; -2]], {1, x, x^2}, x]

Will return a perfectly exceptable fit (for the remaining data).

$\endgroup$
2
  • 4
    $\begingroup$ It's quite annoying how Mathematica will sometimes cut off important points from a plot. If you use Show[Plot[parabola , {x, \[Pi] - 0.1, \[Pi] + 0.1}], ListPlot[list1], PlotRange -> All], you can immediately see what's going on. $\endgroup$ Commented May 8, 2018 at 14:46
  • 4
    $\begingroup$ I upvoted based on your comment but I should have read the last two lines more carefully(the code and "Will return a perfectly exceptable fit"). One shouldn't toss inconvenient data. It might be that those two points are the only good ones. $\endgroup$
    – JimB
    Commented May 8, 2018 at 15:43

Not the answer you're looking for? Browse other questions tagged or ask your own question.