# Negative × Negative = Positive… right?

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:

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!

-
For computer input, exponentiation usually has precedence over negation. (There are some exceptional languages.) There had to be some choice, and if the reverse were true then someone might complain that $-5^2$ required one to write -(5^2). I think this standard has the advantage that it looks roughly like what I would write down on paper: I wouldn't write $-5^2$ to mean $25$. –  Dylan Moreland Dec 5 '11 at 6:07
Note that $-x^2$ in a polynomial expression does mean "first square, then multiply by $-1$"; so $(-5)^2$ is not the evaluation of $-x^2$ at $x=5$. –  Arturo Magidin Dec 5 '11 at 6:14
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). –  Dilip Sarwate Dec 5 '11 at 12:35

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.

-
I'll note that I keep getting many of my students try to evaluate things likes $x^2 - 3x + 1$ at negative numbers by typing -3^2 - 3*-3 + 1 and getting the wrong answers because they fail to add the appropriate parentheses... –  Arturo Magidin Dec 5 '11 at 6:21
As a matter of fact, the error of using $-x^2$ when $(-x)^2$ was intended is so common, that the TI-83 Plus manual devotes a section on how negation works on the calculator. See page 49 of this manual, for instance. –  Ｊ. Ｍ. Dec 5 '11 at 6:37
@J.M. The link shows as broken for me (404 Not Found). –  Arturo Magidin Dec 5 '11 at 13:45
Huh, that's weird. Try this. –  Ｊ. Ｍ. Dec 5 '11 at 13:54
@J.M.: Yes, the latter one worked. The first link shows as http://education.ti.com/guidebooks/graphing/83p/83mbook-eng.pdf –  Arturo Magidin Dec 5 '11 at 16:23
show 1 more comment