I tried to find out what $n$ mod $0$ is, for some $n\in \mathbb{Z}$. Apparently it is an undefined operation - why?
-
$\Bbb Z\bmod 0 = \Bbb Z/0,\cong, \Bbb Z,$ and this does prove useful. For elaboration see my comments below. $\ \ $ – Bill Dubuque Nov 22 '24 at 20:49
5 Answers
I might say it depends on how you define what it means to mod out by a number.
A typical first way of thinking about mods is to say that $a \equiv b \pmod d$ if $a = b + dk$ for some integer $k$. In this sense, there is nothing wrong with saying $a \equiv b \pmod 0$, although this says nothing more than $a = b$.
A different first way of thinking about mods is to say that $a \equiv b \pmod d$ if when you divide $a$ by $d$, you get remainder $b$ (or something very similar). In this sense, as it does not make sense to divide by $0$, we are at a loss.
A typical higher idea is to consider $\mathbb{Z}$ as a group, and for the 'mod by $d$' operation to mean the equivalence classes induced by taking cosets of the subgroup generated by $d$, which I'll denote by $\langle d \rangle$. In this sense, the subgroup $\langle 0 \rangle$ is the trivial subgroup, so modding out by $0$ falls more along the lines of the first way of thinking I mentioned above : it's well-defined, but not really useful.
- 94,345
-
2
-
2Well, it’s useful in the same sense that zero, the empty set, etc. are useful. – user76284 Jul 10 '20 at 18:36
In general, $x = n \pmod a$ is defined by letting $x$ be the remainder of $n$ upon division by $a$. But division by zero isn't well-defined.
Added from comment: As mixedmath points out, the use of the idea of "modulo" has a higher definition as a group theoretic concept in which regarding numbers $\pmod{n}$ is equivalent to considering cosets $n\Bbb{Z}$ in the group of integers and forming the quotient group $\Bbb{Z}/n\Bbb{Z} = \Bbb{Z}_n$. But then taking $n = 0$ doesn't really tell you anything, since the quotient group is just $\Bbb{Z} / 0 \cong \Bbb{Z}$.
Depends on how you define "mod". If you mean "the remainder after dividing", you can't divide by zero, so it's not defined.
However, another way of thinking about mods is as an equivalence relation. We can define it as $$a \equiv b \pmod{n} \iff n \mid (a-b)$$ where $x \mid y$ means "$x$ divides $y$". In this case, $a \equiv b \pmod{n}$ if and only if $0 \mid (a -b)$, which just means $a = b$.
Lastly, the most general way to think of mods is by using ring theory. Take a ring $R$. An ideal $I$ in $R$ is a subring that is contagious under multiplication, so for all $a \in R$, $x \in I \implies ax \in I$. So for the integers, an ideal might be $I = \{\cdots, -10, -5, 0, 5, 10, \cdots\}$, because if you multiply a multiple of five by something, it's still a multiple of five.
Given a ring and an ideal, we can construct a subring, $R/I$, referred to as "$R$ mod $I$". The elements in this ring are cosets of this ideal. For this example, the coset of $1$ would be $1 + I = \{\cdots, -9, -4, 1, 6, 10, \cdots\}$. Instead of adding and multiplying whole sets, we can pick any representative, and multiplication and addition still end up well-defined. This is modular arithmetic! $1 + 3 \equiv 6 + 3 \equiv -9 + 3 \pmod{5}$, after all.
As for the answer to your question, notice that "the integers mod $n$" is the same as $\mathbb{Z}/n\mathbb{Z}$. So if we let $n = 0$, we mod out by the zero ideal (i.e., $I = \{0\}$), the coset of $a$ would just be $\{a\}$, and we get something isomorphic to $\mathbb{Z}$ again. In other words, $n$ mod $0$ is $n$.
- 282,220
- 13,278
-
:Could you tell me is
mod 0defined in the equivalence relation for congruent modulo since when an number is divided by zero it's undefined so could we have such a number in the set of an equivalence relation. – justin Jan 30 '15 at 13:43 -
1The trick is "a divided by b" vs "b divides a". The latter is defined as "there exists an $x$ such that $bx = a$". But the former is defined only when that $x$ is unique (because it returns that $x$). So even though $0/0$ is undefined, $0 \mid 0$, because there exists an $x$ such that $0x = 0$ (every $x$, actually). But zero doesn't divide anything else, because $0x$ is always zero. – Henry Swanson Jan 30 '15 at 19:42
-
:I can't understand the concept you're trying to explain it might be because I haven't fully gone through these concepts.I'm really confused at whether integer
0is in the equivalence relation for congruent modulo.Could you first tell me is the remainder of the congruent modulo included in the set of equivalence relation or do we just have the modulus in the equivalence relation.If the remainder is not included in the equivalence relation then we might not need to bother about a number divided by zero isn't it? – justin Jan 31 '15 at 04:54
Undefined? Since when?
It’s not hard to find a mathematical text that does give a definition for $n \bmod 0$. Indeed, The Art of Computer Programming, Volume 1 by D. Knuth (1969); §1.2.4, p. 38) defines $\bmod$ thus:
If $x$ and $y$ are any real numbers, we define the following binary operation:
$$ x \bmod y = x - y \lfloor x / y \rfloor, \quad \text{if $y \ne 0$;} \quad\quad x \bmod 0 = x. $$
This definition is repeated in Concrete Mathematics (2nd Ed., §3.4, p. 82), also by Knuth, with Ronald Graham and Oren Patashnik. So there. It’s defined. And since Knuth and his monograph in particular is not just some random piece of academia nobody heard of, I suspect – though have not investigated – that this is might be in fact the origin of the “mod” notation for remainder in programming.
And it turns out there are reasons for it other than definitional fiat. Normally we want $x - (x \bmod y)$ to be an integer multiple of $y$ close to $x$. Since the only multiple of zero is zero, this condition forces $x \bmod 0$ to equal $x$. This agrees with the informal interpretation that “$f(x) \bmod y$ is $f(x)$ that loops back to zero at multiples of $y$”. $x \bmod y$ is often constrained by other conditions too (like for example $|x \bmod y| < |y|$ and $|y - 2(x \bmod y)| ≤ |y|$), but those are meant to disambiguate what “close to $x$” means, and which “close” value is chosen in case there is ambiguity – and for $y = 0$, there is no ambiguity, so those other conditions can be disregarded in this case.
So I would say if you meet someone who declines to define $x \bmod 0$, it’s they who have to justify it. Consider that they might have merely failed to define it out of neglect.
- 349
-
1Wikipedia says: “$a\text{ modulo }0$ is undefined in most systems, although some do define it as $a$.” – Soham Saha Nov 22 '24 at 15:11
-
1There are better "reasons" motivating this convention, e.g. as I mention here this convention implies that congruences always persist mod divisors of the modulus. Thus when the modulus $= 0,,$ since $,n\mid 0,,$ this means that solutions of Diophantine equations in integers $(!!\bmod 0)$ persist as modular solutions $(!!\bmod n>0),,$ so we can prove that there are no integer solutions if there are no modular solutions, a basic ubiquitous method (e.g. parity analysis). – Bill Dubuque Nov 22 '24 at 20:43
-
1Note: if we use the $!\bmod $ (congruence) relation (vs. operator) the the above property reformulated in the language of ideals is simply the universal property of quotient rings. In ring theory quotients by zero ideals do in fact often arise as (useful) special cases of general results (e.g. here) so it would be unnatural and inconvenient to exclude them. $\ \ $ – Bill Dubuque Nov 22 '24 at 20:44
-
$r = n\mod x$ means that
$ 0 \leq r < x$
for some $a$, $n = x a + r$
when $x=0$, the first condition cannot be satisfied.
- 4,613