What makes non-PEMDAS answers invalid?
It seems to me that even the non-PEMDAS answer to an equation is logical since it fits together either way. If someone could show a non-PEMDAS answer being mathematically invalid then I’d appreciate it.
My teachers never really explained why, they just told us “This is how you do it” and never elaborated.
In: 834
PEMDAS isn’t required to do math.
If you look at the way computers represent a mathematical expression, for example, PEMDAS isn’t used. In a computer, expressions are typically represented using a totally different system called an “abstract syntax tree”, or AST. There’s absolutely nothing preventing humans from writing out an AST to represent expressions too, except for convenience.
Another way you can represent an expression is using a system called Reverse Polish Notation, or RPN. RPN uses the notion of a “stack”, and operators are always applied to arguments on the stack.
Yet another way to represent an expression without PEMDAS is to write it as a “fully parenthesized expression”. In this representation, you can’t assume any order of operations at all, you have to explicitly put parens around everything. The parens in this way of doing things mean something slightly different than they do in PEMDAS; in this representation, they mean “evaluate everything inside first.”
For example, let’s look at a simple expression, `3*x + 5`.
Using an AST, you would have a node at the top with the plus operator, and two nodes connected to it below. The left node would have the multiply operator and the right node would have the value 5. From the multiply operator, it would have two child nodes as well, the left one is 3 and the right one x.
In RPN, this expression would be represented `3x*5+`. This means push 3 and then x onto the stack, then multiply, which is an operator that takes two arguments off the stack and multiplies them (in this case 3 and x). The push 5 onto the stack and add, which pops two values, the term that resulted from the multiplication `3*x` and 5, and adds them.
Using fully parenthesized expressions, this would be: `((3*x)+5)`. Notice that there’s an outside set of parens surrounding the entire expression. This is necessary in this representation, it would be invalid to write `(3*x)+5` because this leaves the ‘+’ operator unevaluated, and all operators cannot be left in an unevaluated state when using fully parenthesizes representation.
The point of all this is to simply say that PEMDAS is just one way of representing an expression. You can think of the expression itself as being some mathematical idea, and the rules you use to write it down is simply a way to communicate that idea to another person. Obviously, whatever way you choose to communicate a mathematical expression should be unambiguous, or it’s not a very good representation.
Note that all of the above representations are unambiguous, and each one also provides different advantages unique to that representation.
Computers use an AST, for instance, because using an AST is very convenient for a compiler. There are different ways to traverse a tree that can be used based on how the computer should evaluate the expression. Should it do the multiplication first and store the result, then do the plus? Or should it delay the multiplication until it’s absolutely necessary to evaluate it? Doesn’t make much difference for a simple expression, but for a long-running operation it can make a big difference *when* something is evaluated.
RPN is a very good way of representing an expression if it’s convenient to use a stack, and if you hate parentheses. There are no parens necessary in RPN, you never need them because every expression is always unambiguous without them, and everything is always evaluated left-to-right, in the order you encounter them. This is very convenient if you are receiving a stream of data and instructions one at a time and you want to be able to immediately process each bit that comes in. If it’s data, push it onto the stack, if it’s an operator, pop the values needed for that operator, apply it, and push the result back onto the stack … you never need to wait and see what the next thing is to do work.
The reason I’m reviewing all of this is to clarify that how an expression is represented is really not much to do with math proper, it’s purely about representing and communicating a mathematical idea. We use PEMDAS simply because it’s the most convenient form most of the time, but I would argue that if you ever find yourself in a situation where it’s not the most convenient, it’s probably better to switch to something else.
One thing to note about PEMDAS, and one thing that causes a lot of confusion about it, is that it is incomplete. It’s just shorthand for establishing a representation that relies on a certain order of operations:
* parens
* exponents
* multiply / divide – these are at the same level of precedence! it’s not multiply first, then divide!
* add / subtract – like MD, these are also at the same precedence level
First, I say this is incomplete because it doesn’t specify all of the operators, just the basic ones you encounter most often. There’s trig operators like `sin`, logarithmic operators like `ln`, etc. All of the different operators technically fit into this order of operations, but we usually don’t talk about them just because it’s a long list.
Second, I say PEMDAS is incomplete because it works hand in glove with another aspect of this representation, which is the associativity of the operators.
What’s this mean?
Let’s look at the fully parenthesized version of two different expressions that use PEMDAS:
* `1 – 3 + 4 – 2` → `(((1-3)+4)-2)`
* `5^3^4^2` → `(5^(3^(4^2)))`
Notice how in the first expression all of the parens “bunch up” to the left. This is because both addition and subtraction operators, ‘+’ and ‘-‘, are left-associative. This means that you always execute them in the order you read them, from left-to-right.
Exponentiation, on the other hand, is right-associative. The parens in the second expression “bunch up” to the right.
If you have an expression that contains operators all have the same associativity (like RPN), you don’t need order of operations at all to make an expression unambiguous. For example, plus, minus, multiply, and divide are all left-associative, so if we wanted to, we don’t need order of operations. For example, `3*x + 5` would simply be represented in this system as `3*x+5`, the same thing.
However! If we wrote `5+3*x` in this system, we would execute the addition first, and it would be equivalent to `8*x`. If we wanted to represent `5 + 3*x` in this system, we would have to use parens to specify the order we mean: `5+(3*x)`.
It’s possible to mix all these different left-associative operators, but it’s not *convenient* to do so. And, moreover, we find it convenient to have right-associative operators like exponentiation. When mixing operators of different associativity, without order of operations we’re left with an ambiguous expression. So, since we have to introduce order of operations anyway to deal with the second problem, we might as well use it to make our representation as convenient as possible wrt to the first problem. Because we tend to write a lot of polynomials, it would be a big hassle to always parenthesize multiplication terms, so we put MD at a higher precedence than AS so those terms can always be implicitly parenthesized.
All said and done, we settled on this system of using order of operations combined with associativity simply because it strikes a good balance between being terse, unambiguous, and convenient.
(But wait, you say, it is ambiguous! What about that math meme going around?! It’s … not ambiguous. It’s only ambiguous if you ignore the associativity rules, which would be stupid. The whole point of a representation is to resolve these kinds of issues, so if it’s not doing that, stop using it.)
Latest Answers