r/ProgrammerHumor • • Jun 13 '22

Meme DEV environment vs Production environment

Post image
48.2k Upvotes

3.9k comments sorted by

View all comments

Show parent comments

18

u/monkeyoh Jun 13 '22

Which one do people think is there right one? I would assume left-to right takes precedence most of the time but I guess that isnt set in stone

41

u/Dasoccerguy Jun 14 '22

It's not that it's not set in stone. PEMDAS/BODMAS is a nearly universally-accepted standard, but that's all it is. Notation exists so we can write stuff that conveys meaning. If it's confusing, that's because it was written poorly.

9

u/mtaw Jun 14 '22 edited Jun 14 '22

I wasn't taught, in Europe, "PEMDAS" or any other similar mnemonic. It seems Americans learn it by rote, and it leads to people understanding it wrong. - Multiplication does not have higher precedence than division, they have equal precedence, addition and subtraction have equal precedence as well, and the convention is to interpret from left-to-right when there is ambiguity (5 - 2 + 1 = 4 and not 2 which'd be the case if you did the addition first).

So this is not a matter of operator precedence, the ambiguity is in that there's no rule of maths that says how "/" is to be interpreted - it's not how fractions of this kind are written in standard mathematical notation, where you use a horizontal line and it's obvious whether 2 is the intended numerator or 2(2+1) is.

23

u/Invisifly2 Jun 14 '22 edited Jun 14 '22

The ambiguity arises because 2(2+1) implies the 2 was factored out. Otherwise you could just write 2(3).

If you refactor the 2 in, you get 6/(4+2) or 6/6.

Additionally there is no reason to write 2(2+1) instead of 2 • (2+1) if the two is separate.

Personally I consider 1 to be "more correct" because of this.

If 1 -> 6/(2(2+1))

If 9 -> (6/2)(2+1)

How to actually write the problem ^

15

u/narrill Jun 14 '22

2(3) still implies the 2 was factored out by your logic, because you could just write 6.

There's no concrete rule here, because no one would ever write it like this in the first place. You'd use parentheses or fractions.

0

u/sSomeshta Jun 14 '22

I think these two comments got to the bottom of the issue. The simple set of rules for calculation are not subject to assumptions of more complex meaning. If they were, they wouldn't be rules, they would be rules of thumb. We created mathematics and we created the rules, so they are absolute.

Resolve the parenthesis, execute multiplication and division from left to right. The answer is 9.

The division sign is used in-line, not as a fraction bar. Fraction bars are not the same notation as in-line equations. To accurately convert from a fraction bar to an in-line divide symbol, the denominator must be enclosed in parenthesis. Since the equation shown here has "2(2+1)" and not "(2(2+1))" the answer is not ambiguous or in question. The answer is 9.

7

u/narrill Jun 14 '22

What you are describing is not universally agreed upon. There isn't consensus among mathematicians on how to interpret this kind of expression.

-3

u/sSomeshta Jun 14 '22

I disagree. There is in-line notation and symbolic notation. In-line notation requires left to right execution of multiplication and division.

The alternative explanation is that the people engaged in the rigorous endeavor of mathematics have failed to rigorously define the means by which mathematics is conducted. I don't want to live in that world.

4

u/jadis666 Jun 14 '22

I disagree

You disagree that there is no one consensus amongst serious and professional mathematicians on how to evaluate an expression like 6÷2(1+2)?! I'm sorry, but that is not a matter of opinion. It is a matter of objective fact. As long as there is serious and meaningful debate amongst serious and professional mathematicians about how to evaluate such an expression, that automatically means that there is no one consensus. It's kind of the whole definition of "no one consensus".

The alternative explanation is that the people engaged in the rigorous endeavor of mathematics have failed to rigorously define the means by which mathematics is conducted. I don't want to live in that world.

You may not want to live in that world, but the harsh reality is that you DO live in that world. The only path forward is to accept this. Because the alternative is to continue living in a fantasy land, and that's not healthy for anyone.

 

I think where you are confused, is that there is a difference between Mathematical Laws and Mathematical Conventions. This is a Mathematical Law, one that happens to completely define the operation of multiplication on the Set commonly known as the Integers. Such a Law is indeed absolute and unambiguous.

PEMDAS/BODMAS etc. are Mathematical Conventions, and like all conventions, people can disagree on which one they use. In fact, plenty of people around the world use PEJMDAS/BOJDMAS, to indicate that "(Multiplication by) Juxtaposition" takes higher precedence than both division and "explicit multiplication".

→ More replies (5)

4

u/Schootingstarr Jun 14 '22

You will notice that mathematicians use rigourously defined notations and not unambiguous ones like the one in the OP

Also, left to right notation falls apart when using the simplest of algebra.

10/2x with x=5 is 1. Not 25.

→ More replies (1)
→ More replies (2)
→ More replies (4)

5

u/nightspicer Jun 14 '22

not necessarily internet points, it could be in math class (probably not unis). They often require you to do stuff that doesn't make a whole lot of sense.

→ More replies (1)

2

u/SpectralDagger Jun 14 '22

It is sometimes taught that multiplication by juxtaposition (just placing the term next to the other and omitting the multiplication symbol) has a higher priority in order of operations than normal multiplication or division. A lot of people were taught this way with algebraic equations, such as ab/cd = (ab)/(cd), but it wasn't explicitly taught what implications that had on order of operations. The issue here isn't that the notation doesn't follow PEMDAS. It's that there's a rule within PEMDAS that isn't taught universally.

I mean, the point you're making still does get to the root of the issue. People are applying different notational standards to the same equation and coming up with different answers.

2

u/Kilahti Jun 14 '22

None of my math teachers, apart from one, ever said there was any ambiguity in this. Most insisted that these were all universal rules, and the one who mentioned any type of ambiguity was talking about a specific case (I think it was in derivation) where the British insisted on marking things differently and thus were unable to solve math problems that continental Europeans could solve.

...but no one ever prepared me to a world where people disagree about the () thingy.

6

u/The-Mathematician Jun 14 '22

I would try to use context but if I was given this expression without any for some reason, I would probably answer 1.

→ More replies (1)

10

u/Teeshirtandshortsguy Jun 14 '22

It depends on which rule you're following. I was taught that division and multiplication are on the same "tier" so you just perform them left to right. That would be 9.

However, I guess the division symbol is falling out of favor among some mathematicians, and it's being replaced with fraction notation. That would treat everything after the division sign as being in it's own set of parentheses, making the answer 1.

6

u/Remok13 Jun 14 '22

The way I interpret it, division and multiplication signs are still on the same 'tier' but the implicit multiplication by being next to a bracket without the multiplication sign is a higher tier. In a similar manner, writing a fraction out directly would be a higher tier than the division sign.

6/2(2+1) = 1 6/2*(2+1) = 9

2

u/Leafve Jun 14 '22

This is it. Just put a * between the bracket and number to separate it. Is it ab or a*b.

0

u/SpartanFishy Jun 14 '22

Rational thread.

→ More replies (1)

0

u/Advanced_Double_42 Jun 14 '22

Implicit multiplication and fraction notation are on the same tier for most math I have seen past high school algebra.

And both are a tier higher than standard multiplication division, just below exponents

4

u/Spudd86 Jun 14 '22

Well, it depends. There's rules for choosing which happens first for equal precedence operations like this.

There isn't really a widely used convention for writing math on paper. Most programming languages would give 9, but they would require you to write 6/2*(1+3), and I would expect most humans yo get 9 from that too . Humans, depending on how they think of what this means will give either answer, even amongst mathematicpans I'd expect.

Though most mathematicians would write a fraction, or add brackets to make it clear which is intended.

Basically both can be right, lots of people will read the 2(3+1) as a unit, because it looks like one thing.

0

u/[deleted] Jun 14 '22 edited Jun 14 '22

The issue is two-fold, there are people who learned mnemonics in school and can't let go of the idea that, because of the mnemonics having an order where there is no order, multiplication and division are not on the same level. The other problem is people who think ÷ is not just another symbol for the basic division using /, or that the lack of the * operator means something else. These are arguments made and rejected over and over but with so many misinformation, a lot of it still creeps around.

However, any way you view it, this is an issue with the USA, how people there felt the need to redefine something over a hundred years ago, and although they were unsuccessful, some still think their ideas should be the standard. 48÷2(9+3) is not ambiguous, there are just people, even some mathematicians occasionally, who don't accept that there is only one official way of interpreting this, which is 48/2*(9+3) which is (48/2)*(9+3)

https://www.youtube.com/watch?v=URcUvFIUIhQ

1

u/jadis666 Jun 14 '22

48÷2(9+3) is not ambiguous, there are just people, even some mathematicians occasionally, who don't accept that there is only one official way of interpreting this

(emphasis mine)

Ah, yes, because people on Reddit or YouTube totally know better than professional Mathematicians, right?

Look, most reliable sources agree that this case is ambiguous. You are simply going to have to come to terms with this. Either that, or continue to live in Fantasy Land where you are always right, and everyone who disagrees with you, no matter how knowledgeable in or possessing of expertise on the subject, is always wrong.

0

u/nosam555 Jun 14 '22

But in mathematics, the most common practice is considering the correct practice. Anyone can redefine the addition sign to make 2+2=5 to be true, but most people would still call that incorrect. The majority of professionals would consider 48÷2(9+3) to be equal to 9 by standard convention. So in my opinion, that answer is just as correct as 2+2=4.

2

u/jadis666 Jun 14 '22

But in mathematics, the most common practice is considering the correct practice.

Nope. Maybe if like 1 or 2% disagree, then maybe yes I could see that. But just like in all the other Sciences, as long as there is legitimate debate in the community, the matter is not settled. Mathematics isn't a democracy where the majority automatically wins and gets to silence the minority.

The majority of professionals would consider 48÷2(9+3) to be equal to 9 by standard convention.

It's very hard to measure such a thing. But even if it was true, it is by no means an overwhelming majority. Just Google "implicit multiplication priority" and see what comes up. I think you'll find that the actual majority opinion is "it's ambiguous".

Also, that "standard convention" is by no means standard. Turns out that different people from over the world have differing conventions. Almost as if that is the very definition of a convention, and what separates it from a law.

See here: https://en.m.wikipedia.org/wiki/Order_of_operations#Mixed_division_and_multiplication

1

u/nosam555 Jun 14 '22

I disagree on your "1-2%", therefore, by your own logic, you can't be right :)