+ Reply to Thread
Results 1 to 10 of 10

Excel bug? Excel calculated Polynomial formula does not match data, why?

  1. #1
    Registered User
    Join Date
    10-06-2013
    Location
    Kaunakakai, HI
    MS-Off Ver
    Excel 2003
    Posts
    4

    Excel bug? Excel calculated Polynomial formula does not match data, why?

    Excel calculated Polynomial formula does not match data, why?

    This problem has stumped me (no surprise) & stumped my son (surprise, he is finishing his last year as a business major & has good experience with Excel). He also showed it to his professor (not sure what one) and (quote from email) "she was able to replicate the exact same problem we were having, and had no idea what was happening..."

    I am using Excel 2003 but the same thing happened under a newer version (my son's Excel 2010, and apparently 2012)

    Open the attachment and/or replicate the problem:
    Open a new Excel spreadsheet
    Post data to cells A2:B5 (A2:A5 as 86, 68, 50, 32 and B2:B5 as 10.5, 35, 108, 276)
    Highlight cells A2:B5, select Insert>Chart (or use toolbar Chart button)
    Chart Wizard starts
    Chart Type: XY (Scatter), click Finish (or Next, Next, Next)
    The chart appears in the worksheet.
    Right click a data point in the chart & Select "Add Trendline"
    TrendlineType - select Polynomial, Order value is 3.
    Click on the "Options" tab & check "Display equation on chart" & "Display R-squared value on chart"
    Click "OK"
    The trendline is added and the equation for the trendline appears:
    y = -0.0013x3 + 0.3459x2 - 30.891x + 953.82
    or perhaps this is clearer: y = -0.0013X^3 + 0.3459X^2 - 30.891X + 953.82

    and the R-squared value is equal to 1 (My understanding is R squared of 1 means the data matches the trendline perfectly with the formula shown)

    Now put the formula in the spreadsheet to solve for Y with any value of X
    Let cell B8 be the input value for X (I labeled A8 as "Input X:")
    Put the formula in B9 as:
    = -0.0013*B8^3 + 0.3459*B8^2 - 30.891*B8 + 953.82

    When I enter an X value of 32 the calculated Y value is close to the original value of 276 but not exact.
    When I enter an X value of 86 the calculated Y value not even close to the expected value of 10.5.

    What am I doing wrong? or is this a bug?
    Attached Files Attached Files

  2. #2
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Excel bug? Excel calculated Polynomial formula does not match data, why?

    But if you set the intercept to zero R^2 = .9556

    and the equation is

    y = .0041 * x^3 -.6341 * x^2 + 24.098 * x
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  3. #3
    Forum Guru Izandol's Avatar
    Join Date
    03-29-2012
    Location
    *
    MS-Off Ver
    Excel 20(03|10|13)
    Posts
    2,581

    Re: Excel bug? Excel calculated Polynomial formula does not match data, why?

    Increase the number of decimal places exposed in the trendline label and you will see:

    y = -0.00132887517146781x3 + 0.34593621399177500x2 - 30.89094650205780000x + 953.81618655692600000
    R² = 0.99999999999998700

    If you use this precision in your formula the results are better.

  4. #4
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,819

    Re: Excel bug? Excel calculated Polynomial formula does not match data, why?

    Izandol has explained the problem. It is a rounding error caused by displaying too few significant figures in the chart trendline.

    The only thing I would add is that, if this is something you need to do frequently (regress a polynomial and then calculate new y's from the coefficients for that polynomial), I would suggest learning how to use the LINEST() worksheet function. http://office.microsoft.com/en-us/ex...in=HA010277524 Just before Example 1 is an example of how to use LINEST() to regress cubic polynomials.
    Quote Originally Posted by shg
    Mathematics is the native language of the natural world. Just trying to become literate.

  5. #5
    Registered User
    Join Date
    10-06-2013
    Location
    Kaunakakai, HI
    MS-Off Ver
    Excel 2003
    Posts
    4

    Re: Excel bug? Excel calculated Polynomial formula does not match data, why?

    Thank you Izandol, this has solved the mystery & given me the formula I was looking for. The formula does indeed work as expected. (I added to your reputation, thanks again). One more request, could you please tell me how to increase the decimal places in the trendline label? (I tried but can't figure it out)



    Quote Originally Posted by Izandol View Post
    Increase the number of decimal places exposed in the trendline label and you will see:

    y = -0.00132887517146781x3 + 0.34593621399177500x2 - 30.89094650205780000x + 953.81618655692600000
    R² = 0.99999999999998700

    If you use this precision in your formula the results are better.

  6. #6
    Registered User
    Join Date
    10-06-2013
    Location
    Kaunakakai, HI
    MS-Off Ver
    Excel 2003
    Posts
    4

    Re: Excel bug? Excel calculated Polynomial formula does not match data, why?

    Mr Shorty, thank you for pointing me to the LINEST() function. I do not need to do this frequently but, regardless, will (out of curiosity) see if I can learn to use it.

  7. #7
    Forum Guru Izandol's Avatar
    Join Date
    03-29-2012
    Location
    *
    MS-Off Ver
    Excel 20(03|10|13)
    Posts
    2,581

    Re: Excel bug? Excel calculated Polynomial formula does not match data, why?

    You can select the label and then click the increase decimals button on the formatting toolbar.

  8. #8
    Registered User
    Join Date
    10-06-2013
    Location
    Kaunakakai, HI
    MS-Off Ver
    Excel 2003
    Posts
    4

    Re: Excel bug? Excel calculated Polynomial formula does not match data, why?

    Izandol, thank you again. That worked as expected (this time). Before asking for help when I tried the increase decimal button was not available (greyed out) & I thought that was because I had the label selected. Selecting a cell instead brought the increase/decrease decimal buttons back. Thought you must have used another method. Mahalo & aloha!

  9. #9
    Registered User
    Join Date
    02-13-2020
    Location
    St. Peterburg, Florida, U.S.
    MS-Off Ver
    Office 16
    Posts
    1

    Re: Excel bug? Excel calculated Polynomial formula does not match data, why?

    That is the way how I solved as well.
    I chose the equation of the trendline obtained in the graph, and changed its category to number and to 10 decimals places. The resulting line from that equation with more decimals matched the one showed in the graph.

  10. #10
    Forum Expert Pepe Le Mokko's Avatar
    Join Date
    05-14-2009
    Location
    Belgium
    MS-Off Ver
    O365 v 2402
    Posts
    13,446

    Re: Excel bug? Excel calculated Polynomial formula does not match data, why?

    Did you notice this thread is seven years old ?

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Excel Formula to regression fit Cubic polynomial
    By vsennak in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 04-01-2013, 03:21 PM
  2. Replies: 1
    Last Post: 03-06-2013, 09:37 AM
  3. Replies: 2
    Last Post: 06-27-2011, 03:00 AM
  4. excel formula for Match 2 columns data
    By luke_devon in forum Excel General
    Replies: 7
    Last Post: 10-12-2010, 09:59 AM
  5. Excel formula to find and match the data
    By SmallJack in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-09-2010, 05:13 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1