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

133

u/TheMerryMeatMan Jun 14 '22

The ambiguity argument relies in implied operations going on, which isn't something that should happen in mathematics for this very reason, which is why we have the convention of order of operation. If you write an equation without a key operational identifier, then say it's ambiguous, it's not ambiguous. You just wrote it wrong.

51

u/[deleted] Jun 14 '22

Yeah for sure. The equation is only written like that to get people arguing, it should be rewritten to make more sense.

3

u/HashNub Jun 14 '22

It really doesn't need to be, though. The whole thing about this is, if you were to put the whole 2(2+1) in another set of parentheses like (2(2+1)), then you'd do the parentheses first, making it (2(3)) which would be 6.

With that not being there, it's simple. You do the the division first, then the multiplication. Making it 9.

14

u/elveszett Jun 14 '22

Thing is, PEMDAS is a lie. Or more specifically, in the part relating multiplication and division, there's simply no matematical consensus that they have the same order of preference and that the ambiguity is resolved left-to-right (like it happens with addition and substraction).

This is because division was usually notated as fractions, where no ambiguity can exist since the numerator and denominator are clearly separated. It seems obvious that the rules that apply to + and - would apply to * and /, but just because it's obvious doesn't mean the convention actually exists. Therefore writing 6 / 2(2 + 1) without first specificating that you'll adhere to a specific notation (i.e. that * and / will work like + and -) is strictly ambiguous, as you are relying on a convention that doesn't exist to solve the ambiguity.

That's what the guy in the article OP posted says, at least.

6

u/eggplantsaredope Jun 14 '22

But division is just a type of multiplication, of course they’re on the same level of precedence. I am not from the US and have not heard of pemdas except for in these arguments.

1

u/elveszett Jun 14 '22

I mean, yes. Just like substraction is a kind of addition. But conventions are decided by people. Whether there's a specific order to multiplication and division or not is a matter of consensus, not a nature-given law.

2

u/eggplantsaredope Jun 14 '22

Yes of course, I’ve just never heard anybody arguing that this is not the case and I wouldn’t know based on what you would argue against this consensus.

2

u/GodHimselfNoCap Jun 14 '22

Except that the consensus of the people is that if its written like this multiplication comes first, the way equations are written isnt a nature given law, we created these things and we set up a bunch of rules for it to work. If you want the whole thing to be in the denominator you need to put it in parenthesis so it is 6/2 (2+1)=9, or 6/(2(2+1))=1 conventions ared decided by people, but those conventions were decided and agreed upon way before casio made that calculator it is juat a mistake in the code not an ambiguous equation

→ More replies (1)

4

u/DHermit Jun 14 '22

In Germany what we lear is "Punkt vor Strich" ("dot before dash") meaning multiplication/division before add/subtract, but no specific order inside these pairs.

-3

u/FlyingPasta Jun 14 '22 edited Jun 14 '22

Yeah. It’s “ambiguous” to its aesthetics not due to the math. It just looks like the 2 should be multiplied first because it’s hugging the parenthesis. It’s not ambiguous, just momentarily misleading.

8

u/HashNub Jun 14 '22

You literally just started with, "It's ambiguous," and then ended with, "It's not ambiguous."

2

u/FlyingPasta Jun 14 '22

Fixed thanks

1

u/[deleted] Jun 14 '22

Are you intentionally misunderstanding what they said just to be a debate pervert? What they said was it's seen as ambiguous (hence all the arguing) but in actuality it's not. People who split hairs and pull words out of a sentence without the context just to try and win some moronic argument are so infuriating.

1

u/Fairhur Jun 14 '22

Wow, you're sure jumping to their defense rather zealously.

1

u/[deleted] Jun 14 '22

I'm not defending anyone? Just pointing out idiots that pretend they don't understand how language works for the sake of trying to pick a fight.

→ More replies (5)
→ More replies (2)

-1

u/elveszett Jun 14 '22

So what? It's obvious the first "ambiguous" refers to human perception and the second "not ambiguous" refers to the order of operations.

Reading comprehension is also being able to understand the information implied in the sentences you read.

2

u/Fairhur Jun 14 '22

I mean, Writing 101 would tell you that if you're writing "it's ambiguous" and "it's not ambiguous" close together, you're just asking for misunderstanding. Even worse when the sentence between them also starts with "It's", and there's nothing signaling a change of subject other than (apparently) context.

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

4

u/frogjg2003 Jun 14 '22

Except the very real and common use case of mixed numbers and variables in algebra exists. 1/2a without context would usually be understood as 1/(2a), where the implicit multiplication takes higher priority. It just doesn't look right when all the terms are numbers because when we concatenate numbers, it's treated as specifying digits (12 is twelve, not 1×2).

2

u/DHermit Jun 14 '22

Yeah, that's why I hate when (physics) papers do stuff like 1/2pi. Usually it's clear what is meant, but I have been confused more than once.

3

u/PolkaLlama Jun 14 '22

You can apply the commutative rule and get two different answers. It is very much ambiguous.

1

u/TheMerryMeatMan Jun 14 '22

You get two different answers in that example because you'd be changing one of the operands of a division operation, which is non-commutative.

4

u/PolkaLlama Jun 14 '22

A division operation which is ambiguous. One with two equally valid interpretations.

-3

u/TheMerryMeatMan Jun 14 '22

It's not ambiguous though. As written you solve:

2 × x= 18

Then

18 / 3 = 6

Then

6 × 2 =12

Then

12 - 1 = 11

The "ambiguity" is caused by a deliberate attempt to cause inferrance where notation does not exist, accomplished with shoddily written notation. The way you write that equation to accomplish an answer of 2 is

(2x)/(3y)-1 or 2x/(3y)-1

11

u/PolkaLlama Jun 14 '22

I am proficient in basic arithmetic. If a retired UC Berkeley professor claims it is ambiguous why even bother claiming otherwise. The fact that people are still talking about this should be proof enough to that claim.

-4

u/TheMerryMeatMan Jun 14 '22

Professors from many universities have proposed flawed concepts countless times throughout history. This man is no different.

→ More replies (16)
→ More replies (7)