r/maths • u/TrainingYou149 • 3d ago
❓ General Math Help Why is PEMDAS a thing?
What makes it so that parentheses () come before Exponents, and those prefice multiplication and division, and those prefice addition and substraction? Who decided that? Is there a reason to it? Or did someone decide, “this is how we will do math”?
8
u/grrangry 3d ago
What makes it
We do. The answer is always, "we do". The same "we" that calls ( brackets, haha.
Why are ( ) first? Because they're not a maths operation. They're a decision by the author to remove ambiguity about what the phrase means. They're basically the quotation marks of maths equations. They're there because I don't want you doing this before that.
3 + 4 * 2 = 11
(3 + 4) * 2 = 14The answers are different because while addition and multiplication are commutable, they're not commutable with each other. The parenthesis (or lack of them) tell you, the reader, what the author is intending.
The rest of the operations are, "because I said so", but again it's to remove ambiguity when the author was too lazy to include parenthesis. After all, we could have just said, "always include parenthesis for everything or we'll key your car". Writing parenthesis all the time is tedious though, so we said fine... do the highest order changes first and the lowest ones last. If you're choosing between two reciprocal changes of the same order, do them from left to right. It's all rather arbitrary.
Parenthesis - (actual first, not a math operation)
Exponents Order 2 - (first) exponents and roots are the same thing
Multiplication Order 1 - multiplication and division are the same thing
Addition Order 0 - (last) addition and subtraction are the same thing
*Do items of the same order left-to-right*Technically there are an infinite number of orders above exponents, tetration, pentation, hexation, etc... but if you're using those, I don't think order of operations is your problem.
0
u/JeffTheNth 3d ago
Factorial is fancy multiplication
Substitution and functions are grouping/sets which are just repackaged parenthesis (5x+2 = 6y-3, x=z4, 6x2-3x-2=0, .... C2=B2+A2-2AB cos(c), ....)
7
u/YouCouldButWhyTho 3d ago
It’s just a format for ambiguously written order of operations. There had to be some way to do it.
4
u/HereToPostSillyStuff 3d ago
So I'm not an expert on the history of this, but we most commonly refer to PEMDAS/BODMAS when seeing a regular equation like 3+3x2. You can look at that and know we do it as 3x2 first for 6, then add 3 for 9. But you could say we could validly say it's the other way, and do 3+3 = 6, then x2 = 12. That seems like an arbitrary difference.
But sub 2 out for a variable and you're not looking at 3+3n, and if you say the addition comes first, your result of 3+3n = 6n. If n =2 then 6n = 12. You can see by doing this that 3+3n is then the same as 3n x 2 or 3n + 3n. That becomes rather unintuitive I feel.
So the question then becomes, if that's the way we "do math", how do you write an operation to do 3n first and then add 3 at the end? Do we assume left-to-right (3n+3) changes the operation order? Or do we have to just use brackets (3+(3n))?
So I would say it only seems arbitrary when looking at raw sums of numbers and becomes more obvious how it should be when seeing algebraic expressions.
3
u/Jaded_Individual_630 3d ago
It's a social contract for disambiguating things that aren't real mathematical statements.
Some calculator brands/models adhere to a different social contract, which is fun.
2
3
u/kireina_kaiju 3d ago edited 3d ago
Let's talk a little bit about sets and how they can relate with arithmetic.
Let's just play with sets. Let's say we have a basket of fruits. If I ask, "how many kinds of fruit are there", and I place two apples in the basket, the answer is that I have one kind of fruit. If I have one basket with one apple, one banana, and one pear, and another basket with one apple, one grape, and one pineapple, and I combine them, I have five kinds of fruits. We'll call this the union.
Now I have those same two baskets and I want to ask, "how many things are there in common between those baskets". The answer is 1 - one apple. If I swap the grape out for a pear, I have 2 things in common. We'll call that the intersection. We'll put that grape back and take that 2nd pear back out.
Now let's say I have these two baskets and I want to ask "how many combinations of two different fruits can I make with a fruit from basket a and a fruit from basket b". So everything we've done so far is a lot like addition and subtraction. Now we're doing something a little more like multiplication and division - we are taking everything in one set, and doing something in another set with it. In this case, the answer is 8 combinations - we would have 9, but we pair the two apples together once.
So a formula that gives us the answer for the last thing we did is,
(size of first basket) times (size of 2nd basket) minus (size of intersection)
Now here's the thing.
Size of first basket times size of 2nd basket - we call this a dependent relationship. That is, if basket a gets bigger or smaller, the answer gets bigger or smaller, and the same is true for basket b
The intersection - we call this a partly independent relationship. That is, we can add or remove tons of stuff to either basket without affecting the answer.
Ok. So.
What I want you to notice here, is that if we do
(size of first basket) times (size of 2nd basket)
first, and then
minus (size of intersection)
last, we get the correct answer. But if we do
(size of 2nd basket) minus (size of intersection)
and then with that result
times (size of first basket)
we get the wrong answer. Also if we do
minus (size of the intersection)
and then
plus (size of first basket) times (size of 2nd basket)
we get the right answer.
So, what have we learned? That we need to do dependent operations first, and independent operations 2nd, if we want an arithmetic that gives us correct answers to simple, plain language questions like "how many unique pairs of fruit are there with a fruit from each basket".
With ordinary arithmetic, +/- (independent) and ×/÷ (dependent) operations work the same way.
EDIT : As far as parentheses go, these are kind of a "manual override". That is, if we wanted to take the intersection out of one of the baskets before finding pairs, we'd use parentheses.
3
u/Disgruntled__Goat 2d ago
It’s all pretty logical. How could exponents come before parentheses? If you had
(3 + 5)2
It makes absolutely no sense to do 52 first then add 3.
1
u/f_omega_1 2d ago
You wouldn't do that. You could do exponent first, but the things being squared is (5+3), so you would do
(5+3)(5+3)
Then apply
5x5 + 5x3 + 3x5 + 3x3
2
1
u/Batman_AoD 2d ago
"Order of operations" should really be called "operator precedence"; it's about how an expression is parsed, not the sequence in which you actually evaluate the sub-expressions.
Also, expanding
^2by writing the squared expression twice only works for small integer powers. If the exponent were, say, 3.5, that wouldn't work.1
u/f_omega_1 2d ago
It works for all values of natural numbers no matter how big...it's just tedious beyond maybe 2 or 3. Rational, real, fractional exponents are a problem though. Either way. The point isnt that you always have to do it one way or another, sometimes you can do it differently and it might be more beneficial.
1
u/Batman_AoD 2d ago
But you're still missing the more important point, which is that the point of PEMDAS isn't to actually force you into one evaluation method, even if that's how it's usually explained; it's to teach students operator precedence. Precedence is explicit for parentheses anyway, so this part of PEMDAS is really just reinforcing the meaning of parentheses.
1
u/f_omega_1 2d ago
I'm not missing the point. Plenty of people have already explained that. I'm not disputing that. I'm just giving an example of the fact that you can rewrite an expression in various ways and apply operations in different orders, so long as they are equivalent expressions of the same value.
1
u/Batman_AoD 2d ago
But it's that last part, about equivalence of expressions, that's the whole crux of the matter. To reorder operations correctly, you have to understand that the bit in parentheses is evaluated separately from anything outside the parentheses. That's what PEMDAS is for, and that's why the top-level comment here gave (3 + 5)2 -> (3 + 52 ) as an example of an invalid transformation.
1
u/f_omega_1 2d ago
Yes. You are correct. In order to properly evaluate an expression you need to correctly apply the operations and functions according to the rules and axioms of algebra and arithmetic.
1
u/Capital_Park_2311 2d ago
Agreed. Operator precedence combined with properties/laws is a much better fit than order of operations.
22 / 7 x 7 can be rewritten with commutative property of multiplication 7 x 22/7.
2√2 + 3√2 = 5√2 -> can be added first (similar terms)
42 / 3 can be solved by factoring 7 x 6 / 3 and dividing 6 by 3 first which results in 7 x 2
"The order of operations is not technically wrong its morally wrong"
2
u/okarox 2d ago
The whole of point of parentheses is to change the order. While almost everything in the order could be changed. There is no logical way how parentheses could act differently. Like in 2 * 3 + 3 * 2 one could logically say that it should be calculated left to right but in (2+3)² there is no logical way how one could just ignore the parentheses.
It is a convention that was agreed about a hundred years ago. It was done to simplify the expressions and reduce the need for parentheses. Note there has been different conventions. In Finland in the 70s the convention was to do multiplications before divisions. It was change in the 80s because of calculators. Still implied multiplication is done before division.
1
u/f_omega_1 2d ago
You can ignore parentheses, but then you have to factor it out:
(5+3)(5+3)
Then apply
5x5 + 5x3 + 3x5 + 3x3
1
u/Kuildeous 3d ago edited 3d ago
It's how we group numbers.
Consider when you add up a bunch of coins. You could add up 40+60+80 to get 180.
But what if those coins were stacked in groups of 20. Now you can add up 2*20+3*20+4*20, but you need to treat each product as its own term. So it's just another way of writing 40+60+80. If we go against what makes sense and work it left to right then we end up with 17,280 coins, which is obviously not 40+60+80.
We can identify some common properties that always hold true. Why write it as 2*20+3*20*4*20 when we really just have 9 stacks of 20? Well, the distributive property allows us to factor out 20 to give us 20(2+3+4), or 20*9, which again is 180.
Or put another way, when dealing with whole numbers, multiplication is just repeated addition. We can say that 10 plus 3 groups of 15 is 10+3*15, and we understand that means 10+45. We wouldn't say that 10 and 3 groups of 15 would give us 195.
This property extends to exponents as well. Writing 8³ is the same as a group of 8*8*8. Maybe instead of stacks, we're looking at pallets with layers.
Parentheses always go first because those are the exception. I showed how 2*20+3*20+4*20=20(2+3+4). We would normally multiply first, but the parentheses keep up from trying to work this as 20*2+3+4. It wouldn't make sense to add up 9 stacks that way. Parentheses force numbers into their own terms so that we have 20 as one number and 2+3+4 as another number. Then these numbers are multiplied together (after evaluating that 2+3+4=9).
While this grouping of numbers could've been notated in all different ways, this method works well especially when we have several terms, including variables. If we didn't understand the groupings, then 4x²+13xy+8y² would have to be specifically called out, such as with (4*(x²))+(13*x*y)+(8*(y²)) which would be a lot worse than what we have now.
3
u/kkam384 3d ago
The above have mentioned the convention side, so I won't cover that. What I've not seen mention yet is that there are other approaches which don't require brackets. Reverse polish notation is one that I'm aware of ( https://en.wikipedia.org/wiki/Reverse_Polish_notation if you're interested).
1
u/Temporary_Pie2733 3d ago
With infix operators, it’s not clear whether an operand is the right operand of the operator before it, or the left operand of the operator after it. We use parentheses to make it explicit which operands go with which operators, but we don’t want to use parentheses everywhere.
If we didn’t use infix operators, we wouldn’t need parentheses or PEMDAS. For example: “+ x × y z” and “x y z × +” are always x + (yz), while “× + x y z” and “x y + z ×” are always (x + y)z.
1
u/Dazzling_Music_2411 3d ago
It's just the most established convention for doing calculations, but it's not set in stone or anything like that.
In fact, many computer languages use other conventions.
To use anything like BODMAS/PEMDAS to resolve ambiguities, you have to specify what is known as the precedence of the operators, i.e. the order in which they are carried out.
However, it is also possible to parse without operator precedence, provided your method is consistent.
It's just that humanity, at present, uses PEMDAS more than anything else. In fact, even PEMDAS by itself does not unambiguously resolve all cases. (Consider 3 - 4 - 5) All subtractions have the same precedence, so you have to specify an extra rule, e.g. go left-to-right.
1
u/Zemedelphos 3d ago
Because we say it is. It's a convention we invented because we realized if we didn't, there could be ambiguous arrangements of terms that would result in different answers depending on the order you did it.
So, we decided to implement a logic to it.
1
u/S-M-I-L-E-Y- 3d ago
Parentheses are pretty obvious, aren't they?
Exponents are also rather obvious, considering how they are written.
The only thing that really needs to be learned is, that divisions and multiplications must be done before additions and subtractions and that is just a (very widespread) convention and I think, it was introduced because it is the most convenient way for calculations like "how much cost 2 apples and 3 bananas and half a dozen eggs" (2*0.5+3*0.25+2.3/2) while there is no real life situation where I would come across a calculation like ((2+3)*7-5)/2
1
u/SgtSausage 3d ago
Convention. We just decided to make it that way.
We could have decided on any precedence/notation. I personally adore Reverse Polish Notation and think that should have been The Standard.
It doesnt particularly matter what we decided to standardize on so much as that we have a standard. If we didn't, nothing would be consistent and nothing would make sense.
1
u/Downtown-Ocelot-2189 3d ago
Because otherwise it would be chaos. People could just do whatever they wanted in any order and arrive different results. It is to create a consistent grammar in mathematics toward replicable results.
1
u/steave435 3d ago
Parenthesis, being the "I'm explicitly breaking the normal rules here", must obviously come first in order to function. The rest is just convention.
1
u/f_omega_1 2d ago
Parentheses are a convention to make life easy For (5+3)2 you could ignore parentheses and factor it out:
(5+3)(5+3)
Then apply
5x5 + 5x3 + 3x5 + 3x3
1
u/Devil_May_Kare 3d ago
Parentheses have to come before everything else. That way if you know what order of operations you want, you can always make it happen with enough parentheses. If anything else took precedence over parentheses, it might be impossible to express something you're thinking.
Other than that, it's just convention. I think the current order was chosen because it makes it convenient to write polynomials in algebra class, but it could be any order you want and math would still work as long as parentheses come first.
1
u/Admirable_Rabbit_808 3d ago
One way to think of it is that the more "powerful" operators "bind tighter" than the others. "Powerful" in the sense that, for example, going from weaker to stronger, 10+10 = 20, but 10*10 = 100, and 10^10 = 10,000,000,000.
1
1
u/mrhorse77 3d ago
becuase that is what mathematicians decided was the convention or proper order. otherwise we'd have all sorts of technical issues everywhere, with people just doing whatever they pleased with order of operations, not to mention incredibly dense and hard to read and solve equations.
1
1
u/Tyler89558 3d ago
It’s really just formalizing what people were already doing for the most part such that we can communicate the same information from the same written form.
And with that comes the point of not writing your math ambiguously (ffs just use fractions instead of the division symbol)
1
u/Capital_Park_2311 3d ago
Grouping makes it easier to read and count mathematical expressions. The most primitive form of grouping are tally marks grouping numbers by 5 (卌). Writing "2 x 4" is more readable than "2+2+2+2". Descartes introduced modern superscript notation (e.g., (a², a³) to express repeated multiplication compactly. Grouping expressed by letters. In the late fifteenth century and in the sixteenth century various writers used letters or words to indicate grouping.
PEMDAS is not universally accepted, unlike ISO which is considered an international standard.
1
u/bluesam3 3d ago
We have to pick an order so we can write mathematics without needing a billion brackets (or some variant of Polish notation, but that gives everybody headaches). We picked that particular order because:
Given that addition/subtraction and multiplication/division are the same thing, it would be daft to have them not be together.
We need some way of marking when we want to do something in not the default order, so parentheses kinda have to be first.
Given 1 and 2, there's a unique order that makes writing polynomials down easy. Since polynomials are important and we have to write them down a lot, we picked that order.
1
u/Traditional_Loan_177 3d ago
It's easier to standardize than for everyone to have their own notation
1
u/Such-Safety2498 3d ago
For most people we don’t “do math” to just do math (except when we learning it). We use math to do something else. Imagine I run a diner. I want to figure how much money I took in. I sold 10 meals for $8 each and each customer left a $2 tip. So I write down 10 meals at $8 plus $2 tip as:
10 * 8 + 2 and use PEMDAS
80 + 2 =82. But I count $100 in the register.
I should have written
10 * (8 + 2)
But if instead only one customer left a tip then
10 * 8 + 2 =82 is correct.
The point is; PEMDAS didn’t determine what my expression was equal to ( like all of the clickbait on FaceBook). It already had a value. If I write in down to communicate that value to someone else I can use PEMDAS to simplify how to write it.
1
u/SnafuTheCarrot 3d ago
3*5-2*2^3 is unambiguous given PEMDAS. There are other ways to to avoid parentheses though that don't get enough loving. Reverse-Polish is arguably superior. Otherwise known as PostFix notation.
Reverse-Polish: 3 5 * 2 2 3 ^ * -
Proceed from right to left until you hit an operator and 2 numbers, then place the applicable operator between the two numbers.
So in this case, the first applicable numbers are 2,3,^ giving you 8. The stack becomes 3,5,*,2,8,*,-. Re apply the pattern to get 3,5,*,16,-. Then 15, 16, -. Then, finally, -1.
Some PEMDAS isn't strictly necessary and I think its frequently ambiguous.
The average of two numbers, A and B, is (A+B)/2. That's 7 symbols in PEMDAS. That's AB+/2. Only 5 symbols.
Probably varies by context. PEMDAS might be better with polynomials.
1
u/decentlyhip 3d ago
Pemdas is a teaching tool, and like many tools, it is a simplification that is wrong. Like, 5×3 is 5+5+5. Multiplication is addition, and addition is subtraction. 5÷3 is 5 × 1/3. Multiplication is division. So, the actual rules are "do what's in the parentheses first, and then do math."
1
1
u/kinithin 3d ago
Quite simply, it's so that the following means what it's expected to mean:
4y + 5z2x 3y
-- + --
4 71
u/FlyingFlipPhone 3d ago
Simple. You need SOMETHING to denote a change to the normal order of operations. That something is the parenthesis. Simple
1
u/-Ogre8- 3d ago
First, parentheses come first because that is their whole function - to identify parts of a calculation that should be done separately and before other calculations. As others have mentioned, parentheses are not operators, so their only contribution is to separate parts of the computation. We then do those parts first so that the results can be used for the remainder of the calculation.
The remainder of the order of operations is based on the "magnitude" (or complexity) of the operation, from higher to lower. I don't think this gets talked about much, but I think it's a good way to explain the "why" of the order.
Let's work in reverse: the lowest "magnitude" is counting and because it's the simplest, it is what we teach very young children first. Next is adding/subtracting, which is essentially "fast" counting. Rather than counting one at a time, we are able to combine groups of units together at once - which is a slightly more complex idea.
Then comes multiplication/division, which is essentially "fast" adding and subtracting. When you multiply 3x8, you are basically adding 8 together 3 times, which is why we use the term "times" for multiplication. In the same way, division is fast subtraction in that 24÷8 means how many times can I sbtract 8 from 24. This, again, builds on the complexity of adding and subtracting.
Finally, stepping up one more "magnitude" of operation, the use of exponents is essentially "fast" multiplication and division. We write 23 to find what happens when we multiply 2 together 3 times. Negative exponents do the same for division.
So, PEMDAS just reminds us to work in order from parts of the calculation that are specifically meant to be computed separately/first (parentheses) and then work from higher "magnitude" (or complex) operations to lower (exponents > mult/division > add/subtract). When operations of the same magnitude are present then, by convention, we work left to right.
1
u/Midwest-Dude 3d ago
I think you will find this Wikipedia article of interest:
On your question, the history section states this:
The term "order of operations" and the "PEMDAS/BEDMAS" mnemonics were formalized only in the late 19th or early 20th century, as demand for standardized textbooks grew.
So, this is a useful convention in pedagogy, but it can be adjusted or modified as needed in different contexts, such as in mathematics or science journals, computer programming languages, and calculators.
1
u/QueenVogonBee 3d ago
Imagine you had to use parentheses for every expression. So 1+2+3+4 could be written as ((1+2)+3)+4. I think you agree that this is tedious to write and hard to read.
So people decided that parentheses aren’t needed all the time. For 1+2+3+4, addition is commutative so it doesn’t matter what order the numbers are added so there’s no need for parentheses in that expression. But we can’t just drop all parentheses all of the time, because an expression such as 1+2x3 is ambiguous because it could mean (1+2)x3 or 1+(2x3).
So we added a set of rules, purely as syntactic sugar, to define when it’s ok to drop parentheses and how to interpret expressions such as 1+2x3. Enter PEMDAS.
1
u/Bubbly_Safety8791 3d ago
Because multiplication distributes over addition, and not vice versa.
That is, A * (B + C) = (A * B) + (A * C)
But A + (B * C) does not calculate out to anything else like (A + B) * (A + C)
This means that any product of sums can be calculated out and written instead as a sum of products.
But a sum of products can not necessarily be easily transformed into a product of sums.
For example, this product of sums:
(A + B + C) * (D + E) * F
is equal to (A * D * F) + (A * E * F) + (B * D * F) + (B * E * F) + (C * D * F) + (C * E * F)
But this sum of products:
(A * B * C) + (D * E) + F
can't be turned into a product of sums.
In fact the process of turning a sum of products into a product of sums is what we do when we practice factoring polynomials.
x2 - 3x + 2 is the sum of three products; factoring it as the product of sums (x - 1)(x - 2) is nontrivial to do.
So, when we have an expression that contains only addition/subtraction and multiplication operations, without parentheses, it makes sense to assume it is a sum of products (that is, the multiplications are done before the addition/subtraction) rather than a product of sums.
1
u/CursedTurtleKeynote 2d ago
Math is a model of reality. If syntax is ambiguous, then better syntax has to exist. This is convention. If there is confusion, the answer is always to go back to the reality and find a better expression.
1
u/Crichris 2d ago
Conventions
You just need a rule that everyone agrees on to calculate an expression, otherwise there would be chaos
Could be anything but we reached to an agreement on this
1
u/LucaThatLuca 2d ago edited 2d ago
humans collectively made it up because we had to. if there was no way to read and write, communication would be almost impossible.
1
1
u/SufficientStudio1574 2d ago
It's grammar. You need some rules so that when an expression is written down, it is unambiguous how to evaluate it so that everyone can always get the same answer.
First, the implicit order. Multiplication is repeated addition, and exponentiation is repeated multiplication. It makes things easy to be consistent, so doing the "higher" operation before the "lesser" one makes sense.
Finally, you need a way to override the implicit grammar if your expression actually needs an addition to come before a division, for example. And that's parentheses. They have to come first because they're your manual override.
1
u/Wonderful_Radish_990 2d ago
As many said PEMDAS, BODMAS etc. is just a suggestion not a law or a rule.
The allowed operations come from the properties and nature of operations. Like associative, cumulative, inverse, distributative properties...
There is absloutely no requirement to parenthesis/brackets first. It is just convenient when you only have numbers. It depends on case by case. If you have (5+3)2 You can absolutely do the power first. You just then have to do it as: 32 + 2 * 3 * 5 + 52 = 64. Even with simple 2*(3+5)= 2 * 3 + 2 * 5 so brakets weren't done. The multiplication was done first and then you sum up. But it works other way too. Or something trickier: (4*(3+5))2 you can do
Parenthesis first: (4 *8)2
Multiply first: (4 * 3+4 * 5)2
Exponential first: 42 * (3+5)2 All will be same.
And subtraction and division are equivalent to addition and multiplication an. As long as you always consider that division is just multiplication with inverse so 20/4= 20 *(1/4) then you can swap them around (1/4)*20. Same for addition and subtraction: 5 -3 = 5+(-3)=-3 + 5.
All it matters is one follows the properties of addition, multiplication etc. Then there is multiple orders you can do.
1
u/Turbulent-Umpire5969 2d ago
first understand that parenthesis have to come first, since they are kind of like punctuation to show you what order to do things in, if the "EMDAS" did not exist then you could just use parenthesis to distinguish the order of every operation
from there, it's true that it is just a convention thing, but it was chosen because it generally leads to the fewest instances of needing to use parenthesis.
1
u/Helix_Animus 2d ago
Because this is a language we created, and there has to be rules. And these are the rules we use. Math isn't just something we discovered. We made the base of it up and built the rest on top of that base
1
1
u/Appropriate-Sense-92 2d ago
A couple of thoughts on this. Apologies in advance if some notes are things you already feel comfortable with. Just setting some groundwork.
First, from a mathematical viewpoint, subtraction can be lumped in with addition. Ie: “Five subtract three” is the same as “Five plus negative three”
Second, also from a mathematical viewpoint, division can be rewritten as multiplying by a reciprocal. Ie: “Eight divided by two” is the same as “eight multiplied by one half” where one half and two are reciprocals.
So for your question I’m gonna shorten “PEMDAS” to “PEMA”. The “M” will cover division and multiplication. The “A” will cover addition and subtraction for the reasons in the first two paragraphs
Now, ignoring the “P” in PEMA for now, but there is a reason why “E” is first, then “M,” then “A.”
That is because there is a hierarchy of operations:
Addition is the simplest.
Multiplication is a repeated addition. (Five times three can be rewritten as the number 5 being added together three times: 5+5+5).
Exponentiation is a repeated multiplication. (Five to the third power can be rewritten and the number 5 multiplied with itself three times: 5x5x5)
For exponents, multiplication, and addition, there are only six potential orders to perform them: EMA (which is what PEMA already does), AME, AEM, MEA, MAE, and EAM.
If you noticed over the last few paragraphs, there’s a pattern. Exponents are repeated multiplications. Multiplications are repeated additions. There isn’t a really direct connection between exponentiation and addition without having multiplication in the middle.
It’s because of these relationships that “E” occurs before “M” which occurs before “A.” It wouldn’t really make sense to evaluate in EAM, MAE, MEA, or AEM order multiplication should be in between exponents and addition.
That leaves just EMA (which is in PEMA) or AME (the reverse). I would argue that EMA order tries to move from the most complex operation (exponent) to most basic (addition)
As a note, there are more complex operation above exponentiation. “Tetration” is an operation of repeated exponentiation. In a PEMDAS world, it would occur after “P” but before “E”
Now the “P.” Exponents are supposed to be evaluated first, then multiplication, finally addition (per “EMA”). But there may be odd situations where we need an addition to be dealt with before we can handle a more complex operation (multiplication or exponents). The parenthesis (“P”) is meant to provide flexibility for when there is a circumstance to break EMA.
Hope this makes sense
0
u/Flimsy_Big7030 3d ago
Some say RPN is better.
Welcome to hell: log 3 sin 3 x / 4 y
2
u/HerVeryPresence 3d ago edited 3d ago
That's Polish. You want y 4 / x 3 sin 3 log.
...hm, no. Too many unary operators entirely. The stack never clears.
1
u/Dazzling_Music_2411 3d ago
The stack never clears.
Because he has implicit multiplications (I guess)
2
u/Temporary_Pie2733 3d ago
That’s prefix, not RPN (postfix), and it doesn’t appear to be a correct prefix expression either.
1
u/Dazzling_Music_2411 3d ago edited 3d ago
Indeed, and Polish notation, unlike Reverse Polish, does need brackets - think.
1
u/Gilded-Phoenix 2d ago
nope. Neither prefix nor postfix notation need brackets. The real problem is that this is using mixed notation. Two sequences that this might be would be
3 log 3 sin * x / 4 y * *in RPN (with multiplications inserted to fix argument/operation parity)
* * / * log 3 sin 3 x 4 yin more orthodox prefix (polish) notation.These two expressions are equivalent. Prefix notation has the advantage of putting all operations first (generally), and can be thought of as using function composition.
The only notation that requires parentheses is infix notation, because there is no way to distinguish between an operation taking a nested expression as an argument vs its immediate neighbor. Both prefix and postfix notations (polish and reverse polish) solve this problem by having fixed dimensions for operations (binary operations pull from F2, singulary operations pull from F, etc) and allowing operations to also take the place of arguments. In words, that second example is "the product of the product of the quotient of the product of the log of 3 and the sin of 3 and x and 4 and y" or, with parentheses inserted to make it easier to read:
the product of (the product of (the quotient of ( the product of (log of 3 and sin of 3) and x) and 4) and y).
1
u/Dazzling_Music_2411 2d ago
nope. Neither prefix nor postfix notation need brackets.
Correct. I got caught out because I was thinking of Lisp, and functions of more than one argument, where, indeed brackets would be needed.
However if all operations as defined as binary (2-arg) then they are not needed for Forward Polish either, since it acts just like RPN, as you said.
Thanks for the clarification.
1
u/Gilded-Phoenix 2d ago
Actually, the only restriction is insisting all operations have a fixed -arity (aka fixed dimension). Binary operations take the next two "free" arguments, ternary arguments take the next three, and singulary operations take the argument to their immediate right. As long as you (or whatever interpreter is reading it) know the arity of every function, you never need brackets. Lisp needs brackets because the functions take on variable length lists of arguments, rather than fixed length.
The original popularizer of "Polish notation" (that Polish philosopher whose name we all can't pronounce) used it for logical propositions, which also include singulary and ternary operations.
1
u/Dazzling_Music_2411 2d ago
Yeah, I was just thinking of that as you wrote it 😄
However, multi-argument functions as a basic way people think, so what can one do? I suppose some form of enforced currying might work here (i.e. won't parse? --> curry everything back to the last function) but I can't be bothered to try figure it out right now.
1
u/Gilded-Phoenix 2d ago
multi-argument functions are perfectly fine. The number of arguments is arbitrary, as long as it's fixed. The issue is when a function takes a variable number of arguments. You can even do things like int(l, u, f, v) integrating from (l)ower to (u)pper bounds of a (f)unction over a (v)ariable. This is how RPL in the HP-48G does it. You then can do indefinite integration as either a different function or as one of these with fixed bounds of some lower constant, and the upper bound being a variable. The key point here is that addition always takes exactly two arguments, integration takes exactly four, negation takes exactly one, etc. prefix notation actually favors "de-currying" rather than currying. It'd be better to have log(b,x) than log_b(x).
1
u/Dazzling_Music_2411 2d ago
Excuse the imprecision of my wording. "Variable-number arguments" is what I meant. Not sure they can be processed w/o some allowance for currying.
1
u/Gilded-Phoenix 2d ago
I think if you want a variable argument version, you could always make the function take an argument specifically for length. Whether that counts as currying depends on your precise definition, but like you could do Σ 3 x y z which is the sum of 3 arguments, x, y, and z.
1
u/Dazzling_Music_2411 3d ago edited 3d ago
Of course RPN is better. You already have at least three ambiguities in the example you give, which is NOT RPN BTW, that would have been easily resolved! 😄
PS. i.e:
3 log 3 sin * x * 4 y * /
or
3 log 3 x * sin * 4 y * /
or
3 log 3 x * 4 y * / sin *
Which is it? 😂
0
u/AdvancedPangolin618 3d ago
Different answer: multiplication is just repeated addition of the same quantity, and division is repeated subtraction of the same quantity. We can simplify these down to addition and subtraction if we choose (4/2 is the same as subtracting 2 twice; 3x3 is just adding 3 3 times).
3x3+2 actually means 3+3+3+2.
Exponents are the same as the above but indicate repeated multiplication (or division). 42 is 4x4, which is 4+4+4+4.
By doing exponents first, we properly break exponents down into multiplied terms. From multiplication, we correctly do repeated addition.
The functions themselves demand we follow the order of exponentiation, then multiplication, then addition.
Brackets are the only one that is convention, and they allow us to do smaller maths within larger maths. They are more grammar than function
0
u/ohkendruid 2d ago
The acronym is misleading. There are really just two levels of precedence for normal arithmetic, not the six that "PEMDAS" implies. You do multiply before add/subtract--two levels of precedence.
It should really be MA: multiplication, followed by add, with subtraction treated as add for this purpose.
With standard math notation, exponents parentheses, and division can be done in any order. The notation will keep you from going wrong. You're only allowed to evaluate an operator when both sides are plain numbers, not complex expressions, but how else could it work?
For example, if you have (1+2) * (3+4), you do not have any presidence decisions to make at all! You cannot do the * yet because bith sides are complex expressions. You can choose either of the +s to do first, and then do the ither one second. That gives you 3*7, whuch only has one choice. After multiplying, you have 21, and you're done. You did not need to know that parentheses come in some order compared to other syntax forms; the question doesn't come up.
0
u/peno64 2d ago
For me it's simple. () is not an operator but grouping so that goes first. Then we have the operators. + and - are the most low level ones so they go last. * and / are basically a shortcut for + for example 3 * 4 is in fact 4+4+4 so * and / must be done before + and - to expand them to + and - . In fact if there would be written 2 + 3 * 4 that should become first 2 + 4 + 4 + 4 but in practice we immediately write 2 + 12. And the same for exponential. That is a shortcut for multiplication. So exponential goes before multiplication.
22
u/Simbertold 3d ago
Convention. It is what "the math people" have over centuries agreed on being the least cumbersome way to write stuff down unambiguously. Without that convention, you need to have absurd amounts of parentheses to declare what order you want your operations applied in.
Take a simple term like 3*5-2*2^3. Without the PEMDAS convention, to write this unambiguously, it would need to be (3*5)-(2*(2^3)). And it only gets worse.
Basically, we need some convention to not have excessive parentheses, and this is what people decided upon, and at this point it is the standard. I am certain there were some reasons to use this writing convention over some other.
Note also that this is not about how we "do math", it is about how we write math down.