8
$\begingroup$

I have read and heard in many places that multiplication and division are of equal precedence. So what is the value of:

$$ 80 \div 10 \times 2 $$

Is it

$$(80 \div 10) \times 2 = 16$$

or

$$ 80 \div (10 \times 2) = 4 $$

? The answer here seems to be that by convention we operate from left-to-right, so the first solution is correct. But I would have thought we should get the same answer either way if multiplication and division are of equal precedence. Isn't the whole point of operator precedence to resolve expressions that would otherwise have more than one solution?

For example, people also say that addition and subtraction are the same level of precedence, but no such ambiguity exists there:

$$ 80 + 10 - 2 = (80 + 10) - 2 = 80 + (10 - 2) = 88 $$

So what is meant when people say that multiplication and division have the same precedence?

$\endgroup$
4
  • 4
    $\begingroup$ Well $(80-10)+2 \ne 80-(10+2)$. $\endgroup$
    – user856
    Jun 23, 2017 at 0:18
  • 1
    $\begingroup$ Actually addition subtraction has the exact same ambiguity. Is 10-8+2 equal to (10-8)+2=4 or is it 10-(8+2)=0? $\endgroup$
    – fleablood
    Jun 23, 2017 at 0:22
  • 2
    $\begingroup$ Division and subtraction aren't associative so you can't rearrange the order. "Precidence" is about distribution. $\endgroup$
    – fleablood
    Jun 23, 2017 at 0:27
  • $\begingroup$ @fleablood, but precedence is always taught by using parentheses to show the intended order. Just look at the example in the second paragraph here. That doesn't have to do with associativity? $\endgroup$
    – jds
    Jun 23, 2017 at 0:45

6 Answers 6

11
$\begingroup$

When there is equal precedence, the standard thing to do is to work from left to right. Hence $$80/10\times 2 = (80/10)\times2=16. $$

It should be noted that this is not completely universal, i.e. some programming languages don't do it this way, as far as I know. Anyway, it doesn't really matter that much because no one actually writes $80/10\times2$, instead they write $(80/10)\times2$ to remove any ambiguity.

$\endgroup$
7
  • 3
    $\begingroup$ No one should actually write $80/10 \times 2$, especially if they mean $80/(10 \times 2)$. If you read MSE enough, you'll find out that lots of people would actually write that, and even worse things. $\endgroup$ Jun 23, 2017 at 0:18
  • $\begingroup$ So then what is meant by "equal" precedence? $\endgroup$
    – jds
    Jun 23, 2017 at 0:42
  • $\begingroup$ It means that they come at the same level in the hierarchy of operations, and in case of ambiguity (i.e. multiple operations at the same level) go from left to right. $\endgroup$
    – Eff
    Jun 23, 2017 at 0:54
  • 1
    $\begingroup$ You should probably use $\div$ $\div$ rather than $/$ for this. $\endgroup$ Jun 23, 2017 at 3:12
  • 1
    $\begingroup$ While it is certainly true that nobody writes $80/10\times2$, people do write things like $80/3x$ or $1/2\pi$, and sometimes context makes it clear that what is meant is $80/(3x)$ and $1/(2\pi)$, respectively. (Such expressions are even found in textbooks.) $\endgroup$
    – mweiss
    Jun 23, 2017 at 5:07
2
$\begingroup$

I'm fine with Eff's answer because I don't think my question was particularly clear. But I'd like to offer what I hope is a clearer question and answer.

When learning about order of operations, examples of mathematical ambiguity like the following often come up:

What is $2 + 4 \times 6$?

The teacher then demonstrates to the pupil that by performing this computation in a different order of operations, we get two different answers. So we use order of operations to indicate that the real answer is $2 + (4 \times 6) = 26$, not $(2 + 4) \times 6 = 36$. In other words, order of operations removes the ambiguity of which operation to perform first.

When I heard that two operations have "equal" precedence, my interpretation of that was that it does not matter which order you perform your operations. But mathematically, this cannot be true since:

$$ (80 \div 10) \times 2 \neq 80 \div (10 \times2) $$

While $\div$ and $\times$ have equal precedence.

Clearly, something else is meant by "equal". Implicit in Eff's answer is that by "equal" we mean that the ambiguity cannot be resolved by simple precedence. The ambiguity is resolved by a new left-to-right rule.

To answer my own question, "What does it mean that multiplication and division have the same precedence?" I say: it means that you cannot perform multiplication or division first as a rule and in fact you will get different answers depending on context. The real rule is that you perform operators with equal precedence in a left-to-right computation.

$\endgroup$
1
  • 2
    $\begingroup$ This kind of thing is precisely why all mathematics educators ought to learn programming. Every proper programming language reference will not only specify precedence groups, but also the associativity (left-to-right or right-to-left) within each group. Only people who appreciate precision fully can really teach mathematics well. (For example see the C++ operator precedence rules.) $\endgroup$
    – user21820
    Sep 1, 2017 at 13:31
1
$\begingroup$

To say the multiplication and division have equal precedence is to say that, in an unparenthesized expression, they are both to be performed before operations of lower precedence, such as addition and subtraction, and that they are both to be performed after operations of higher precedence, such as exponentiation. Equality of precedence further implies that in an unparenthesized expression containing both multiplication and division, neither operation takes priority over the other. This leaves an ambiguity that must be resolved by some other rule—a left-to-right rule in this case.

One thing that precedence does not imply is that order of operations of equal precedence is irrelevant. To see this, you don't even need to look at an expression containing both multiplication and division. You can consider an expression containing only divisions, such as $10\div2\div5$. Clearly precedence rules can't tell you which division is to be performed first since, well, the precedence of division equals the precedence of division. In this case you need a rule that tells you how to associate the factors in the expression. As stated before, the rule use here is the left-to-right rule: $(10\div2)\div5=1$ is meant, and not $10\div(5\div2)=4$. One could say that associativity of division (and of a mixture of multiplications and divisions) defaults to left-to-right in the absence of parentheses.

A final thought: as discussed above, precedence rules resolve some, but not all ambiguities. I would not say that resolving ambiguity is the ``point'' of precedence rules (or of default associativity rules). The most straightforward way to resolve ambiguity would be to require parentheses everywhere, and to declare expressions such as $1+2\times3$ and $10\div2\div5$ to be undefined. Rather, the point of precedence and default associativity rules is to make expressions more human-readable by allowing parentheses to be omitted in certain situations.

$\endgroup$
1
$\begingroup$

For this discussion, operations have 2 properties of interest:

  1. Precedence
  2. Associativity

Both, yes, are used to disambiguate expressions. (Note, e.g., that prefix and postfix expressions never need to rely on precedence, and never need parenthesis to force evaluation.)

Precedence applies when 2 operators are adjacent; the operator with the higher precedence is evaluated first. $2 + 3 \times 5$ is always 17. In such examples, associativity plays no role. (When I say always, I mean, in math. Every programming language I know will do it this way, but that doesn't make them authoritative. Not all calculators yield this answer, though (infix) scientific calculators should.)

When 2 operators with the same precedence are adjacent, then associativity applies. The four basic arithmetic operators associate left-to-right. So, $8 - 3 - 2$ is always 3.

There are other operations which associate right-to-left. Exponentiation. $2^{3^2}$, which might be written as 2 ^ 3 ^ 2 in some languages, is always $2^9 = 512$. We use parenthesis to force evaluation otherwise: $\left(2^3\right)^2 = 8^2 = 64$.

While we're here, for clarity, 'cause I've seen too many CS professors get this wrong, associativity does not apply when evaluating, e.g., $ 3 \times 7 + 64 \div 16$ It does not matter (in arithmetic) whether the multiplication is performed first, or the division, just so they are both performed before the addition is applied (per the precedence rules). Languages like C, Python and Java have no rules about which is evaluated first, either.

Someone commented above that math teachers should learn programming. Languages are not authoritative; it is up to them to implement the rules of math correctly (or, not). For example, while writing this, the Tex engine balked at $2^3^2$, insisted I put braces in to clarify, though math is quite clear on the subject. OTOH, Python3 evaluates 2**3**2 just fine.

I would say it is important for programmers to be good at math, and know a bit about language theory. Side-effects are not a concern in arithmetic, but must be considered in programming.

$\endgroup$
1
$\begingroup$

It means, if you use $\clubsuit$ to represent "either $\times$ or $\div$" then

$$a \; \clubsuit \; b \; \clubsuit \; c \; \clubsuit \; d \; \clubsuit \; \cdots$$

means you compute the answer in this order

  1. $\; a \; \clubsuit \; b$
  2. $(a \; \clubsuit \; b) \; \clubsuit \; c$
  3. $((a \; \clubsuit \; b) \; \clubsuit \; c) \; \clubsuit \; d$
  4. etc.
$\endgroup$
0
$\begingroup$

I don't see the answer I'm looking for and this circulates as a viral meme every year, so I'm going to take a stab at answering it. Someone else pointed out that the "ambiguity" also holds true for addition and subtraction. There is no ambiguity, PEMDAS is just a horrible way to teach order of operations. I teach my students GEMA (grouping, exponents, multiplication, addition) to increase understanding of the connections between multiplication and division as well as addition and subtraction and to remove any sense of ambiguity for problems like these. It also removes any need to memorize a random rule that you should work from left to right.

Subtraction can ALWAYS be written as addition by a negative number. So 10-8+2 can be rewritten as 10 + - 8 + 2. To do 10 - (8 +2) is mathematically incorrect because now you are distributing that negative to both the 8 and the 2 (i.e. 10 + - 8 + - 2), which is not what the notation 10 - 8 + 2 means. Another way of looking at it is to notice he plus sign in front of the 2. That tells us we're adding 2. If you do 10 - (8 + 2), you're subtracting 2 instead.

Division and multiplication work the same way. Dividing by a number can ALWAYS be written as multiplication by its reciprocal. So 80 / 10 × 2 can be written as 80 × (1/10) × 2. To do 80 / (10 × 2) would be mathematically incorrect because that would be equivalent to doing 80 × (1/10) × (1/2), which is not what 80 / 10 × 2 means. Another way of seeing how it is incorrect is noticing that there is a multiplication symbol in front of the 2, meaning 2 is being multiplied. If you do 80 /(10 × 2) you're dividing by 2 instead.

Someone else mentioned that some textbooks use 1/2x to mean 1/(2x). In six years of higher level math, I never once saw this notation. In my experience, they use a vertical fraction since 1/2x means 1/2 × x. If a textbook does use that notation to mean 1/(2x), it's wrong.

$\endgroup$
0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .