[Math] can you disprove this rule PEDMSA?-(division before multiplication, subtraction before addition)

arithmetic

I know the proper teaching of PEMDAS/PEDMAS/BODMAS/BOMDAS.. is that multiplication and division have equal priority and are evaluated going through the arithmetic expression left to right (So, doing division first if division is left of multiplication in the arithmetic expression, and multiplication first if it is to the left of a division). Ditto for addition and subtraction.

And I know PEMDAS if taken as multiplication always before division, gives wrong answers. And addition always before subtraction, also gives wrong answers. e.g. 3-2+1 addition before subtraction would be wrong result. And 6/2*3 multiplication before division would be wrong result.

So one can break(get a wrong result from), a literal reading of PEMDAS, i.e. doing multiplication always before division, and ditto with additionan and subtraction.

But how about a literal reading of PEDMSA? so, taking it literally.. division always before multiplication. Subtraction always before addition.

Can you break it(get a wrong result from it)?

Best Answer

It is false that your PEDMSA rule (without the left-to-right rule) suffices to correctly evaluate any arithmetic expression.

$(6/3)/2 \color{red}\ne 6/(3/2)$.

$2^{(1^2)} \color{red}\ne (2^1)^{^2}$.

This shows that you still need the left-to-right rule when processing each arithmetic operation, and need the inside-out rule for exponentiation. It is true that with these rules in place, PEDMSA works. But the justification given by other existing answers is incomplete. To handle arbitrarily long arithmetic expressions, you will need induction. Also take note that exponentiation in some programming languages like Python have right-to-left associativity, so 2**1**2 is interpreted as 2**(1**2); this is obviously because there is no superscript in source code.


Here is the proof that PEDMSA+LTR+IO (namely PEDMSA with the left-to-right and inside-out rules) works for all arithmetic expressions involving $+,-,*,/$ and superscript-exponentiation and brackets, but no unary negation.

Take any expression $E$. By induction we can assume that PEDMSA+LTR+IO works for expressions that have fewer operations than $E$. Here parentheses are counted as operations. We shall analyze what happens when we apply PEDMSA+LTR+IO to $E$. We have the following cases:

  • $E$ has a parenthesis: The inner expression has fewer operations than $E$, and is hence evaluated correctly. After that, the resulting outer expression now has fewer operations than $E$, and hence we get the correct answer.

  • $E$ has no parentheses but has exponentiation: $E$ is reduced in the same way as conventionally (inside-out for chained exponentiations), so we get the correct answer.

  • $E$ has division and no higher-precedence operation: Let $p$ be the position of the first $/$ in $E$. By considering the $*$ operations immediately to the left of $p$, if any, it is clear that $E$ is of the form $\cdots [x * \cdots] y / z \,\cdots$, where there is no $*$ or $/$ immediately before $x$, and there is only a chain of $*$ between $x$ and $y$, and here the square-brackets in $[x * \cdots]$ denote that that subexpression is optional (it will not be there if whatever operation immediately to the left of $p$ is not $*$). Then the value of $E$ is $\cdots \Big( \big( [x * \cdots] y \big) / z \Big) \,\cdots = \cdots \Big( [x * \cdots] \big( y / z \big) \Big) \,\cdots$, and so our reduction results in an equal expression with fewer operations, and hence we get the correct answer.

  • $E$ has multiplication and no higher-precedence operation: $E$ is reduced in the same way as conventionally (leftmost $*$ first), so we get the correct answer.

  • $E$ has subtraction and no higher-precedence operation: $E$ is of the form $[x + \cdots] y - z \,\cdots$, where there is only a chain of $+$ between $x$ and $y$, or possibly $[x + \cdots]$ is empty (if the first operation is $-$). The value of $E$ is $\Big( \big( [x + \cdots] y \big) - z \Big) \,\cdots = \Big( [x + \cdots] \big( y - z \big) \Big) \,\cdots$, and so our reduction yields an equal expression with fewer operations, and hence we get the correct answer.

  • $E$ has only addition: Our reduction yields the correct answer because any reduction does.


I shall leave it as an exercise to extend this theorem and proof to cater for unary negation. One must think very carefully about how to amend the evaluation rules to correctly handle expressions like:

$-3/-1*--4--2*---5$

If you do not consider this valid, then you must decide and precisely specify what expressions are valid.