2
$\begingroup$

The wife and I were doing homework together, and we noticed something really strange when charting quadratics with a TI-series graphing calculator:

f(5) = -x^2 + 110x - 1000 f(5) = -5^2 + (110*5) - 1000 f(5) = -25 + 550 - 1000 f(5) = -475  // Wait a minute... -5^2 = -25  // Negative? 

We knew this wasn't right, so we tried the formula out on an online calculator, and we got the same result:

online calculator result

So we decided to wrap the coefficient in parentheses, and it worked as expected:

// Wrap in parentheses... (-5)^2 = 25 // Positive, as expected 

Obviously, I think the second solutions must be correct... but I can't imagine that in today's day and age, I have to explicitly wrap every negative coefficient in parentheses to ensure proper evaluation on a calculator. Is this the case, or is the first evaluation actually correct?

Thanks for taking the time!

  • 2
    To add to @DylanMoreland's comment, one notable exceptional program/language is the widely-used Microsoft Excel whose manual carefully explains (or used to explain) that in `-5^2` the `-` is a _unary_ operator that has precedence over exponentiation while in `1-5^2` the `-` is a binary operator that defers to exponentiation. I was burned by this difference when writing `EXP(-X^2/2)`; one of the many?/rare? instances where it would have paid to RTFM! (See also J.M.'s comment on Arturo Magidin's answer).2011-12-05

1 Answers 1

10

Modern calculators follow the appropriate precedence of operations: exponentiation goes before products, products go before additions. If you type "2+3*5", my calculator (TI-83+) correctly gives 17 as the answer. When you type "-5^2", the calculator correctly performs the square first, then multiplies by $-1$.

Note that if you simply write $-5^2$, then this does mean $-(5^2)$, and not $(-5)^2$, because of the precedence of the operations. When you write $-x^2$, you mean $-(x^2)$, not $(-x)^2$.

The function $f(x) = -x^2 + 110 x - 1000$ is the function $f(x) = -\left( x^2\right) + \left( 110 x\right) - 1000,$ and as such, its value at $5$ is $-(5^2) + (110\times 5) - 1000 = -25 + 550 - 1000 = -475.$

If the function you meant to write was $g(x) = (-x)^2 + 110x - 1000 = x^2 + 110x - 1000,$ then you should have written that.

The calculator correctly evaluated what was typed; whether what was typed was what was meant is of course a separate matter.

  • 0
    Ah, I forgot to percent-encode. Thanks for the nudge!2011-12-05