Wolfram has lots of interesting features, but it must be hard to make sure everything works just right. There is a statistical procedure to find the line or curve of best fit given a number of data points. If the data points are exactly on a line or curve, you'd think it would be especially easy. But somehow it isn't.

I was asking Wolfram to give me an equation like y=ax

^{2}+bx+c, which would go as near as possible to the points (0,0), (1,1), (2,4). The right answer is y=x

^{2}, but Wolfram gives an answer with teeny tiny x and constant terms added in.

A quick Google search doesn't turn up any information on why this happens. I learned about it from David Cushing on Aperiodical. It turns out that if you ask for a parabola instead of a quadratic, you get the right answer. The wrong answer happens because the computer is using a complex procedure which produces numbers that can only be represented approximately on the computer, and some very small round-off errors show up at the end.

It appears that this has to do with whether W|A is working analytically or numerically. I guess it processes this request and goes into

ReplyDeletenumericmode, and so gives approximations (which are essentially 0). On the other hand, if you ask for "polynomial interpolation of (0,0), (1,1), and (2,4)", it goes intoanalyticmode and gives the exact answer.I, too, found this interesting, and happened to see Peter Rowlett mention that he had posted this on Reddit, where some knowledgeable people responded. http://www.reddit.com/r/math/comments/1um6t7/can_wolfram_alpha_find_a_quadratic_passing/

Thanks for the Reddit link, Patrick.

ReplyDeleteI was thinking about what analytic mode might look like. Interpolation gives a curve that exactly goes through n points. If a polynomial is the best fit, it will be a polynomial of degree n-1 or lower. Seems to me that WA should use interpolation for best fit problems when the number of data points is less than the degree of the curve asked for, and could also check for close matches when the degree is higher.

Hi, Sue.

ReplyDeleteIt is, indeed, puzzling, that Wolfram Alpha (WA) wouldn't return the expected answer. WA is usually one of my first visits when I want to checks results of my calculations. (Getting results to 50 or more decimal places is nice, but not possible on a hand-held calculator.)

I also use translations of some LINPACK routines and ran your example through it: http://www.akiti.ca/LinLeastSqPoly4.html

I entered the following data pairs: (0,0),(1,1), (2,4) .

Made sure the check-box beside each pair was checked.

Selected the radio button under the "c" term to indicate a quadratic approximation.

The program returned the correct approximation: y = 1*x^2

And no residuals, so we have a perfect fit.

(Incidentally, I am a new user of the Desmos Graphing Calculator too; so far, I am very impressed with it.)

I am also a new user of the Desmos graphing calculator.

If I do quadratic (0,0), (1,1), (2,4)

ReplyDeleteit works fine on WA

Yep, works fine for me too. Now. I'd love to hear from them about the details behind this.

ReplyDelete