User:Marty/UCSC Math 110 Fall 2008/Week 7

This week, we are covering many topics from modular arithmetic.
 * Invertible residues, and Euler's totient.
 * The Fermat-Euler theorem, and its special case, Fermat's little theorem.
 * We also cover the Chinese remainder theorem, and applications to systems of congruences and the totient.

=Finding Multiplicative Inverses=

We begin with the following theorem: $$ ab \equiv 1, \mbox{ mod } m.$$
 * If $a \in \ZZ$, $m \in \ZZ$, $m > 0$, and $GCD(a,m) = 1$, then there exists $b \in \ZZ$ such that:
 * In other words, $\bar a \cdot \bar b = \bar 1$ (modulo $m$). The residue $\bar b$ is called the multiplicative inverse of the residue $\bar a$.

Finding multiplicative inverses can be performed using the Euclidean algorithm. Indeed, in order to find an integer $b$, such that $ab \equiv 1$, mod $m$, it is necessary and sufficient to find two integers $b,k$ such that $ab - 1 = mk$. Thus, it suffices to solve the Diophantine equation $ab - mk = 1$ (where $a,m$ are known, and $b,k$ are unknown). This skill has been covered previously.

=Solving one linear congruence in one variable=

By finding a multiplicative inverse, one can solve many linear congruences. Consider the following:
 * Find $x \in \ZZ$ (or a residue $\bar x$) such that $\bar 5 \cdot \bar x = \bar 3$, modulo $13$.

Since $GCD(5,13) = 1$, we can find a multiplicative inverse to $\bar 5$, modulo $13$. Namely, $\bar 5 \cdot \bar 8 = \overline{40} = \bar 1$, modulo $13$. Hence, multiplying both sides of the equation $\bar 5 \cdot \bar x = \bar 3$ by $\bar 8$ yields: $$\bar 8 \cdot \bar 5 \bar x = \bar 8 \cdot \bar 3, \mbox{ modulo } 13.$$ Hence $\bar x = \overline{24} = \overline{11}$, modulo $13$. The solution is:
 * $\bar x = \overline{11}$, modulo $13$.
 * To translate, $5x - 3$ is a multiple of $13$ if and only if $x - 11$ is a multiple of $13$.

=Chinese Remainder Theorem=

According to the Chinese remainder theorem, a system of two congruences, with relatively prime moduli, is equivalent to a single congruence, modulo the product of the two moduli. For example, the following two statements (the first of which has two parts) are equivalent:
 * 1)  The following two congruences hold:
 * 2) * $x \equiv 3$, mod $5$.
 * 3) * $x \equiv 2$, mod $7$.
 * 4)  The following single congruence holds:
 * 5) * $x \equiv 23$, mod $35$.

In order to deduce the single congruence from the pair of congruences, one must either use a "guess and check" method, or use the Euclidean algorithm. Here is a sample "guess and check":
 * Note that the numbers between $0$ and $34$, which are congruent to $3$, mod $5$, are:
 * $3$, $8$, $13$, $18$, $23$, $28$, $33$.
 * Note that the numbers between $0$ and $34$, which are congruent to $2$, mod $7$, are:
 * $2$, $9$, $16$, $23$, $30$.
 * There is a unique number in both of these lists. This common number is $23$.
 * Hence, if $x \equiv 3$, mod $5$, and $x \equiv 2$, mod $7$, then $x \equiv 23$, mod $35$.

Here is a sample solution, using a linear Diophantine equation:
 * If $x \equiv 3$, mod $5$, then $x = 5a + 3$, for some $a \in \ZZ$.
 * If $x \equiv 2$, mod $7$, then $x = 7b + 2$, for some $b \in \ZZ$.
 * Hence $5a + 3 = 7b + 2$, for such $a,b$.
 * Hence $5a - 7b = -1$.
 * Using guess and check, or the Euclidean algorithm, one finds the solution $a = -3$, $b = -2$ to this equation.
 * This solution yields $x = 5a + 3 = -15 + 3 = -12$.
 * $-12$ is congruent to $23$, modulo $35$.
 * Hence, if $x \equiv 3$, mod $5$, and $x \equiv 2$, mod $7$, then $x \equiv 23$, modulo $35$.

Going from a single congruence to a pair of congruences is much simpler. Namely, if $a$ divides $m$, then a congruence modulo $m$ implies the same congruence modulo $a$. In other words, if $a$ divides $m$ then: This can be seen by translation:
 * $x \equiv y$, modulo $m$ implies that $x \equiv y$, modulo $a$.
 * $x - y$ is a multiple of $m$, and $m$ is a multiple of $a$, implies that $x-y$ is a multiple of $a$.

Hence, if one was given that $x \equiv 23$, modulo $35$, then one could deduce that:
 * $x \equiv 23$, mod $5$, and hence $x \equiv 3$, mod $5$.
 * $x \equiv 23$, mod $7$, and hence $x \equiv 2$, mod $7$.

=Fermat-Euler Theorem=

The Fermat-Euler theorem states the following:
 * If $a \in \ZZ$, $m \in \ZZ$, $m > 0$, and $GCD(a,m) = 1$, then the following (equivalent) statements are true:
 * $\bar a^{\phi(m)} = \bar 1$, modulo $m$.
 * $a^{\phi(m)} \equiv 1$, mod $m$.
 * $a^{\phi(m)} - 1$ is a multiple of $m$.
 * If $e,f \in \ZZ$, and $e \equiv f$, modulo $\phi(m)$, then $a^e \equiv a^f$, modulo $m$.

It is most useful for simplifying large exponents in modular arithmetic. For example, suppose that we are working "mod $13$". Notice that $\phi(13) = 12$. It follows that:
 * $\bar 2^{12} = \bar 1$, modulo $13$.
 * Hence $\bar 2^{24} =\bar 1$, modulo $13$.
 * Hence $\bar 2^{120000} = \bar 1$, modulo $13$.
 * Hence $\bar 2^{120002} = \bar 4$, modulo $13$.
 * In general, $\bar 2^e = \bar 2^f$, whenever $e \equiv f$, modulo $12$.
 * When working with congruences, mod $13$, the exponents naturally "live modulo $12$".

What about exponents when $GCD(a,m) \neq 1$? We can separate out a congruence into two congruences using the Chinese remainder theorem. Consider the following:
 * What is $6^{1000}$, modulo $33$?
 * We can separate this into two congruences, one modulo $3$ and one modulo $33$, then later put our results together.
 * What is $6^{1000}$, modulo $3$?
 * What is $6^{1000}$, modulo $11$?
 * First, note that $6 \equiv 0$, modulo $3$.
 * Hence $6^{1000} \equiv 0$, modulo $3$.
 * Next, note that $6^{10} \equiv 1$, modulo $11$, by the Fermat-Euler theorem (since $10 = \phi(11)$)
 * Hence $6^{1000} \equiv 1$, modulo $11$.
 * Therefore, $6^{1000}$ is congruent to $0$, mod $3$, and to $1$, mod $11$.
 * Hence $6^{1000}$ is congruent to $12$, modulo $33$
 * $12$ is the unique residue, modulo $33$, which is congruent to $0$ mod $3$ and to $1$ mod $11$.

=Computing the Totient= Euler's totient satisfies the following basic properties:
 * $\phi(p) = p-1$, if $p$ is a prime number.
 * $\phi(p^n) = p^n - p^{n-1}$, if $p$ is a prime number, and $n$ is a positive integer.
 * If $a$ and $b$ are positive integers, and $GCD(a,b) = 1$, then $\phi(ab) = \phi(a) \cdot \phi(b)$.

Putting these rules together, we can compute the totient of any positive integer. For example:
 * What is $\phi(700)$?
 * Well, $700 = 7 \cdot 2^2 \cdot 5^2$.
 * $\phi(7) = 6$, since $7$ is prime.
 * $\phi(2^2) = 2^2 - 2^1 = 2$, since $2$ is prime.
 * Hence $\phi(7 \cdot 2^2) = 6 \cdot 2 = 12$, since $GCD(7, 2^2) = 1$.
 * $\phi(5^2) = 5^2 - 5^1 = 20$, since $5$ is prime.
 * Hence $\phi(7 \cdot 2^2 \cdot 5^2) = \phi(7 \cdot 2^2) \phi(5^2) = 12 \cdot 20 = 240$, since $GCD(7 \cdot 2^2, 5^2) = 1$.
 * Thus, $\phi(700) = 240$.

Most generally, if $n$ is a positive integer, then $n$ has a canonical decomposition: $$n = \prod_{p \in P} p^{e_p},$$ for some natural numbers $e_p$. The totient of $n$ is then given by: $$\phi(n) = \prod_{p \in P} \phi(p^{e_p}) = \prod_{p \in P} \left( p^{e_p} - p^{e_p - 1} \right),$$ where in the final product, one only includes primes $p$ such that $e_p \geq 1$.

For example, using this formula, $$\phi(700) = \phi(7 \cdot 2^2 \cdot 5^2) = \phi(7) \phi(2^2) \phi(5^2) = (6)(2^2 - 2^1) (5^2 - 5^1) = (6)(2)(20) = 240.$$