Section9.3Using Euler's Theorem

Euler's Theorem has many uses. We will begin with its use in computation.

Subsection9.3.1Inverses

For instance, one has to be just a little clever to use it to compute inverses mod \((n)\).

If \[a^{\phi(n)}\equiv 1\text{ mod }(n)\; ,\] then certainly multiplying both sides by \(a^{-1}\) yields \[a^{\phi(n)-1}\equiv a^{-1}\text{ mod }(n)\; .\] We can check this using Sage.

Let's pick a congruence we wanted to solve earlier, like \[53y\equiv 29\text{ mod }(100)\] and try to solve it with this. Instead of all the stuff we did before, we could just multiply both sides by the inverse of 53 in this form. \[53y\equiv 29\text{ mod }(100)\] \[53^{\phi(100)-1}\cdot 53y\equiv 53^{\phi(100)-1}\cdot 29\text{ mod }(100)\] After the theorem, we get \[1\cdot y\equiv 29\cdot 53^{\phi(100)-1}\text{ mod }(100)\; .\] You could conceivably do this by hand using our tricks for powers; it would look like the following in Sage.

This answer jells with our previous calculation. And now I didn't have to solve a different linear congruence in order to solve my original one; I just have to have a way to do multiplication mod \((n)\).

Remark9.3.1

Sage note:
Notice that Sage has a command to get the Euler phi function, namely euler_phi(n). This doesn't have the direct connection to the group, but is easier to use than Integers(n).unit_group_order().

Subsection9.3.2Using Euler's Theorem with the CRT

We can use this to do Chinese Remainder Theorem systems much more easily, as long as we have access to \(\phi\).

Remember the algorithm for the CRT, where we tried to solve systems like this:

  • \(x\equiv a_1\) mod (\(n_1\))
  • \(x\equiv a_2\) mod (\(n_2\))
  • \(\cdots\)

There, we had to calculate many solutions to congruences of the form \[\frac{N}{n_i}x\equiv 1\text{ mod }(n_i)\; .\] (This was to get the \(d_i\) numbers.) Our new information means that this inverse is just \[\left(\frac{N}{n_i}\right)^{-1}\equiv \left(\frac{N}{n_i}\right)^{\phi(n_i)-1}\; ,\] since we are looking at a congruence modulo \(n_i\).

So the things in the final solution which looked like \[a_i\cdot \frac{N}{n_i}\cdot \left(\frac{N}{n_i}\right)^{-1}\] can be thought of as \[a_i\cdot \frac{N}{n_i}\cdot \left(\frac{N}{n_i}\right)^{\phi(n_i)-1}=a_i\left(\frac{N}{n_i}\right)^{\phi(n_i)}\; ,\] which is much cooler and simpler! So the answer to the general system is just \[x\equiv \sum_{i=1}^k a_i \Big(\frac{N}{n_i}\Big)^{\phi(n_i)}\, .\]

Remark9.3.2

Sage note:
It's possible to do it more concisely if you know a little Python and something called 'list comprehension'.

But that's not necessary for our purposes.

Example9.3.3

We can do this one step even better. Take a huge system like

  • \(3x\equiv 7\) mod (10)
  • \(2x\equiv 5\) mod (9)
  • \(4x\equiv 1\) mod (7)
Can we find solutions for this using the same mechanism? Yes, and without too much difficulty now.

Since one can solve \(bx\equiv c\) mod (\(n\)) with \[x\equiv b^{\phi(n)-1}\cdot c\; ,\] any likely system of congruences with coprime moduli \[b_i x\equiv c_i\text{ mod }(n_i)\] where \(N\) is the product of the moduli could be solved by \[x\equiv \sum_{i=1}^k \left(b_i^{\phi(n_i)-1}c_i\right)\left(\frac{N}{n_i}\right)^{\phi(n_i)}\text{ mod }(N)\, .\]

Let's use this to solve this system.

Notice that we make as much stuff modulo \(M\) to begin with as possible. Even for bigger numbers, asking Sage to first make things modular is a big help – it takes essentially no time!

Example9.3.4

We can demonstrate this with a much larger example, picking essentially random large primes to compute with.