2

This is a bit of a dumb question (and not a very useful one either), but nonetheless:

I've been taught that grammatically, the negative sign is actually just negative one being multiplied with the number on its right. Thats why $-x^2$ is practically $(-1)\cdot(x^2)$ and not ($-1\cdot x)^{(2)}$.

But, by that logic, shouldn't $x/-y$ be $(x/-1)\cdot y$?

It's similar to the confusion of this question in that you'd normally see it written as a fraction. Does this kind of stuff really not get on anyone else's nerves?

Evan
  • 135
  • Yes $-x$ is the same as $-1 \times x$. But, grammatically, you need to parse the formula first and you don't parse $x \mathop{/}-y$ as $(x\mathop{/}-)y$ (because "-" is an operator not a formula). So you have to parse $x\mathop{/}-y$ as $x\mathop{/}(-y)$. – Rob Arthan Sep 01 '17 at 23:24
  • @RobArthan but doesn't parsing "-y" separately contradict that we would parse the "2^x" not separate from the "-" in the case of "-2^x"? – Evan Sep 01 '17 at 23:35
  • 1
    No. What I wrote is that you can't parse the minus sign on its own as a term: $1\mathrel{/}-$ doesn't make sense. This doesn't contradict any correct uses of the minus sign as a prefix operator. – Rob Arthan Sep 02 '17 at 00:06
  • @RobArthan okay, that makes much more sense. feel free to go ahead and post that as an answer and I will mark it correct. – Evan Sep 02 '17 at 00:34
  • "I've been taught that grammatically, the negative sign is actually just negative one being multiplied with the number on its right." This doesn't mean you should literally replace a unary minus sign with a $-1$. It's merely a justification for why the unary negation operator should have the same precedence as multiplication (and lower precedence than exponentiation). That being said, it doesn't necessarily have to be that way. It would be perfectly valid to have $(-1)x^2$ mean $(-1)(x^2)$ and $-x^2$ mean $(-x)^2$, but it just so happens that we don't do it that way. – Carmeister Sep 02 '17 at 06:17

4 Answers4

2

All you need to know is:

  • $/$, ^ and $-$ are operators; the first two binary, the third unary.
  • ^ has the highest precedence, then comes $/$ and then $-$

Now the two expressions are unambiguous:

  • $-x \text{^} 2 = - (x\text{^}2)$ because ^ has higher precedence
  • $x\,/{-y} = x / (- y)$ because $-$ is an operator

You can then replace $-a$ by $(-1) * a$ if you want, once it has been made clear what the minus sign is applied to: $-x\text{^}2=(-1)*(x\text{^}2)$ and $x/{-y}=x/((-1)*y)$

coconut
  • 766
1

Negative sign versus minus sign could be part of it. Also, a double division, is the equivalent to a multiplication under a fractions line ( can't remember the special name it has). so in your example we get ${x\over{-1\cdot y}}= {\big({x\over-1}\big )\over y}$

  • I was intentionally writing x/-y with a division sign and not as a fraction though. The notation of fraction ensures that the top and the bottom are applied to each other last, whereas "/" doesn't do so to its left and right. – Evan Sep 01 '17 at 23:38
  • a division sign with only two terms is an equivalent to a fraction though... also a fraction with only one negative sign in it is like a negative sign out front. –  Sep 01 '17 at 23:43
1

This is why computer programming languages (and scripting, too) have carefully designed lists of not just operator precedence but also operator associativity.

But we are human beings, or at least I am, and I assume you are, too. As human beings, we often make assumptions about what other human beings mean. If I write $$\frac{7}{-4},$$ would you think I actually meant $$\frac{7}{-1} \times 4?$$ That boils down to $-7 \times 4 = -28$, so if that's what I actually mean, it would make more sense for me to just go ahead and write the $-7$, not bother with the the $-1$, and go to the multiplication by 4.

So what I mean by the first expression is $$\frac{7}{-4} = \frac{-7}{4} = -\frac{7}{4} = -1.75.$$

Now I want you to try three things. First, open your browser's Javascript console (F12 on Firefox for Windows, then look for the Console button). Type in 7/-4, press Enter. It should respond -1.75. Then try the same thing on Wolfram Alpha. And think of a third way to have a computer do this calculation for you. In each case, the answer should be -1.75 or something like that.

If you look on the Mozilla Developer Network's page on Javascript operator precedence, you will see that "unary negation" is level 16 precedence with right-to-left associativity, while division is only level 14 precedence (the higher the number, the higher the priority).

Also notice that exponentiation is by itself on level 15 precedence. However, I got an error when I tried to put -2**3 on the Javascript console. I haven't checked this in the context of an actual script on an HTML document.

On Wolfram Alpha, -2^2 should give $-4$ for the result, and (-2)^2 should give 4. That's how it ought to be.

But we humans are frequently confused by that one. By comparison, $x/-y$ is a straightforward expression with no implied division by $-1$ to pull out of who knows where.

Robert Soupe
  • 14,999
1

When one uses the horizontal fraction bar instead of the in-line diagonal one, the denominator is effectively in parentheses.

$$\frac{a}{bc}=a/(bc)\neq\frac{a}{b}\cdot c$$

Notice that if $\color{red}{\frac{a}{bc}=\frac ab\cdot c}$, then it would hold that $\color{red}{\frac{a}{bc}=\frac{ac}{b}}$.

Try this with $b=-1$ and $a$ and $c$ equal to numbers of your choice.

Also, it’s just universally understood that you cannot divide a number by the negative sign (but we usually parenthesize the denominator anyways).