Berlekamp–Rabin algorithm: Difference between revisions

From Wikipedia, the free encyclopedia
Content deleted Content added
m Content in this edit is translated from the existing Russian Wikipedia article at ru:метод Берлекэмпа; see its history for attribution.
AnomieBOT (talk | contribs)
m Substing templates: {{Книга}} and {{Статья}}. See User:AnomieBOT/docs/TemplateSubster for info.
Line 1: Line 1:
In [[number theory]], '''Berlekamp's root finding algorithm''' (also ''Berlekamp-Rabin algorithm'') is the [[Randomized algorithm|probabilistic]] method of [[Root-finding algorithm|finding roots]] of [[Polynomial|polynomials]] over [[Finite field|field]] <math>\mathbb Z_p</math>. The method was discovered by [[Elwyn Berlekamp|Berlekamp]] in 1970<ref name=":0">{{Статья|author=E. R. Berlekamp|year=1970|doi=10.1090/S0025-5718-1970-0276200-X|issn=00255718|выпуск=111|язык=en|страницы=713–735|издание=Mathematics of Computation|заглавие=Factoring polynomials over large finite fields|ссылка=https://www.ams.org/mcom/1970-24-111/S0025-5718-1970-0276200-X/|том=24}}</ref> as an auxiliary to the [[Berlekamp's algorithm|algorithm]] for polynomial factorization over finite field. The algorithm was later modified by [[Michael O. Rabin|Rabin]] for arbitrary finite field in 1979<ref name=":1">{{Статья|автор=M. Rabin|год=1980|doi=10.1137/0209024|issn=00975397|выпуск=2|страницы=273–280|издание=SIAM Journal on Computing|заглавие=Probabilistic Algorithms in Finite Fields|ссылка=https://epubs.siam.org/doi/10.1137/0209024|том=9}}</ref>. The method was also independently discovered before Berlekamp by some other researchers<ref>{{Книга|автор=Donald E Knuth|год=1998|isbn=9780201896848|заглавие=The art of computer programming. Vol. 2 Vol. 2|ссылка=https://www.worldcat.org/title/art-of-computer-programming-vol-2/oclc/900627019&referer=brief_results}}</ref>.
In [[number theory]], '''Berlekamp's root finding algorithm''' (also ''Berlekamp-Rabin algorithm'') is the [[Randomized algorithm|probabilistic]] method of [[Root-finding algorithm|finding roots]] of [[Polynomial|polynomials]] over [[Finite field|field]] <math>\mathbb Z_p</math>. The method was discovered by [[Elwyn Berlekamp|Berlekamp]] in 1970<ref name=":0">{{cite journal |author = |editor= |format= |url= https://www.ams.org/mcom/1970-24-111/S0025-5718-1970-0276200-X/ |title= Factoring polynomials over large finite fields |type= |origyear= | agency = |edition= Mathematics of Computation |location= |date= 1970 |year= 1970 |publisher= |at= |volume= 24 |issue= 111 |number= |pages = 713–735 |page= |series= |isbn = |issn = 00255718 |doi = 10.1090/S0025-5718-1970-0276200-X |bibcode = |arxiv = |pmid = |ref= |archiveurl = |archivedate = |language= en |quote= }}</ref> as an auxiliary to the [[Berlekamp's algorithm|algorithm]] for polynomial factorization over finite field. The algorithm was later modified by [[Michael O. Rabin|Rabin]] for arbitrary finite field in 1979<ref name=":1">{{cite journal |author = M. Rabin |editor= |format= |url= https://epubs.siam.org/doi/10.1137/0209024 |title= Probabilistic Algorithms in Finite Fields |type= |origyear= | agency = |edition= SIAM Journal on Computing |location= |date= 1980 |year= 1980 |publisher= |at= |volume= 9 |issue= 2 |number= |pages = 273–280 |page= |series= |isbn = |issn = 00975397 |doi = 10.1137/0209024 |bibcode = |arxiv = |pmid = |ref= |archiveurl = |archivedate = |language= |quote= }}</ref>. The method was also independently discovered before Berlekamp by some other researchers<ref>{{cite book| author = Donald E Knuth | chapter = | chapter-url = | format = | url = https://www.worldcat.org/title/art-of-computer-programming-vol-2/oclc/900627019&referer=brief_results | title = The art of computer programming. Vol. 2 Vol. 2 | orig-year = | agency = | edition = |location= |date = 1998 |publisher= |at= |volume= |issue = | pages = | page = | series = | isbn = 9780201896848| ref = }}</ref>.
== History ==
== History ==
The method was proposed by [[Elwyn Berlekamp]] in his work<ref name=":0" /> on polynomial factorization over finite fields. Original work lacked formal correctness proof<ref name=":1" /> and was later refined and modified for arbitrary finite fields by [[Michael O. Rabin|Michael Rabin]]<ref name=":1" />. In 1986 René Peralta proposed similar algorithm<ref>{{Статья|автор=Tsz-Wo Sze|год=2011|doi=10.1090/s0025-5718-2011-02419-1|issn=00255718|выпуск=275|страницы=1797–1811|издание=Mathematics of Computation|заглавие=On taking square roots without quadratic nonresidues over finite fields|ссылка=http://dx.doi.org/10.1090/s0025-5718-2011-02419-1|том=80}}</ref> for finding square roots in <math>\mathbb Z_p</math><ref>{{Статья|автор=R. Peralta|год=1986|doi=10.1109/TIT.1986.1057236|issn=00189448|выпуск=6|страницы=846–847|издание=IEEE Transactions on Information Theory|заглавие=A simple and fast probabilistic algorithm for computing square roots modulo a prime number (Corresp.)|ссылка=https://ieeexplore.ieee.org/document/1057236|том=32}}</ref>. In 2000 Peralta's method was generalized for cubic equations<ref>{{Статья|автор=C Padró, G Sáez|год=2002|doi=10.1016/s0893-9659(02)00031-9|issn=08939659|выпуск=6|страницы=703–708|издание=Applied Mathematics Letters|заглавие=Taking cube roots in Zm|ссылка=http://dx.doi.org/10.1016/s0893-9659(02)00031-9|том=15}}</ref>.
The method was proposed by [[Elwyn Berlekamp]] in his work<ref name=":0" /> on polynomial factorization over finite fields. Original work lacked formal correctness proof<ref name=":1" /> and was later refined and modified for arbitrary finite fields by [[Michael O. Rabin|Michael Rabin]]<ref name=":1" />. In 1986 René Peralta proposed similar algorithm<ref>{{cite journal |author = Tsz-Wo Sze |editor= |format= |url= http://dx.doi.org/10.1090/s0025-5718-2011-02419-1 |title= On taking square roots without quadratic nonresidues over finite fields |type= |origyear= | agency = |edition= Mathematics of Computation |location= |date= 2011 |year= 2011 |publisher= |at= |volume= 80 |issue= 275 |number= |pages = 1797–1811 |page= |series= |isbn = |issn = 00255718 |doi = 10.1090/s0025-5718-2011-02419-1 |bibcode = |arxiv = |pmid = |ref= |archiveurl = |archivedate = |language= |quote= }}</ref> for finding square roots in <math>\mathbb Z_p</math><ref>{{cite journal |author = R. Peralta |editor= |format= |url= https://ieeexplore.ieee.org/document/1057236 |title= A simple and fast probabilistic algorithm for computing square roots modulo a prime number (Corresp.) |type= |origyear= | agency = |edition= IEEE Transactions on Information Theory |location= |date= 1986 |year= 1986 |publisher= |at= |volume= 32 |issue= 6 |number= |pages = 846–847 |page= |series= |isbn = |issn = 00189448 |doi = 10.1109/TIT.1986.1057236 |bibcode = |arxiv = |pmid = |ref= |archiveurl = |archivedate = |language= |quote= }}</ref>. In 2000 Peralta's method was generalized for cubic equations<ref>{{cite journal |author = C Padró, G Sáez |editor= |format= |url= http://dx.doi.org/10.1016/s0893-9659(02)00031-9 |title= Taking cube roots in Zm |type= |origyear= | agency = |edition= Applied Mathematics Letters |location= |date= 2002 |year= 2002 |publisher= |at= |volume= 15 |issue= 6 |number= |pages = 703–708 |page= |series= |isbn = |issn = 08939659 |doi = 10.1016/s0893-9659(02)00031-9 |bibcode = |arxiv = |pmid = |ref= |archiveurl = |archivedate = |language= |quote= }}</ref>.


== Statement ==
== Statement ==
Let <math>p</math> be the odd prime number. Consider polynomial <math display="inline">f(x) = a_0 + a_1 x + \dots + a_n x^n</math> over field <math>\mathbb Z_p</math> of remainders modulo <math>p</math>. One have to find all <math>\lambda_1, \dots, \lambda_k</math> such that <math display="inline">f(\lambda_i)\equiv 0 \pmod p</math> for every possible <math>i</math><ref name=":1" /><ref name=":2">{{Книга|автор=Alfred J. Menezes, Ian F. Blake, XuHong Gao, Ronald C. Mullin, Scott A. Vanstone|год=1993|isbn=9780792392828|издательство=Springer US|серия=The Springer International Series in Engineering and Computer Science|заглавие=Applications of Finite Fields|ссылка=https://www.springer.com/gp/book/9780792392828}}</ref>.
Let <math>p</math> be the odd prime number. Consider polynomial <math display="inline">f(x) = a_0 + a_1 x + \dots + a_n x^n</math> over field <math>\mathbb Z_p</math> of remainders modulo <math>p</math>. One have to find all <math>\lambda_1, \dots, \lambda_k</math> such that <math display="inline">f(\lambda_i)\equiv 0 \pmod p</math> for every possible <math>i</math><ref name=":1" /><ref name=":2">{{cite book| author = Alfred J. Menezes, Ian F. Blake, XuHong Gao, Ronald C. Mullin, Scott A. Vanstone | chapter = | chapter-url = | format = | url = https://www.springer.com/gp/book/9780792392828 | title = Applications of Finite Fields | orig-year = | agency = | edition = |location= |date = 1993 |publisher= Springer US |at= |volume= |issue = | pages = | page = | series = The Springer International Series in Engineering and Computer Science | isbn = 9780792392828| ref = }}</ref>.


== Algorithm ==
== Algorithm ==
Line 51: Line 51:


== Correctness proof ==
== Correctness proof ==
Algorithm finds factorization of <math>f_z(x)</math> in all cases except for ones when all numbers <math>z+\lambda_1, z+\lambda_2, \dots, z+\lambda_n</math> are quadratic residues or non-residues simultaneously. According to [[theory of cyclotomy]]<ref>{{Книга|автор=Marshall Hall|год=1998|isbn=9780471315186|страниц=464|издательство=John Wiley & Sons|заглавие=Combinatorial Theory|ссылка=https://books.google.ru/books?hl=en&lr=&id=__JCiiCfu2EC&oi=fnd&pg=PA1&dq=Combinatorial+Theory+hall&ots=WeNDZ7uCSM&sig=a6JwSPPen2C2EysEnkSTXpUNaxM&redir_esc=y#v=onepage&q=Combinatorial%20Theory%20hall&f=false}}</ref> probability of such event for the case when <math>\lambda_1, \dots, \lambda_n</math> are all residues or non-residues simultaneously (that is, when <math>z=0</math> would fail) may be estimated as <math>2^{-k}</math> where <math>k</math> is the number of different values among <math>\lambda_1, \dots, \lambda_n</math><ref name=":0" />. In this way even for the worst case of <math>k=1</math> and <math>f(x)=(x-\lambda)^n</math> probability of error may be estimated as <math>1/2</math> and for modular square root case error probability is at most <math>1/4</math>.
Algorithm finds factorization of <math>f_z(x)</math> in all cases except for ones when all numbers <math>z+\lambda_1, z+\lambda_2, \dots, z+\lambda_n</math> are quadratic residues or non-residues simultaneously. According to [[theory of cyclotomy]]<ref>{{cite book| author = Marshall Hall | chapter = | chapter-url = | format = | url = https://books.google.ru/books?hl=en&lr=&id=__JCiiCfu2EC&oi=fnd&pg=PA1&dq=Combinatorial+Theory+hall&ots=WeNDZ7uCSM&sig=a6JwSPPen2C2EysEnkSTXpUNaxM&redir_esc=y#v=onepage&q=Combinatorial%20Theory%20hall&f=false | title = Combinatorial Theory | orig-year = | agency = | edition = |location= |date = 1998 |publisher= John Wiley & Sons |at= |volume= |issue = | pages = | page = | series = | isbn = 9780471315186| ref = }}</ref> probability of such event for the case when <math>\lambda_1, \dots, \lambda_n</math> are all residues or non-residues simultaneously (that is, when <math>z=0</math> would fail) may be estimated as <math>2^{-k}</math> where <math>k</math> is the number of different values among <math>\lambda_1, \dots, \lambda_n</math><ref name=":0" />. In this way even for the worst case of <math>k=1</math> and <math>f(x)=(x-\lambda)^n</math> probability of error may be estimated as <math>1/2</math> and for modular square root case error probability is at most <math>1/4</math>.


== Complexity ==
== Complexity ==
Line 61: Line 61:
# Taking <math>\gcd</math> of two polynomials via [[Euclidean algorithm]] works in <math>O(n^2)</math>.
# Taking <math>\gcd</math> of two polynomials via [[Euclidean algorithm]] works in <math>O(n^2)</math>.


Thus the whole procedure may be done in <math>O(n^2 \log p)</math>. Using [[fast Fourier transform]] and Half-GCD algorithm<ref>{{Книга|автор=Aho, Alfred V.|год=1974|isbn=0201000296|издательство=Addison-Wesley Pub. Co|заглавие=The design and analysis of computer algorithms|ссылка=http://worldcat.org/oclc/1147299}}</ref> complexity may be improved to <math>O(n \log n \log pn)</math>. For modular square root case the degree <math>n</math> is equal to <math>2</math>, thus the whole complexity of algorithm in such case may be estimated as <math>O(\log p)</math> per iteration<ref name=":2" />.
Thus the whole procedure may be done in <math>O(n^2 \log p)</math>. Using [[fast Fourier transform]] and Half-GCD algorithm<ref>{{cite book| author = Aho, Alfred V. | chapter = | chapter-url = | format = | url = http://worldcat.org/oclc/1147299 | title = The design and analysis of computer algorithms | orig-year = | agency = | edition = |location= |date = 1974 |publisher= Addison-Wesley Pub. Co |at= |volume= |issue = | pages = | page = | series = | isbn = 0201000296| ref = }}</ref> complexity may be improved to <math>O(n \log n \log pn)</math>. For modular square root case the degree <math>n</math> is equal to <math>2</math>, thus the whole complexity of algorithm in such case may be estimated as <math>O(\log p)</math> per iteration<ref name=":2" />.


== References ==
== References ==

Revision as of 23:07, 27 July 2019

In number theory, Berlekamp's root finding algorithm (also Berlekamp-Rabin algorithm) is the probabilistic method of finding roots of polynomials over field . The method was discovered by Berlekamp in 1970[1] as an auxiliary to the algorithm for polynomial factorization over finite field. The algorithm was later modified by Rabin for arbitrary finite field in 1979[2]. The method was also independently discovered before Berlekamp by some other researchers[3].

History

The method was proposed by Elwyn Berlekamp in his work[1] on polynomial factorization over finite fields. Original work lacked formal correctness proof[2] and was later refined and modified for arbitrary finite fields by Michael Rabin[2]. In 1986 René Peralta proposed similar algorithm[4] for finding square roots in [5]. In 2000 Peralta's method was generalized for cubic equations[6].

Statement

Let be the odd prime number. Consider polynomial over field of remainders modulo . One have to find all such that for every possible [2][7].

Algorithm

Randomization

Let . Finding all roots of such polynomial is equivalent to finding its factorization into linear factors. To find such factorization it's sufficient to split polynomial into any two non-trivial divisors and factorize them recursively. To do this consider the polynomial where  is some random element of . If one can represent this polynomial as the product then in terms of initial polynomial it means that which provides needed factorization of [1][7].

Classification of elements

Due to Euler's criterion for every monomial exactly one of following properties holds[1]:

  1. Monomial is equal to if ,
  2. Monomial divides if  is quadratic residue modulo ,
  3. Monomial divides if  is quadratic non-residual modulo .

Thus if is not divisible by , which may be checked separately, then is equal to the product of greatest common divisors and [7].

Berlekamp's method

Property written above leads to the following algorithm[1]:

  1. Explicitly calculate coefficients of ,
  2. Calculate remainders of modulo by consequently squaring current polynomial and taking remainder modulo ,
  3. Using exponentiation by squaring and polynomials calculated on the previous steps calculate the remainder of modulo ,
  4. If then mentioned above provide non-trivial factorization of ,
  5. Otherwise all roots of are either residues or non-residues simultaneously and one has to choose another .

If is divisible by some non-linear primitive polynomial over then when calculating with and one will obtain non-trivial factorization of , thus algorithm allows to find all roots of arbitrary polynomials over .

Modular square root

Consider equation having elements and as its roots. Solution of this equation is equivalent to factorization of polynomial over . In this particular case problem is a bit simpler because it is sufficient to calculate only . For this polynomial exactly one of the following properties will hold:

  1. GCD is equal to which means that and are both quadratic non-residues,
  2. GCD is equal to which means that both numbers are quadratic residues,
  3. GCD is equal to which means that exactly one of these numbers is quadratic residue.

In the third case GCD is equal to either or . It allows to write the solution as [1].

Example

Assume we need to solve the equation . For this we need to factorize . Consider some possible values of :

  1. Let . Then , thus . Both numbers are quadratic non-residues, so we need to take some other .
  1. Let . Then , thus . From this follows , so and .

Manual check shows that, indeed, and .

Correctness proof

Algorithm finds factorization of in all cases except for ones when all numbers are quadratic residues or non-residues simultaneously. According to theory of cyclotomy[8] probability of such event for the case when are all residues or non-residues simultaneously (that is, when would fail) may be estimated as where  is the number of different values among [1]. In this way even for the worst case of and probability of error may be estimated as and for modular square root case error probability is at most .

Complexity

Assume that polynomial's degree is . Here's estimation of algorithm's steps complexity:

  1. Due to binomial theorem , thus transition from to may be done in ,
  2. Polynomial multiplication and taking remainder of one polynomial modulo another one may be done in , thus calculation of is done in ,
  3. Binary exponentiation works in as well,
  4. Taking of two polynomials via Euclidean algorithm works in .

Thus the whole procedure may be done in . Using fast Fourier transform and Half-GCD algorithm[9] complexity may be improved to . For modular square root case the degree is equal to , thus the whole complexity of algorithm in such case may be estimated as per iteration[7].

References

  1. ^ a b c d e f g "Factoring polynomials over large finite fields". 24 (111) (Mathematics of Computation ed.). 1970: 713–735. doi:10.1090/S0025-5718-1970-0276200-X. ISSN 0025-5718. {{cite journal}}: Cite journal requires |journal= (help)CS1 maint: date and year (link)
  2. ^ a b c d M. Rabin (1980). "Probabilistic Algorithms in Finite Fields". 9 (2) (SIAM Journal on Computing ed.): 273–280. doi:10.1137/0209024. ISSN 0097-5397. {{cite journal}}: Cite journal requires |journal= (help)CS1 maint: date and year (link)
  3. ^ Donald E Knuth (1998). The art of computer programming. Vol. 2 Vol. 2. ISBN 9780201896848.
  4. ^ Tsz-Wo Sze (2011). "On taking square roots without quadratic nonresidues over finite fields". 80 (275) (Mathematics of Computation ed.): 1797–1811. doi:10.1090/s0025-5718-2011-02419-1. ISSN 0025-5718. {{cite journal}}: Cite journal requires |journal= (help)CS1 maint: date and year (link)
  5. ^ R. Peralta (1986). "A simple and fast probabilistic algorithm for computing square roots modulo a prime number (Corresp.)". 32 (6) (IEEE Transactions on Information Theory ed.): 846–847. doi:10.1109/TIT.1986.1057236. ISSN 0018-9448. {{cite journal}}: Cite journal requires |journal= (help)CS1 maint: date and year (link)
  6. ^ C Padró, G Sáez (2002). "Taking cube roots in Zm". 15 (6) (Applied Mathematics Letters ed.): 703–708. doi:10.1016/s0893-9659(02)00031-9. ISSN 0893-9659. {{cite journal}}: Cite journal requires |journal= (help)CS1 maint: date and year (link)
  7. ^ a b c d Alfred J. Menezes, Ian F. Blake, XuHong Gao, Ronald C. Mullin, Scott A. Vanstone (1993). Applications of Finite Fields. The Springer International Series in Engineering and Computer Science. Springer US. ISBN 9780792392828.{{cite book}}: CS1 maint: multiple names: authors list (link)
  8. ^ Marshall Hall (1998). Combinatorial Theory. John Wiley & Sons. ISBN 9780471315186.
  9. ^ Aho, Alfred V. (1974). The design and analysis of computer algorithms. Addison-Wesley Pub. Co. ISBN 0201000296.