- Shanks-Tonelli algorithm
The Shanks-Tonelli
algorithm is used withinmodular arithmetic to solve a congruence of the form:
where "n" is a
quadratic residue (mod "p"), and "p" is an odd prime; typically, .When , it is much more efficient to use the following identity: .
Shanks-Tonelli cannot be used for composite moduli, which is a problem equivalent to
integer factorization .Once you have solved the congruence for "x" the second solution is simply .
If the
Generalized Riemann hypothesis is true, the Shanks-Tonelli algorithm is guaranteed to run inpolynomial time .The algorithm was developed by Alberto Tonelli and refined by
Daniel Shanks .The algorithm
Inputs: "p", an odd prime. "n", an integer which is a quadratic residue (mod "p"), meaning that the
Legendre symbol ("n"|"p") = 1.Outputs: "R", an integer satisfying .
# Factor out powers of 2 from ("p" − 1), defining "Q" and "S" as: .
# Select a "W" such that the Legendre symbol ("W"|"p") = −1 (that is, "W" should be a quadratic non-residue modulo "p").
# Let .
# Let .
# Loop:
## Find the lowest "i", , such that . This can be done efficiently by starting with and squaring (mod "p") until the result is 1.
## If , return "R".
## Otherwise, let and repeat the loop with "R"' as the new "R".Uses
Modular square roots are used in, for example, the
quadratic sieve and relatedinteger factorization algorithms.Generalization
Shanks-Tonelli can be generalized to any cyclic group (instead of ) and to "k"th roots for arbitrary integer "k", in particular to taking the "k"th root of an element of a
finite field .References
* cite book
last=Niven
first=Ivan
authorlink=Ivan Niven
coauthors=Herbert S. Zuckerman,Hugh L. Montgomery
title=An Introduction to the Theory of Numbers
edition=5th edition
year=1991
publisher=Wiley
isbn=0-471-62546-9Pages 110–115 describe the algorithm and explain the group theory behind it.External links
* [http://edmond.bf.rmit.edu.au/ecommerce/QS/QSNotes.htm Quadratic Sieve Algorithm] - contains a description of the Shanks-Tonelli algorithm.
Wikimedia Foundation. 2010.