Viewing a single comment thread. View all comments

DragonFireCK t1_iyaxbmc wrote

The order of operations is merely a common standard agreed upon by mathematicians. There is nothing innate with mathematics that requires that standard, though having a standard of some form is a requirement for the common infix notation.

There are other options, such as pre-fix and post-fix notation, also known as Polish and reverse-Polish notation. With pre-fix notation, you'd write `1+2*3` as `+ 1 * 2 3` or `+ * 2 3 1` and `(1+2)*3` as `* 3 + 1 2` or `* + 1 2 3`. With these, you don't even need to define left-to-right or right-to-left as its implied by the definition - though you have to agree whether its pre-fix or post-fix.

13

Sereaph t1_iyc5dfu wrote

I'd like to delve deeper to clarify this concept. If we're talking PURELY numbers, PURELY mathematics, there IS NO order of operations. The math just *IS*.

For example, 1+2+3 = 6 doesn't happen left to right, right to left, or whatever order at all. 1+2+3 *IS* 6 and it *IS* 12-6 and it *IS* 18/3. All of these terms are just different ways of representing the number 6. They are equivalent, one in the same. Another way to think of it is that ALL the operations are done *at the same time*.

However, human beings aren't instant and we lose track of things all the time. Therefore, we devised the order of operations as an INTERPRETATION of how we observe the math actually works.

But I do want to clarify, this order of operations isn't just an "agreed upon standard" arbitrarily. It's following observed rules. The reason why multiplication comes before addition is because it is already a form of repeated addition.

7 + 3 x 4 is the same as 7+(4+4+4).

If we try it purely left to right, it doesn't make sense.

7+3x4 is not the same as 10x4 because the 3 is *modifying* the 4.

The 3 and the 4 are not separate terms. They are telling us that 4 happens 3 times (or that 3 happens 4 times). The 7 is just another term being added to the evaluation of 3 times 4. So we MUST evaluate 3x4 first.

Here's an illustration:

7 apples + 3 baskets of 4 apples. You don't add 7 apples to 3 baskets. You'd get what, 10 apple/baskets? That doesn't make sense. You add the baskets first (12 apples total), then add the extra 7 apples for a total of 19 apples.

3

bildramer t1_iyca5ey wrote

Fun fact: (with some assumptions about operators) only one of the cyclic permutations of a RPN (or PN) string is valid, so you can be sneaky and define the value of any string as the value of the only parsable-as-RPN cyclic permutation of it, leading to funny stuff like 1 + 2 - 3 = 2, 5 * 6 - 7 + 8 * 9 = 368. Another fun fact: all strings with N numbers and N-1 binary operators are valid under that scheme, such as - + 8 7 * 6 5 * * 4 3 = 169. Proofs are an exercise to the reader.

2