-   Factoring (
-   -   Closed form solution of x^2 = 2 mod Fermat number (

mpenguin 2005-08-18 12:18

Closed form solution of x^2 = 2 mod Fermat number
Sorry if this is known, but didn't find it on the net.
The solution of x^2 = I in C leads to solution to x^2 = 2 mod (2^(2^n)+1).
It is also possible to compute sqrt(2+sqrt(2)) mod (2^(2^n)+1) and
similar roots rising from solutions in C.

Any use of this?

sq2:=mods(ii2*2/(1+ii),n); /* sq2^2 mod n == 2*/
sq2a:=mods(ii3*2/((ii*sq2+1-ii)),n); /* sqrt(2+sqrt(2)) mod n*/

alpertron 2005-08-18 14:35

sqrt(2) mod F_n in UBASIC
I translated the sqrt(2) program to UBASIC

10 input N0
20 N=2^(2^N0)+1
30 Ii=modpow(2,2^(N0-1),N)
40 Ii2=modpow(2,2^(N0-2),N)
50 Sq2=(Ii2*2*modinv((1+Ii),N))@N
60 print Sq2,Sq2^2@N

This is interesting, but it would be far more interesting to find another sqrt(2) that is not the negative of this one (mod F[sub]n[/sub]). This would allow to factor F[sub]n[/sub] and you will appear in math books :-) .

alpertron 2005-08-18 14:49

Unfortunately with the following code:

10 input N0
20 N=2^(2^N0)+1
30 Ii=modpow(2,2^(N0-1),N)
40 Ii2=modpow(2,2^(N0-2),N)
50 Ii3=modpow(2,2^(N0-3),N)
60 Sq2=(Ii2*2*modinv((1+Ii),N))@N
70 Sq2a=(Ii3*2*modinv((Ii*Sq2+1-Ii),N)@N)
80 print Sq2,Sq2^2@N
90 print ((Sq2a*Sq2a)-2)@N

I found that the values of sqrt(2) generated by calculating directly the sqrt(2) and calculating B=sqrt(2+sqrt(2)) and then B^2-2 = sqrt(2) are the same, so they cannot be used to factor F[sub]n[/sub].

mpenguin 2005-08-18 15:23

I am theory lamer, but according to wikipedia:

>Let n ≥ 3 be a positive odd integer. Then n is a Fermat prime if and only if for every a >coprime to n, a is a primitive root mod n if and only if a is a quadratic nonresidue mod >n.

Looks like sqrt(2) is not primitive root, so showing that it is nonresidue shows compositeness of Fn ?

The original program computes sq2a^2 = 2+sqrt(2)=sqrt(2)*(1+sqrt(2)) (at least in C)
so showing that any of sqrt(2),1+sqrt(2),1-sqrt(2) is nonresidue shows compositeness of Fn?

The above reasoning may be quite buggy :)

mpenguin 2005-08-18 16:14

When one takes the smaller absolute value of sq2 and sq2a ("signed mod") they have strange factorizations F[n] | sq2[n+i] and F[n] | sq2a[n+j].

alpertron 2005-08-18 16:47

Using n=5, F[sub]5[/sub] = 4294967297.

With your method you find sqrt(2) = 4278190337.

If you somehow find sqrt(2) = 1370209359, you will be able to factor F[sub]5[/sub] since gcd(F[sub]5[/sub], 4278190337 - 1370209359) = 6700417 which is a proper factor of the original number.

mpenguin 2005-08-19 16:05

sqrt(2) follows from:
fn(n) = fn(n-1)^2-2*(fn(n-2)-1)^2

fn(n) is the nth Fermat number

alpertron 2005-08-19 17:07

The code for sqrt(2) in UBASIC using your last post is:

10 input N0
20 N=2^(2^N0)+1
30 Ii=2^(2^(N0-1))
40 Ii2=2^(2^(N0-2))
50 Sq2=(Ii2*2*modinv((1+Ii),N))@N
60 print Sq2,Sq2^2@N
70 print (Ii+1)*modinv(Ii2,N)@N

Obviously both values of sqrt(2) are the same, since if the number computed in line 70 is B, the line 50 computes 2/B (mod N).

mpenguin 2005-08-21 16:11

sqrt(2+sqrt(2+sqrt(2+sqrt(2+....sqrt(2))) are computable from Z and iterating x -> x^2 -2 may reach zero in n+1 steps.

mupad code:
fn:=proc(n) begin 2^(2^n)+1;end_proc;
print(" ^2 -sq2[-1] ",1,mods(vk,n),mods(vk^2,n)-sq2);
for i from 2 to n0-2 do
print(" ^2 -sq2[-1] ",i,vt,mods(vt,n),mods(vk,n),mods(vt^2,n),
"== 2, ",mods(vt^2-vk,n));
print(" + ",i,mods(s1,n),mods(vk,n),mods(s1^2-vk,n));

for i from 1 to n0+1 do
print(" x -> x^2-2 ",i,gcd(s1,n),s1);

Yamato 2005-09-28 17:53

Let F(n) = 2^(2^n) + 1.

Then the "trivial" square root of 2 is

sqrt(2) = F(n-1) * inv(F(n-2) - 1) (mod F(n))
(inv is the inverse number mod F(n))

because of the real factorization

F(n) = F(n-1)^2 - x^2

where x = (F(n-2) - 1)*sqrt(2)

mpenguin 2005-09-29 07:46

[QUOTE=Yamato]Let F(n) = 2^(2^n) + 1.

Then the "trivial" square root of 2 is


Yes, the square root of 2 is trivial mod Fn.

(2+2^(1/2))^2 and (2+(2+2^(1/2))^(1/2))^(1/2) mod Fn are a little more subtle.

All times are UTC. The time now is 22:19.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2021, Jelsoft Enterprises Ltd.