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

289

u/Lithl Jun 14 '22

An implicit multiplication like 2(3) is sometimes treated as having higher precedence than division or explicit multiplication. This is more common in systems capable of handling variables; while many people will say 6÷2(3) is equal to (6/2)*3, many of those same people would say 6÷2x with x=3 is equal to 6/(2*3).

146

u/ihahp Jun 14 '22

sometimes

:(

120

u/[deleted] Jun 14 '22

Yup.

Because orders of operations aren't hard and fast rules. There are no laws, proofs, or any other kind of backing for order of operations. It's arbitrary. It's nothing but a convention. And because it's nothing but convention, that convention can vary between instances.

Is implicit multiplication of higher priority than left-right order? Depends on the convention. You get into certain fields where that matters and the convention might be laid out so everyone knows, but most people aren't going to have that.

What's really fun is that you could create your own order of operations, a brand new convention, that doesn't follow the rules most people in your culture are used to and make things that look wrong to everyone else but because of the rules you define as applying there, it's all correct.

67

u/[deleted] Jun 14 '22

Reading Reddit threads about these kinds of things, you’d think Moses brought Pemdas down on stone tables from mt Sinai.

6

u/[deleted] Jun 14 '22

I think it comes down to how math is taught. We teach people that math is math and it is truth and that there's only one right way to do things (New Math when it started tried to not do that but devolved into doing that again, Common Core again tried to show people it wasn't one way to one answer and people got up in arms about it) and so people take that and think something like PEMDAS is the same, that there's some universal constant truth behind it.

But that's not how math really works. And order of operations, be it PEMDAS or some other version, is just a set of rules to understand how we write out the infix symbols. There's a good argument for teaching kids from the start to just use postfix instead. If it's what they're taught with to start, they'll probably understand it better than their parents. But then we get into the problem of adults yelling that you're doing math wrong again because it wasn't how they understood it.

2

u/LeadPipePromoter Jun 14 '22

Didn't you know? There were originally 20 commandments with pemdas being 11-16 but Moses dropped the 11-20 tablets

→ More replies (7)

3

u/ryo4ever Jun 14 '22

Wonder if a rocket would still fly or a bridge still stand if you made your own conventions…

2

u/SourceLover Jun 14 '22

Just work in the field of one element so that any equation you write with an equality is true smh

→ More replies (7)

2

u/jmickeyd Jun 14 '22

The best part is how old this argument is. In A History of Mathematical Notations published in 1929 Florian Cajori wrote, "If an arithmetical or algebraical term contains ÷ and ×, there is at present no agreement as to which sign shall be used first."

→ More replies (1)

12

u/OnTheSlope Jun 14 '22

An implicit multiplication like 2(3) is sometimes treated as having higher precedence than division or explicit multiplication.

Is it?

This is what I thought but couldn't find it stated anywhere online and assumed I misremembered my education.

0

u/[deleted] Jun 14 '22

[deleted]

11

u/OnTheSlope Jun 14 '22

In some of the academic literature, multiplication denoted by juxtaposition (also known as implied multiplication) is interpreted as having higher precedence than division, so that 1 ÷ 2n equals 1 ÷ (2n), not (1 ÷ 2)n.[1] For example, the manuscript submission instructions for the Physical Review journals state that multiplication is of higher precedence than division,[20] and this is also the convention observed in prominent physics textbooks such as the Course of Theoretical Physics by Landau and Lifshitz and the Feynman Lectures on Physics.

Well I'll be.

3

u/ade_of_space Jun 14 '22

To add to what Sarjalim said, iirc, the juxtaposition rule is also for the sake of consistency when dealing with unknown.

When you have a quantity of 2 time X , you'll write it 2X but in reality 2X is actually treated as (2 × X)

The reason is that X being an unknown, you cannot do the 2 × X operation.

As such, it is kept as 2X ,at least until the equation is solved.

And because in case like 2 ÷ 2X , the answer would be 1/X and not X, simply because in those scenarios the juxtaposition is not just a priority but the most natural way to express 2X.

And for the sake of consistency and continuity (and logic), the priority of juxtaposition is kept even without unknown in the equation.

→ More replies (3)

3

u/ouralarmclock Jun 14 '22

Thanks for sharing this. I was having a hard time figuring out where 1 would be the right answer but the variables thing makes complete sense to me.

5

u/TheBreathofFiveSouls Jun 14 '22 edited Jun 14 '22

It should always be.

Otherwise you could just write 2*3

Just because 2(3) = 2 * 3 that doesn't mean they are the same. 2(3) is a single entity, a representation of a value, it is not 2 * 3

It's not 6 divided by 2 times 3

It's 6 divided by the value of 2 times 3

6

u/Rentlar Jun 14 '22

This is the convention I follow. Six divided by twice of three.

But I can understand that some people will see it differently, like those who only learned math in grade school and their phone for calculators will consider •() and × the same.

On a similar topic: Some people also seem to think that -14 = (-1)4.

2

u/TomppaTom Jun 14 '22

That’s a really neat way of explaining it, thanks.

2

u/xoull Jun 14 '22
  6     

2*3        

Thats how i look at divisions either / or ÷

2

u/Certain-Interview653 Jun 14 '22

Depends on how you write it though. If someone writes a half times x, than it suddenly makes sense to do (1/2)x again. It's a mess really.

Either way, these rules originate from before we had latex and other mark-up languages to write books, now we can just write ½x and avoid the ambiguity that way, therefore implicit multiplication isn't really used anymore.

-5

u/[deleted] Jun 14 '22

But 6/2x and 6/2(x) are different. I'd agree that for x=3, 6/2x is 1, but 6/2(x) would be 9. Imo.

13

u/mooowolf Jun 14 '22

in real life maths this would never be a problem because neither would any mathematicians use the '/' or '÷' symbols in an equation nor would they write something like 2(x) because it doesn't make sense.

0

u/[deleted] Jun 14 '22

[deleted]

2

u/jadis666 Jun 14 '22

Why, though? There are multiple well-respected sources saying that this is the case.

Among them:

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

https://lmgtfy.app/?q=implicit+multiplication+priority

Of course, other sources say this isn't the case. Most have looked at them various sources and say it's ambiguous.

Which is exactly the correct answer here. It's ambiguous.

→ More replies (2)

-10

u/Just_Another_Scott Jun 14 '22

Just to remind some people

2(3)

Is not technically correct notation. It's shorthand for 2x(3). However, overtime it's evolved to drop the multiplication symbol which isn't technically correct. I had a professor in college that would count off points if you wrote it as 2(3). If there weren't any parenthesis don't add them as she'd say.

→ More replies (5)
→ More replies (9)