phi(n) (the Euler phi-value of n ), if I have time...

I would like to touch briefly on that critical "phi_n" ( my notation above). phi(n) - the Euler phi function - came on the mathematical scene through Euler's classic generalization of Fermat's little theorem (I have devoted an entire section of my web site - with my personal year-2001 homage-lecture to mark the 400th anniversary of Fermat's birth - to that classic theorem):
Fermat's little theorem. Let p be prime, and a be any integer not divisible by p , then a^(p-1) leaves remainder 1 on division by p .

Euler's generalization of Fermat's theorem. Let n be any natural number ( 1 < n , prime or otherwise), and a be any integer such that gcd( a , n ) = 1, then a^phi(n) leaves remainder 1 on division by n (where phi(n) is the number of integers between 1 and ( n-1 ) that share no common factor, greater than 1 , with n ).

Euler's beautiful formula for phi(n) . phi(n) = n Product(1-1/p[r]) , where the product is evaluated over the distinct prime divisors p[1], p[2], p[3] , ... of n .

Two examples only:

1. When n = p , is itself a prime, phi(n) = phi(p) = p*(1-1/p) = p*(p-1)/p = p-1 , the ' p-1 ' of
Fermat's little theorem.

2. When n = pq , the product of two distinct primes,

phi(n) = phi(pq) = (p*q)(1-1/p)*(1-1/q) = p*q*(p-1)/p*(q-1)/q = (p-1)*(q-1) ,


the ' (p-1)*(q-1) ' of the RSA method.

Maple has a command for computing phi(n) (it requires loading Maple's Number Theory package; the items are alphabetically listed, and 'phi' is just after 'pdexpand')

> with(numtheory);

Warning, the protected name order has been redefined and unprotected

[GIgcd, bigomega, cfrac, cfracpol, cyclotomic, divi...
[GIgcd, bigomega, cfrac, cfracpol, cyclotomic, divi...
[GIgcd, bigomega, cfrac, cfracpol, cyclotomic, divi...
[GIgcd, bigomega, cfrac, cfracpol, cyclotomic, divi...

> phi(13);

12

> phi(15);

8

> phi(25);

20

> phi(12345678910987654321);

12345678910987654320

>

> p[1] := nextprime(1234);

p[1] := 1237

> q[1] := nextprime(5678);

q[1] := 5683

> n[1] := p[1]*q[1];

n[1] := 7029871

> n[1]*(1 - 1/p[1])*(1 - 1/q[1]); # Euler formula

7022952

> phi(n[1]); # Maple command

7022952

>

But what about, say:

> p[2] := nextprime(10^24 + rand()^2);

p[2] := 1311876140800314942488681

> length(p[2]);

25

> q[2] := nextprime(10^29 + 54321*rand()^2);

q[2] := 130291632156830344656809567537

> length(q[2]);

30

> n[2] := p[2]*q[2];

n[2] := 1709264835724768072795950174573954357856535...

>

Here NOW - I hope - you will see the difference:

> n[2]*(1 - 1/p[2])*(1 - 1/q[2]); # Euler formula

170926483572476807279594887164451402814508622375492...

BUT FOR:

> # phi(n[2]);

the computation clock comes on... Maple cannot quickly compute phi(n[2]) because - to do so - it needs to factor n[2] in order to find p[2] and q[2] , to use Euler's formula to evaluate phi(n[2]) , and here they have only 25 and 30 digits... That should explain to you why earlier I had to define 'phi_nA' (with the known values of pA and qA) in the RSA demonstration: Maple could not itself have carried out the computation had I used phi(nA)...

Contact details 

After August 31st 2007 please use the following Gmail address: jbcosgrave at gmail.com


This page was last updated 18 February 2005 15:08:21 -0000