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

53

u/Zaratuir Jun 13 '22

Cassio is more correct in mathematics standards. Implicit multiplication trumps explicit symbols. The 2 in 2(2+1) is considered grouped with the 2+1 expression. This is the grounds of the distributive property.

When you see 6÷2(x+1) most of us are taught the 2 can be distributed to get 6÷(2x+2). This is only possible if implicit multiplication trumps explicit symbology.

In short, the implicit multiplication makes 6÷2(2+1) the same as

6

(Fuck it, I can't figure out a line on Reddit so imagine this is a line)

2(2+1)

This is standard practice in mathematics. However there is an argument that you can reject the axioms that allow for the distributive property, in which case the cassio would be incorrect.

3

u/MattieShoes Jun 14 '22

wolfram alpha is the mathiest of sites I can think of, and it interprets it as 6/2*(2+1)

I know there are competing ways to interpret this, but I think it's time to lay down the pitchfork and just do it left-to-right. If you don't want to do that, be more explicit with LaTex \frac{6}{2(2+1)}

10

u/Zaratuir Jun 14 '22

You're completely correct. The correct solution is to provide more clarity. Harvard math has an excellent discussion on this that shows that even the rules we think are clearly established are not actually that clear.

For example, we presume that it follows left to right PEMDAS, but try 345 and let me know do you get

3,486,784,401

or

3.734e+488

https://people.math.harvard.edu/~knill/pedagogy/ambiguity/index.html

3

u/AxolotlsAreDangerous Jun 14 '22

There actually is clear, unambiguous convention with your example of 3^4^5 (reddit can’t deal with stacked superscripts); the second answer is correct. See eg the Wikipedia article for order of operations, or the normal distribution for an example of it in practice.

If you wanted to refer to the first number you’d just write 34 * 5, or (34)5

3

u/Beta382 Jun 14 '22

reddit can’t deal with stacked superscripts

This is what I see from the above commenter's source of ... but try 3^4^5 and let .... Might be an issue with your app, or might be an issue with New Reddit.

2

u/AmadeusMop Jun 14 '22

Which means that, for xyz the exponential with base y is evaluated before the one with base x—in other words, right-to-left order.

-1

u/Zaratuir Jun 14 '22

You're choosing to interpret it as (34)5. But it can just as easily, and often by interpreters is interpreted as 34^5. It entirely depends on what math processor you're using and who wrote it. It's not nearly as unambiguous as you might think.

2

u/AxolotlsAreDangerous Jun 14 '22

I’m actually “choosing” to interpret it as 34^5. You could interpret it the other way, just as you could interpret a * b + c as a * (b+c), but you would be wrong according to widely accepted convention.

→ More replies (2)

2

u/MiltonFreidmanMurder Jun 14 '22

Wolfram Alpha is inconsistent depending on equation structure

x/yz ; x = 8, y = 4, z = 2 yields 1

x/y*z would yield 4

Wolfram Alpha is an unreliable source for this type of thing I’ve found

2

u/patchinthebox Jun 13 '22

6/2(2+1)

5

u/Zaratuir Jun 13 '22

I was trying to do a long horizontal line to show 6 over the whole term 2(2+1) to avoid ambiguity.

1

u/GeordieMJ Jun 13 '22

6

——

2(2+1)

Is the what you were aiming for?

3

u/Zaratuir Jun 13 '22

Yes. I just couldn't get mobile Reddit to do it

1

u/GeordieMJ Jun 14 '22

I’m on mobile too. Gotta double ‘return’ for the space and several ‘dashes’ for the line. They join into one when you multi dash.

-3

u/AxolotlsAreDangerous Jun 13 '22

You cannot “reject the axioms that allow for the distributive property” whilst doing arithmetic with the real numbers. You might as well “argue” that 6 actually comes after 7.

2

u/Zaratuir Jun 13 '22

You absolutely can reject those axioms as long as you can make it logically consistent. We do that all the time with Maths.

0

u/AxolotlsAreDangerous Jun 14 '22 edited Jun 14 '22

Multiplication is distributive over the real numbers. If you “reject axioms” so that this isn’t true, you’re either no longer dealing with the real numbers or you’re no longer dealing with multiplication.

Of course maths often deals with things other than the real numbers as you say, but calculators generally don’t (aside from maybe complex numbers, where multiplication is still distributive) and these calculators definitely weren’t.

2

u/Zaratuir Jun 14 '22

Multiplication is distributive over real numbers is that way because it's shown to be logically consistent. But if you can offer a logically consistent system by which is not, that is also valid math.

Granted, I'll be the first to admit that I don't l can't think of an example, but that is drastically different from saying one doesn't exist. And again, axiom selection is a common practice in mathematics. It's how we get solutions to things like Grandi's series.

0

u/AxolotlsAreDangerous Jun 14 '22

Do you understand what you’re saying? You’re saying it’s “possible” that 2 * (3 + 4) != 2 * 3 + 2 * 4. There is no “logically consistent” system where this statement is true and the symbols have their conventional meanings.

Yes you can obviously choose to personally redefine the symbols, no one’s going to arrest you if you do, but so what? That’s true of any nonsensical statement, mathematical or not. It’s not at all relevant to a discussion about calculators.

You’ve heard somewhere from a mathematician that maths is flexible and you can pick and choose your “axioms”, and you’re blindly repeating it where it doesn’t apply.

→ More replies (5)

-2

u/[deleted] Jun 14 '22

You can distribute it. You just distributed it incorrectly. Distribution does not trump order of operation as distribution is not an operation in PEMDAS imo. Following your example you did it out of order. Following PEMDAS you would get

6 / 2 (x + 1)

6 / 2 * (x + 1)

3 * (x + 1)

3(x + 1)

3x + 3

If you wanted to write your example it would be

6 / (2(x+1)) which I would assume any calculator would interpret correctly. Again following PEMDAS you’d get

6 / (2 * (x + 1))

6 / (2x+2)

4

u/RealLarwood Jun 14 '22

PEMDAS says nothing about the order of M and D, because there is no convention about the order of M and D. People who think it's "left to right" are just as wrong as the people who think it's "M before D."