What's the difference between $(-x)^2, -x^2$ and $-(x)^2$?

$\begingroup$

$(-x)^2$ is definately equal to $(-1)^2(x)^2$, right?

But $-(x)^2$ and $-x^2$ are confusing me, do they mean $-(x^2)$ or do they mean $(-1)^2(x)^2$?

$\endgroup$ 0

3 Answers

$\begingroup$

Because the unary $-$ has lower priority than exponentiation, convention$^\ast$ says $$-(x)^2 = -x^2 = -(x^2) = -x\cdot x$$ The parentheses just clarify the meaning here. In the expression $(-x)^2 = (-x)\cdot(-x) = x^2$ they are essential.
This convention is very similar to the way that $$3-2\cdot 4 = 3 - (2\cdot 4)$$ must be handled.

$^\ast$ some programming languages have a different convention (for example Perl), but generally this is the standard unless stated otherwise, such as in a language specification. See this wikipedia section on exceptions

$\endgroup$ 7 $\begingroup$

$(-x)^2=(-x)(-x)=(-1)^2(x)^2=x^2$

$-(x)^2=-(x\cdot x)=-x^2$

$-x^2=-(x^2)$ as shown above

$\endgroup$ $\begingroup$

It depends on the medium you are using. Given that exponentiation is evaluated before subtraction by convention (probably from the study of polynomials), there become 2 competing design decisions:

  • That subtraction and negation are evaluated with the same priority
  • That unary operators are universally evaluated before binary operators

Most academic publications will use the first convention, that $-x^2 = -(x^2)$.

A lot of software (Haskell, some spreadsheet software) will use the second convention so $-x^2 = (-x)^2$.

$\endgroup$

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like