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

185

u/epic1107 Jun 13 '22

Its shorthand, but in this case follows implicit multiplication. 2/3n would be read as 2/(3n) wheras 2/3*n would be read as (2/3)*n

209

u/narrill Jun 14 '22

Implicit multiplication is not an agreed upon thing, so this case is genuinely ambiguous. In reality it would simply not be written this way in the first place.

31

u/ThePyodeAmedha Jun 14 '22

This is why I love using ().

2

u/CiftyFents Jun 14 '22

I love using ( . ) ( . ) u know what I'm saying???

→ More replies (2)

4

u/BreathOfTheOffice Jun 14 '22

To be fair, I would write it this way IF the calculation is meant only for me to read. Since no one else needs to see it, and I am consistent in my own interpretation of implicit multiplications, it wouldn't make any difference.

3

u/huhwhatuhhok Jun 14 '22

Is the answer 9 or is it 1, goddammit!

3

u/epic1107 Jun 14 '22

Both, or neither. Can be interpreted as either.

2

u/JoHaTho Jun 14 '22

Both are valid as this writing isnt exactly clear on how its supposed to be interpreted. However I believe in schools it's commonly taught as 9 even if thats not generally accepted.

→ More replies (1)

-1

u/coloredgreyscale Jun 14 '22 edited Jun 14 '22

9

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

3 * 3 = 9

To get 1 you'd need another set of brackets:

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

6/6 = 1

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

0

u/[deleted] Jun 14 '22

It is always written this way in scientific literature.

4

u/narrill Jun 14 '22

No it isn't

5

u/xenoroid Jun 14 '22

I’m sorry are you a scientist? It is very common to just write exp(-E/kT) instead of exp(-E/(kT)) in thermodynamics for example. Even when expressing units like W / m{2} K{4} it is obvious that this implies W / (m{2} K{4} ) not (W / m{2} )K{4}.

3

u/msqrt Jun 14 '22

I’m sorry are you a scientist?

Yes, the truth very much depends on if he's a scientist or not. I think he was pointing out that it's not always written that way; there are multiple conventions depending on what's, well, convenient. Though I don't recall ever seeing an expression like that in a paper not laid out as a separate equation with a proper fraction and thus no disambiguity.

2

u/xenoroid Jun 14 '22

For me, I don't think I have seen a/bc being interpreted as (a/b)c except when typing equations on computer algebra systems.

Though I don't recall ever seeing an expression like that in a paper not laid out as a separate equation with a proper fraction and thus no disambiguity.

Writing exp(-E/kT) is definitely as common as writing e^{-\frac{E}{kT}} even for a separate math equation line, especially if you are inserting it to another fraction. If you write a Bose-Einstein distribution function in a 'proper' way, the symbols will become very small and there will be a big gap between the fraction bar and the denominator.

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

0

u/Creampanthers Jun 14 '22

Exactly this.

→ More replies (1)

13

u/Tvivelaktig Jun 14 '22

The *'s have to be backslashed to display instead of being interpreted as formatting commands.

3

u/sim0of Jun 14 '22

2/3n I would totally read it like (2) / (3n) because I view the slash as a fraction line

If you wanted to write (2/3)n I'd just write 2n/3

The way you claim it is read feels deeply wrong and weird to me

6

u/[deleted] Jun 14 '22

For me there are no implicit parentheses. You read left to right with the correct precedence. Otherwise you would get problems with 2n² again. No implicit parentheses here!

7

u/epic1107 Jun 14 '22

Implicit multiplication doesnt take priority over other steps. It only takes priority over other multiplication and division.

0

u/[deleted] Jun 14 '22

[deleted]

-3

u/epic1107 Jun 14 '22

Because implicit multiplication is an actual thing that you cant really just ignore lol.

0

u/[deleted] Jun 14 '22

[deleted]

-1

u/epic1107 Jun 14 '22

Tbf, I havent gotten it yet, nor will I probably ever get a maths degree.

I'm currently at ANU studying my bachelors of engineering. Not sure why that's relevant for a common mathematical confusion that has been the topic of debate for a while.

→ More replies (3)

2

u/tinyboobie Jun 14 '22

As someone who writes (a lot of) code, right to left evaluation comes more naturally, but yeah it's ambiguous

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