Saturday, January 11, 2014

Wolfram Alpha Glitch!

There are many great math calculation resources online. Wolfram Alpha is probably the most well-known. I've used it often from home, where I don't have a calculator. I used to create graphs there that I could copy onto my handouts and tests, but now I use Desmos for that.

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=ax2+bx+c, which would go as near as possible to the points (0,0), (1,1), (2,4). The right answer is y=x2, 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.


5 comments:

  1. 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 numeric mode, 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 into analytic mode 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/

    ReplyDelete
  2. Thanks for the Reddit link, Patrick.

    I 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.

    ReplyDelete
  3. Hi, Sue.

    It 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.

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

    it works fine on WA

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

    ReplyDelete

 
Math Blog Directory