5 ms·
Is "commute" the right word for that? I'm not a mathematician, but it doesn't match any usage in my poorly trained math-lang semantic net.
by sblom 6y ago
Is "commute" the right word for that? I'm not a mathematician, but it doesn't match any usage in my poorly trained math-lang semantic net.
- henryfjordan 6y agoAccording to the Wikipedia page on the commutative property, "commute" is the right word. > If the commutative property holds for a pair of elements under a certain binary operation then the two elements are said to commute under that operation. https://en.wikipedia.org/wiki/Commutative_property https://en.wikipedia.org/wiki/Commutative_property
- konjin 6y agoNo, it's called distributive property: https://en.m.wikipedia.org/wiki/Distributive_property https://en.m.wikipedia.org/wiki/Distributive_property
- henryfjordan 6y agoAfter some further reading, I don't think anyone in this thread is correct. Modulo in math is not an operator like a programmer might think of it. See: https://math.stackexchange.com/questions/2832649/modular-arithmetic-and-the-distributive-property https://math.stackexchange.com/questions/2832649/modular-ari...
- vitus 6y agoRight. This is a consequence of compatibility with exponentiation. https://en.wikipedia.org/wiki/Modular_arithmetic#Properties https://en.wikipedia.org/wiki/Modular_arithmetic#Properties It should be easy to see that n ≡ (n % 15) (mod 15) which, applying compatibility of exp, then gives us n^4 ≡ (n % 15)^4 (mod 15) which can be rewritten in Python's notation as n**4 % 15 == (n % 15) ** 4 % 15
- edflsafoiewq 6y agoThe injection mod15: Z -> Z/15 is an operation and the basic idea here is mod15(pow4(x)) = pow4(mod15(x)), so I think it's correct to call it commutativity.
- vitus 6y agoWell, not quite. You really want to say that mod15(pow4(x)) == mod15(pow4(mod15(x))). Example: (3 ** 4) % 15 = 81 % 15 = 6. But, (3 % 15) ** 4 = 3 ** 4 = 81. (That said, the two functions do commute when you restrict your domain and range to Z/15.) edit: also, I wouldn't consider mod15 to be an injection, as it's, um, not injective (it maps multiple inputs to the same output).
- edflsafoiewq 6y agopow4(mod15(x)) is already in Z/15, you can't apply mod15 to it. The point is pow4ing in Z and then reducing mod 15 is the same as reducing mod 15, then pow4ing in Z/15. It's not actually the same pow4 on the LHS and RHS (the LHS is in Z, the RHS in Z/15), but I think "commutative" still fits. > as it's, um, not injective Er, surjection :)
- vitus 6y agoWell, how about this, if we use pow4' to be modular exponentiation, i.e. mod15 o pow4? (of course then changing mod15 to take Z -> Z so the types line up) Then the desired statement showing commutativity is pow4'(mod15(x)) = pow4'(x) = mod15(pow4'(x)) where that last equality is trivial because mod15 o mod15 = mod15 so mod15 o pow4' = mod15 o mod15 o pow4 = mod15 o pow4 = pow4' per associativity of function composition
- ChrisLomont 6y agoI'm a PhD in math. Modulo is a function in that it maps integer to integers. Power is a function mall mg integers to integers. Both are operators in the math sense, and one can talk about operators commuting. So the terms are correct. As far as programmers, modulus is an operator, complete with operator overloading in many languages and satisfying operator precedence. So operator is the correct word there also. Here's the idea from math https://mathoverflow.net/questions/20968/rules-for-operator-commutativity https://mathoverflow.net/questions/20968/rules-for-operator-...
- joppy 6y agoIt's roughly the right word for it - mathematicians would say that operations f and g commute if f(g(x)) = g(f(x)) for all x. In this specific case it is not quite true that (^4) and (%15) commute, but if we treat (%15) as returning an element of the-integers-modulo-15 then it is true that the two operations precisely commute. (I think people would say "they commute" anyway, because colloquially it's close enough).