Shanks's square forms factorization: Difference between revisions

Content deleted Content added
No edit summary
top: Added short description.
Tags: Mobile edit Mobile app edit Android app edit App full source
 
(12 intermediate revisions by 5 users not shown)
Line 1:
{{Short description|Integer factorization algorithm}}
{{more footnotes|date=March 2015}}
 
'''Shanks's square forms factorization''' is a method for [[integer factorization]] devised by [[Daniel Shanks]] as an improvement on [[Fermat's factorization method]].
 
The success of Fermat's method depends on finding integers <math>x</math> and <math>y</math> such that <math>x^2-y^2=N</math>, where <math>N</math> is the integer to be factored. An improvement (noticed by [[Maurice Kraitchik|Kraitchik]]) is to look for integers <math>x</math> and <math>y</math> such that <math>x^2\equiv y^2\pmod{N}</math>. Finding a suitable pair <math>(x, y)</math> does not guarantee a factorization of <math>N</math>, but it implies that <math>N</math> is a factor of <math>x^2-y^2=(x-y)(x+y)</math>, and there is a good chance that the [[prime divisor]]s of <math>N</math> are distributed between these two factors, so that calculation of the [[greatest common divisor]] of <math>N</math> and <math>x-y</math> will give a non-trivial factor of <math>N</math>.
 
A practical algorithm for finding pairs <math>(x,y)</math> which satisfy <math>x^2\equiv y^2\pmod{N}</math> was developed by Shanks, who named it Square Forms Factorization or SQUFOF. The algorithm can be expressed in terms of continued fractions or in terms of quadratic forms. Although there are now much more efficient factorization methods available, SQUFOF has the advantage that it is small enough to be implemented on a programmable calculator. Shanks programmed it on an [[HP-65]], made in 1974, which has storage for only nine digit numbers and allows only 100 steps/keystrokes of programming. There are versions of the algorithm that use little memory and versions that store a list of values that run more quickly.
 
In 1858, the Czech mathematician [[Václav Šimerka]] used a method similar to SQUFOF to factor <math>(10^{17} - 1)/9</math> <math>=</math> <math>11111111111111111</math> <math>=</math> <math>2071723 \cdot 5363222357</math>.<ref>{{cite journal |last1=Lemmermeyer |first1=F. |title=Václav Šimerka: quadratic forms and factorization |journal=LMS Journal of Computation and Mathematics |date=2013 |volume=16 |pages=118–129 |doi=10.1112/S1461157013000065 |doi-access=free}}</ref>
 
==Algorithm==
'''Note''' This version of the algorithm works on some examples but often gets stuck in a loop.
 
This version does not use a list.
 
Line 36 ⟶ 39:
<math>i=i+1,b_i=\left\lfloor\frac{P_0+P_{i-1}}{Q_{i-1}}\right\rfloor,P_i=b_iQ_{i-1}-P_{i-1},Q_i=Q_{i-2}+b_i(P_{i-1}-P_i)</math>
 
until <math>P_i=P_{i-1}.</math>{{cn|date=October 2023}}
 
Then if <math>f=\gcd(N,P_i)</math> is not equal to <math>1</math> and not equal to <math>N</math>, then <math>f</math> is a non-trivial factor of <math>N</math>. Otherwise try another value of <math>k</math>.{{cn|date=October 2023}}
 
Shanks's method has time complexity <math>O(\sqrt[4]{N})</math>.<ref>{{Harvcol|Riesel, |1994, |p. =189}}</ref>.
 
Stephen S. McMath wrote
a more detailed discussion of the mathematics of Shanks's method,
together with a proof of its correctness.<ref>{{Cite CiteSeerX|title=Daniel Shanks' Square Forms Factorization| year=2004 |citeseerx = 10.1.1.107.9984}}</ref>
 
Line 209 ⟶ 212:
* {{cite book
| last=Riesel | first=Hans | authorlink=Hans Riesel
| title=Prime Numbers and VomputerComputer Methods for Factorization
| publisher=Birkhauser
|edition = 2nd
Line 222 ⟶ 225:
* S. McMath, F. Crabbe, D. Joyner: [https://web.archive.org/web/20200930034823/https://www.usna.edu/Users/cs/crabbe/papers/mcmath-IJPAM.pdf ''Continued fractions and parallel SQUFOF''], 2005
* Jason Gower, Samuel Wagstaff: [http://homes.cerias.purdue.edu/~ssw/squfof.pdf ''Square Form Factorisation''] [http://www.ams.org/journals/mcom/2008-77-261/S0025-5718-07-02010-8/S0025-5718-07-02010-8.pdf (Published)]
* [https://web.archive.org/web/20231003030532/http://colin.barker.pagesperso-orange.fr/lpa/big_squf.htm Shanks's SQUFOF Factoring Algorithm]
*[https://github.com/TilmanNeumann/java-math-library java-math-library]