Euler's totient function, denoted , counts the positive integers up to a given integer that are relatively prime to , meaning their greatest common divisor with is 1.
The precise definition states that for any positive integer , the value of equals the number of integers in the range such that .
Take a prime number . All positive integers less than are relatively prime to .
For a prime power , where is prime and is a positive integer, the totient function is:
This only arises because among the numbers from 1 to , exactly those that are divisible by are not relatively prime to . There are such numbers.
One of the most valuable properties of Euler's totient function is its multiplicativity.
If and are coprime (i.e. ), then:
This let's us compute for any integer by first finding its prime factorization. Given , where each is a distinct prime, we have:
Substituting the formula for prime powers, we get:
Which simplifies to:
The time complexity of computing depends on the algorithm. Using the formula above requires finding the prime factorization of , which has a time complexity of using the general number field sieve (GNFS) for large integers.
Although, for practical purposes with reasonably sized numbers, the complexity is expressed as using trial division methods.
The space complexity for computing is as we need to store the prime factorization of .
Euler's totient function appears in several important theorems in number theory. One of the most significant is Euler's theorem, which states that if and are coprime, then:
This is a generalization of Fermat's Little Theorem, which states that if is prime and is not divisible by , then:
Note that for a prime , we have , which aligns the two theorems.
In RSA, the security relies on the difficulty of factoring large composite numbers. The encryption and decryption operations use modular exponentiation, with the decryption key satisfying:
Where is the encryption key and is the product of two large primes.
The computational complexity of modular exponentiation used in RSA is using the square-and-multiply algorithm which is way faster than attempting to factor to find directly.
Another important result of is the formula for the sum of over all divisors of :
It's an elegant result that relates the totient function and the structure of integer divisors.
E.g. let's compute this sum for :
The divisors of 12 are: 1, 2, 3, 4, 6 and 12
Sum:
As predicted, the sum equals .
The Möbius inversion formula provides a way to express in terms of the Möbius function .
The Möbius function is defined as:
if has a squared prime factor
if is the product of distinct primes
Computing using this approach has a time complexity of if we precompute the Möbius function using the sieve of Eratosthenes.
Euler's totient function also appears in the context of cyclotomic polynomials. The -th cyclotomic polynomial, denoted , is the minimal polynomial over the rational numbers of the primitive -th roots of unity. The degree of is precisely .
For example, and , confirming that the degree is .
The totient function satisfies several interesting identities and inequalities.
The average order of the totient function is:
This means that as grows, the average value of for from 1 to approaches .
Computing for a large range of values can be done using the sieve method. If we want to compute for all from 1 to , the time complexity is and the space complexity is .
The algorithm proceeds as follows:
Initialize an array with for all
For each prime from 2 to :
If (meaning is still marked as a prime):
Subtract by for all multiples of up to
This applies to all numbers simultaneously.
Let's compute some values of for small .
(only 1 is coprime to 1)
(only 1 is coprime to 2)
(1 and 2 are coprime to 3)
(1 and 3 are coprime to 4)
(1, 2, 3 and 4 are coprime to 5)
(1 and 5 are coprime to 6)
The Chinese Remainder Theorem (CRT) is closely related to Euler's totient function. CRT states that if are pairwise coprime positive integers, then the system of congruences:
has a unique solution modulo .
The number of solutions to the congruence is related to the prime factorization of and can be expressed in terms of for certain types of .
In group theory, if is a finite abelian group, then the number of elements of order in is either 0 or . This is useful in the study of the multiplicative group of integers modulo , denoted , which has order .
For prime , the multiplicative group is cyclic of order . A generator of this group is called a primitive root modulo.
The complexity of finding a primitive root modulo is using deterministic algorithms or using probabilistic algorithms.
Euler's totient function is also related to the Carmichael function, which gives the smallest positive integer such that for all integers coprime to . The Carmichael function always divides and equals when is 1, 2, 4, a power of an odd prime or twice a power of an odd prime.
In the context of computational number theory, algorithms for computing can be optimized using various techniques. E.g. if we have access to the prime factorization of , we can compute in time where is the number of distinct prime factors of .
Research on the distribution of values of has revealed interesting patterns. E.g. can have multiple solutions, meaning there exist distinct integers that share the same totient value. The smallest such pair is since .
The totient function has connections to perfect numbers as well. A perfect number is equal to the sum of its proper divisors. If is prime (making it a Mersenne prime), then is a perfect number and .