Is a negative number squared negative?

192.6k Views Asked by At

$-3^2 = -9$

I found this problem while doing an algebra refresher in the book The Complete Idiot's Guide to Algebra. I asked my engineer brother this problem and he got it wrong. A search on Google for why is a negative number squared negative I get conflicting results.

Google presents an excerpt from a site that says the converse. "This is because to square a number just means to multiply it by itself. For example, $(-2)$ squared is $(-2)(-2) = 4$. Note that this is positive because when you multiply two negative numbers you get a positive result." - This, of course, is the exact opposite of what was asked, but it's the given response.

The third item on Google's search results offered up a math forum where the moderator, one Doctor Rick, states that whether it is interpreted as -3^2 or -(3)^2 is a difference of opinion. It's math. How can it be a matter of opinion? If an equation is being used for calculating a space craft landing, or the engineering of a bridge design, a difference of opinion on how to calulate this could prove catastrophic.

The high school math teacher that authored The Complete Idiot's Guide to Algebra presented this question as "be careful, this one is tricky" specifically to teach this situation, but since there seems to some confusion as to which is the right way to calculate this.

My scientific calculator tells me it is 9. Another question here on SE regarding calculators with this same issue, the accepted answer was that adding parentheses fixed the "issue", but doesn't address whether the calculator is getting it "wrong" because it's not actually wrong.

What is the correct answer, and why? Thanks!

5

There are 5 best solutions below

6
On BEST ANSWER

Here's the issue that the other comments have been missing:

$-3^2$ does not mean "the square of negative three". The exponent takes priority over the negative: it means "the negative of $3^2$". If you want to say "the square of negative three" you write $(-3)^2$. (This also explains the issues with your programming languages - the ones that say $-9$ write it without the function notation doing the grouping for you, so the negative is applied after.)

9
On

It is not an opinion but a convention (accepted in all the world as far as I know) :

$$ -3^2=(-1)\cdot 3^2= (-1) \cdot 9 = -9 $$

0
On

$ -3^2 = -9 $ now, if you have parenthesis, like this:
$(-3)^2$ , then the answer will be $ 9 $.

2
On

In order to conserve the distributive law of arithmetic: $x(y+z)=(xy)+(xz), $ along with the other basic laws of arithmetic, when extending the number-system to include additive inverses, we must have $$1=1+0=1+(-1)\cdot 0=$$ $$=1+(-1)[1+(-1)]=$$ $$=1+[(-1)1]+[(-1)(-1)]=$$ $$=1+(-1)+(-1)^2=0+(-1)^2=$$ $$=(-1)^2.$$

9
On

IMO it helps a lot to understand how syntax of programming languages, and in a less straighforward way also maths notation, always correspends to a tree data structure. For instance, $f(g(x), h(y,z))$ is really a character-string encoding for something like $$ \begin{matrix} & & f & & \\& \nearrow & & \nwarrow & \\ g & & & & h \\ \uparrow & & & \nearrow & \uparrow \\ x & & y & & z \end{matrix} $$ The term $-3^2$, or the Python expression -3**2, means $$ \begin{matrix} & & -\square\quad & & \\ & & \uparrow & & \\ & & ** & & \\& \nearrow & & \nwarrow & \\ 3 & & & & 2 \end{matrix} $$ It does not mean $$ \begin{matrix} & & ** & & \\& \nearrow & & \nwarrow & \\ -\square & & & & 2 \\ \uparrow\!\!\!\!\! & & & & \\ 3 \!\!\!\!\! & & & & \end{matrix} $$ Why not? Well, these are just the conventions for how expressions are parsed: exponentiation binds more tightly than negation (which is, kinda reasonably, on the same level as addition).

OTOH, if you write in C# Math.pow(-3, 2), then this clearly is parsed as $$ \begin{matrix} & & \mathrm{pow} & & \\& \nearrow & & \nwarrow & \\ -3 & & & & 2 \end{matrix} $$ which is a different calculation and gives the result $9$. To express $-3^2$ in C#, use - Math.pow(3,2).

In programming languages, the parsing rules are generally these:

  • Parentheses group a subtree together, no matter what happens around them. Function application is typically connected to parenthesis, so this also binds tighly.
  • Commata always separate independent subtrees. Hence the -3 in pow(-3,2) is independent of the 2 and the pow function.
  • All other infix operators, like + and **, have some predefined fixity. For instance, in C and C++ the operator-precendence hierarchy includes the following:

    1. <, <=, >, >=
    2. <<, >>
    3. +, -
    4. *, /, %

    so when the expression pow(0+(-1)*3, 2) is encountered, the parser first splits it up at the comma, then at the +, then at the *, before considering the inner parenthesis.
    But in languages with an exponentiation operator, this should, as in maths notation, have a higher fixity than the other operators.

These parsing rules may subtly vary between different programming languages, but at least for a single language they must always be well-specified.

Alas, in maths it's often not so clear-cut – for some expressions it is indeed up to interpretation what they mean! For instance, does $\sin x^2$ mean $(\sin x)^2$ or rather $\sin(x^2)$? IMO it should be the former (because function application binds tightly), but I think the majority of mathematicians and scientist don't agree, and hence the completely ridiculous notation $\sin^2 x$ is used for that.

Oh well...