- #1
matqkks
- 285
- 5
Why can't we have modulo negative number? I have never seen this.
matqkks said:Why can't we have modulo negative number? I have never seen this.
Because a negative number ##-n=(-1)\cdot n## differs from its positive counterpart only by a unit, ##\varepsilon=-1##. So the ideals ##n\mathbb{Z}## and ##\varepsilon n\mathbb{Z}## are the same. This implies that the factor rings ##\mathbb{Z}[x]/n\mathbb{Z} = \mathbb{Z}_n = \mathbb{Z}[x]/\varepsilon n\mathbb{Z}## are equal, too. And as it makes no difference, it is a matter of convenience to choose the positive version. Otherwise the calculations were full of unnecessary signs.matqkks said:Why can't we have modulo negative number? I have never seen this.
I had been impressed, if it would have calculated the results in the standard representation, i.e. ##[0],[1],[2]##. This way its more an incidental result.FactChecker said:I don't see any conceptual difference between modulo of a positive versus negative integer. I am not sure if all computer languages would implement it. Perl does:
Integers 0..9 mod -3:
0 mod -3 = 0
1 mod -3 = -2
2 mod -3 = -1
3 mod -3 = 0
4 mod -3 = -2
5 mod -3 = -1
6 mod -3 = 0
7 mod -3 = -2
8 mod -3 = -1
9 mod -3 = 0
the situation with primes is the same: "up to units", because ##-3## is as prime as ##3## is. And that ##1## isn't a prime, is only because the definition starts with "A number is prime, if it is no unit and ..." It makes absolute sense to exclude units. E.g. nobody ever asked, whether the fundamental theorem of arithmetic is wrong, since we can always add units as many as we want to: ##6=2\cdot 3= 1\cdot 2\cdot 3= (-1)\cdot (-1)\cdot 2 \cdot 3 = 1\cdot 1\cdot 3\cdot 2\cdot 1 =\ldots ## Units simply don't change the game, so why bother them?PeroK said:The same goes for allowing negative numbers to be prime.
there is no reason for them to apologize for a "happy coincidence" that turns out to be mathematically correct.fresh_42 said:Sure. But this isn't evidence for a smart programming of Perl as you implicitly suggested, but simply a logic outcome of ordinary arithmetic. An automated conversion into standard results would have been smart. The above is more or less an unintended result of a correct division.
Yes, but that's not the point. The point is, that similar to what led to the OP's question, the programmers completely ignored the role of units. In this sense, it is rather off-topic here than a support for the equation ##n\mathbb{Z}=-n\mathbb{Z}##. The example brought you no millimeter closer to the answer of the question. It only shows that you can do calculate with negative numbers, not why they are usually ignored in books.FactChecker said:there is no reason for them to apologize for a "happy coincidence" that turns out to be mathematically correct.
You can do arithmetic using negative bases for instance arithmetic base -2.matqkks said:Why can't we have modulo negative number? I have never seen this.
Because you confuse addition with multiplication. We are talking about multiplication here, since the module is ##z \,\,\cdot\,\, \mathbb{Z}\,##.FactChecker said:IMO, in any algebra, -x is the additive inverse of x. x + (-x) = 0. I see no issue with units.
No, it does not. It simply doesn't contribute anything to the answer of the question: Why are negative numbers ignored? It only shows, that the question has a justification, but nothing as to why this is the case.FactChecker said:I guess I don't see the problem. It seems natural and uncomplicated to extend the equivalence classes in the non-negative integers defined by mod 3 ({0,3,6,9,...}, {1,4,7,10,...},{2,5,8,11,...}) to include the negative integers ({...,-9,-6,-3,0,3,6,9,...}, {...,-8,-5,-2,1,4,7,10,...},{...,-7,-4,-1,2,5,8,11,...}). Does this cause a problem when multiplication is introduced? Off-hand, I don't see it.
The original OP question was "Why can't we have modulo negative numbers?". The answer is that we can. It is a natural extension of the concept to include negative integers. Then the OP asks why he has never seen it. The answer to that is that there is not much benefit.fresh_42 said:No, it does not. It simply doesn't contribute anything to the answer of the question: Why are negative numbers ignored? It only shows, that the question has a justification, but nothing as to why this is the case.
Yes, it is possible to perform modulo on a negative number. Modulo is a mathematical operation that finds the remainder when one number is divided by another. It can be applied to both positive and negative numbers.
When performing modulo on a negative number, the result will always be a positive number. This is because the absolute value of the negative number is taken before finding the remainder. For example, if we have -10 mod 3, the absolute value of -10 is 10, and the remainder when dividing 10 by 3 is 1, so the result is 1.
Modulo is a fundamental operation in mathematics and has many applications in fields such as computer science, physics, and engineering. Being able to perform modulo on negative numbers allows for more efficient and accurate calculations and modeling of real-world phenomena.
One limitation is that in some programming languages, the behavior of modulo on negative numbers may differ. For example, in Python, the result of -10 mod 3 is 2, while in Java, it is -1. It is important to check the specific language's documentation for the expected behavior.
Yes, negative numbers can be used as the divisor in modulo. The same rule applies where the absolute value of the negative number is taken before finding the remainder. For example, 10 mod -3 will result in a remainder of 1.