mersenneforum.org  

Go Back   mersenneforum.org > Extra Stuff > Blogorrhea > Dobri

Reply
 
Thread Tools
Old 2022-04-11, 09:30   #1
Dobri
 
"ม้าไฟ"
May 2018

2×3×89 Posts
Default Factorization of Mersenne Numbers as a Constrained Optimization Problem

An illustration of the factorization of Mersenne numbers as a constrained optimization problem is given for
M11=211-1=2047=111111111112 with BitLength[M11]=11.
One has to start with an assumption about the number of bits necessary to represent a prospective factor a.
Let's assume that BitLength[a]=5. Therefore, M11 = ab and BitLength[b]=11-5+1=7.
In polynomial form,
x10+x9+x8+x7+x6+x5+x4+x3+x2+x+1 = (x4+a3x3+a2x2+a1x+1)(x6+b5x5+b4x4+b3x3+b2x2+b1x+1),
and the binary vectors are a=(1,a3,a2,a1,1) and b=(1,b5,b4,b3,b2,b1,1) where 0≤a3+b5≤1 and a1+b1=1.
The expansion of the polynomial product gives
x10+x9+x8+x7+x6+x5+x4+x3+x2+x+1 = x10+(a3+b5)x9+(b4+a3b5+a2)x8+(b3+a3b4+a2b5+a1)x7+(b2+a3b3+a2b4+a1b5+1)x6+(b1+a3b2+a2b3+a1b4+b5)x5+(1+a3b1+a2b2+a1b3+b4)x4+(a3+a2b1+a1b2+b3)x3+(a2+a1b1+b2)x2+(a1+b1)x+1
An implementation in Wolfram code
Code:
FindInstance[
 2^10 + (ca3 + cb5)*2^9 + (cb4 + ca3*cb5 + ca2)*2^8 + (cb3 + ca3*cb4 +
        ca2*cb5 + ca1)*2^7 + (cb2 + ca3*cb3 + ca2*cb4 + ca1*cb5 + 
       1)*2^6 + (cb1 + ca3*cb2 + ca2*cb3 + ca1*cb4 + cb5)*2^5 + (1 + 
       ca3*cb1 + ca2*cb2 + ca1*cb3 + cb4)*2^4 + (ca3 + ca2*cb1 + 
       ca1*cb2 + cb3)*2^3 + (ca2 + ca1*cb1 + cb2)*2^2 + (ca1 + 
       cb1)*2 + 1 == 2^11 - 1 && ca3 + cb5 <= 1 && ca1 + cb1 == 1 && 
  ca1 <= 1 && ca2 <= 1 && ca3 <= 1 && cb1 <= 1 && cb2 <= 1 && 
  cb3 <= 1 && cb4 <= 1 && cb5 <= 1, {ca3, ca2, ca1, cb5, cb4, cb3, 
  cb2, cb1}, NonNegativeIntegers]
gives the following result:
Code:
{{ca3 -> 0, ca2 -> 1, ca1 -> 1, cb5 -> 0, cb4 -> 1, cb3 -> 1, cb2 -> 0, cb1 -> 0}}
Thus a=(1,0,1,1,1), a = 101112 = 23, b=(1,0,1,1,0,0,1), b=10110012 = 89, and 23×89=2047=111111111112.
Dobri is offline   Reply With Quote
Old 2022-04-11, 15:09   #2
R. Gerbicz
 
R. Gerbicz's Avatar
 
"Robert Gerbicz"
Oct 2005
Hungary

3×547 Posts
Default

And of course this is not a simplification of the problem, because it is a quadratic optimization problem using binary integers.
And I'd prefer this (known) form:

min{0 : x*y=n, x>=2, y>=2, x and y are integers},
it is feasible iff n is composite, and for composites it will give a non-trivial divisor of n [and with that you can factor n fully recursively].
R. Gerbicz is offline   Reply With Quote
Old 2022-04-11, 15:26   #3
Dobri
 
"ม้าไฟ"
May 2018

2×3×89 Posts
Default

The illustration in post #1 is not a simplification indeed.
The approach is to be further expanded in at least three directions as follows:
1) Addition of heuristic constraints (for example, b1+a3b2+a2b3+a1b4+b5≤2, etc.);
2) Use of evolutionary computation and genetic algorithms, like GENOCOP for numerical optimization problems; and
3) Preparation of a quadratic function to be tried on a quantum annealing computer like D-Wave Systems.

Last fiddled with by Dobri on 2022-04-11 at 15:30
Dobri is offline   Reply With Quote
Old 2022-04-11, 15:47   #4
R. Gerbicz
 
R. Gerbicz's Avatar
 
"Robert Gerbicz"
Oct 2005
Hungary

164110 Posts
Default

Quote:
Originally Posted by Dobri View Post
3) Preparation of a quadratic function to be tried on a quantum annealing computer like D-Wave Systems.
On quantum computer we already have the polynomial time factorization Shor's algorithm.
I'd say it is quite unlikely that the quad binary approach would be in polynomial time using quantum [because the above form is from ancient].
R. Gerbicz is offline   Reply With Quote
Old 2022-04-11, 16:06   #5
Dobri
 
"ม้าไฟ"
May 2018

2·3·89 Posts
Default

Shor's algorithm can be implemented on quantum computers like IBM Quantum where the problem is the limited number of qubits and the noise.
Quantum annealing is kind of pseudo-quantum computing for solving optimization problems having the advantage of the utilization of large matrix qubit configurations.
There are several works on integer factorization using D-Wave Systems but not much is known about the efficiency of factoring Mersenne numbers.
A short video that illustrates the classical idea for such optimizations is available at https://www.youtube.com/watch?v=dAyDi1aa40E.

Last fiddled with by Dobri on 2022-04-11 at 16:09
Dobri is offline   Reply With Quote
Old 2022-04-12, 12:59   #6
Dobri
 
"ม้าไฟ"
May 2018

2·3·89 Posts
Default

Below is a more compact Wolfram code which allows one to enter the bit length Mbl of the Mersenne number and the bit length Fbl of the prospective factor.
For this second illustration, M29=229-1=536870911=111111111111111111111111111112 is chosen (Mbl=29) and it is assumed that the bit length of the prospective factor is Fbl=11.
Code:
Mbl = 29; Fbl = 11;
FindInstance[(2^(Fbl - 1) + 1 + 
      Sum[Boole[ca[i]]*2^i, {i, 1, Fbl - 2, 1}])*(2^(Mbl - Fbl) + 1 + 
      Sum[Boole[cb[i]]*2^i, {i, 1, Mbl - Fbl - 1, 1}]) == 2^Mbl - 1 &&
   Boole[ca[Fbl - 2]] + Boole[cb[Mbl - Fbl - 1]] <= 1 && 
  Boole[ca[1]] + Boole[cb[1]] == 1, {Sequence @@ 
   Array[ca, {Fbl - 2}, {1}], 
  Sequence @@ Array[cb, {Mbl - Fbl - 1}, {1}]}, Booleans]
The output is in Boolean format, True (1) or False (0).
Code:
{{ca[1] -> True, ca[2] -> True, ca[3] -> True, ca[4] -> False, 
  ca[5] -> False, ca[6] -> True, ca[7] -> False, ca[8] -> False, 
  ca[9] -> False, cb[1] -> False, cb[2] -> False, cb[3] -> False, 
  cb[4] -> True, cb[5] -> False, cb[6] -> True, cb[7] -> False, 
  cb[8] -> True, cb[9] -> False, cb[10] -> True, cb[11] -> True, 
  cb[12] -> False, cb[13] -> True, cb[14] -> True, cb[15] -> False, 
  cb[16] -> True, cb[17] -> True}}
The obtained factor is 100010011112=1103.

Last fiddled with by Dobri on 2022-04-12 at 13:40
Dobri is offline   Reply With Quote
Old 2022-04-13, 04:53   #7
Dobri
 
"ม้าไฟ"
May 2018

2·3·89 Posts
Default

In this third illustration, the optimization is only over the unknown bits of the binary vector a=(1,aFbl-2,...,a1,1).
The Mersenne number M1249=21249-1 is chosen (Mbl=1249) and it is assumed that the bit length of the prospective factor is Fbl=26.
The simplified Wolfram code
Code:
p = 1249; Mn = 2^p - 1;
Mbl = p; Fbl = 26;
FindInstance[
 Mod[Mn, FromDigits[Boole[Reverse[Join[{True}, 
 {Sequence @@ Array[ca, {Fbl - 2}, {1}]}, {True}]]], 2]] == 0, 
 {Sequence @@ Array[ca, {Fbl - 2}, {1}]}, Booleans]
gives the following result:
Code:
{{ca[1] -> False, ca[2] -> False, ca[3] -> False, ca[4] -> False, ca[5] -> False, ca[6] -> True, ca[7] -> True, ca[8] -> True, ca[9] -> True, ca[10] -> False, ca[11] -> True, ca[12] -> False, ca[13] -> True, ca[14] -> True, ca[15] -> True, ca[16] -> False, ca[17] -> True, ca[18] -> True, ca[19] -> True, ca[20] -> True, ca[21] -> False, ca[22] -> False, ca[23] -> False, ca[24] -> True}}
The obtained factor is 110001111011101011110000012=52358081.

Last fiddled with by Dobri on 2022-04-13 at 04:55
Dobri is offline   Reply With Quote
Old 2022-04-13, 05:52   #8
VBCurtis
 
VBCurtis's Avatar
 
"Curtis"
Feb 2005
Riverside, CA

585410 Posts
Default

Please use your method on M1277 and let us know what the factor is.
VBCurtis is offline   Reply With Quote
Old 2022-04-13, 05:58   #9
Dobri
 
"ม้าไฟ"
May 2018

2·3·89 Posts
Default

Quote:
Originally Posted by VBCurtis View Post
Please use your method on M1277 and let us know what the factor is.
I am working on it indeed. It is a work in progress involving a combination of constrained optimization with empirical constraints and heuristic sieves.
Dobri is offline   Reply With Quote
Old 2022-04-13, 13:47   #10
Dr Sardonicus
 
Dr Sardonicus's Avatar
 
Feb 2017
Nowhere

13·17·29 Posts
Default

Quote:
Originally Posted by Dobri View Post
In this third illustration, the optimization is only over the unknown bits of the binary vector a=(1,aFbl-2,...,a1,1).
The Mersenne number M1249=21249-1 is chosen (Mbl=1249) and it is assumed that the bit length of the prospective factor is Fbl=26.
The simplified Wolfram code
Code:
p = 1249; Mn = 2^p - 1;
Mbl = p; Fbl = 26;
FindInstance[
 Mod[Mn, FromDigits[Boole[Reverse[Join[{True}, 
 {Sequence @@ Array[ca, {Fbl - 2}, {1}]}, {True}]]], 2]] == 0, 
 {Sequence @@ Array[ca, {Fbl - 2}, {1}]}, Booleans]
gives the following result:
Code:
{{ca[1] -> False, ca[2] -> False, ca[3] -> False, ca[4] -> False, ca[5] -> False, ca[6] -> True, ca[7] -> True, ca[8] -> True, ca[9] -> True, ca[10] -> False, ca[11] -> True, ca[12] -> False, ca[13] -> True, ca[14] -> True, ca[15] -> True, ca[16] -> False, ca[17] -> True, ca[18] -> True, ca[19] -> True, ca[20] -> True, ca[21] -> False, ca[22] -> False, ca[23] -> False, ca[24] -> True}}
The obtained factor is 110001111011101011110000012=52358081.
Just out of curiosity, how long did your program take to find that factor?

I ran a completely mindless Pari-GP script to look for small factors 2*k*1249 + 1 of 2^1249 - 1 for k <= 1000000. It quickly found 3 small factors (one of which was smaller than the one your program found). I then checked the cofactor, and it tested composite.
Code:
? forstep(i=6*1249+1,2000000*1249+1,[2*1249,6*1249],r=Mod(2,i)^1249-1;if(r==0,print(i)))
97423
52358081
2379005273
? n=(2^1249-1)/97423/52358081/2379005273;ispseudoprime(n)
%4 = 0
I note that for M1277, your bit length would have to exceed the current TF limit in order to have any chance of turning up a factor. That could increase your program's run time somewhat.

I suggest you try a bit length of 426. If there is no factor that length or smaller, you will at least have shown that M1277 is a P2.
Dr Sardonicus is offline   Reply With Quote
Old 2022-04-13, 14:22   #11
Dobri
 
"ม้าไฟ"
May 2018

2·3·89 Posts
Default

Quote:
Originally Posted by Dr Sardonicus View Post
Just out of curiosity, how long did your program take to find that factor?
The result was obtained for approximately one hour while running the Wolfram code in interpreter mode on a Raspberry Pi 4B device for which Wolfram Mathematica is available for free. Compiling the code segment would make it run much faster.
The increase of the bit length increases the computation time exponentially if no additional constraints are stated.
For example, one could put constraints on the number of consecutive zeros and ones, add empirical bit patterns, etc., in order to reduce the computation time for a prospective factor.
Dobri is offline   Reply With Quote
Reply

Thread Tools


Similar Threads
Thread Thread Starter Forum Replies Last Post
Mersenne factorization by (nxy+x+y) baih Miscellaneous Math 7 2020-08-25 07:55
Optimization Mersenne search Kube Prims GPU Computing 1 2019-11-05 15:40
Transforming the factorization problem into a game Alberico Lepore Alberico Lepore 1 2017-09-28 10:14
An equivalent problem for factorization of large numbers HellGauss Math 5 2012-04-12 14:01
Fermat numbers factorization ET_ Factoring 15 2008-03-12 21:24

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


Fri Jul 7 04:22:00 UTC 2023 up 323 days, 1:50, 0 users, load averages: 1.52, 1.62, 1.53

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

This forum has received and complied with 0 (zero) government requests for information.

Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation.
A copy of the license is included in the FAQ.

≠ ± ∓ ÷ × · − √ ‰ ⊗ ⊕ ⊖ ⊘ ⊙ ≤ ≥ ≦ ≧ ≨ ≩ ≺ ≻ ≼ ≽ ⊏ ⊐ ⊑ ⊒ ² ³ °
∠ ∟ ° ≅ ~ ‖ ⟂ ⫛
≡ ≜ ≈ ∝ ∞ ≪ ≫ ⌊⌋ ⌈⌉ ∘ ∏ ∐ ∑ ∧ ∨ ∩ ∪ ⨀ ⊕ ⊗ 𝖕 𝖖 𝖗 ⊲ ⊳
∅ ∖ ∁ ↦ ↣ ∩ ∪ ⊆ ⊂ ⊄ ⊊ ⊇ ⊃ ⊅ ⊋ ⊖ ∈ ∉ ∋ ∌ ℕ ℤ ℚ ℝ ℂ ℵ ℶ ℷ ℸ 𝓟
¬ ∨ ∧ ⊕ → ← ⇒ ⇐ ⇔ ∀ ∃ ∄ ∴ ∵ ⊤ ⊥ ⊢ ⊨ ⫤ ⊣ … ⋯ ⋮ ⋰ ⋱
∫ ∬ ∭ ∮ ∯ ∰ ∇ ∆ δ ∂ ℱ ℒ ℓ
𝛢𝛼 𝛣𝛽 𝛤𝛾 𝛥𝛿 𝛦𝜀𝜖 𝛧𝜁 𝛨𝜂 𝛩𝜃𝜗 𝛪𝜄 𝛫𝜅 𝛬𝜆 𝛭𝜇 𝛮𝜈 𝛯𝜉 𝛰𝜊 𝛱𝜋 𝛲𝜌 𝛴𝜎𝜍 𝛵𝜏 𝛶𝜐 𝛷𝜙𝜑 𝛸𝜒 𝛹𝜓 𝛺𝜔