NumberTheory
ModularSquareRoot
modular square root
Calling Sequence
Parameters
Description
Examples
Compatibility
ModularSquareRoot(x, n)
x
-
integer
n
positive integer
The ModularSquareRoot function computes a non-negative integer y such that y2=xmodn if possible. If not possible, an error message is displayed.
When x has more than one square root, any one of them may be returned.
with(NumberTheory):
The follow numbers have square roots modulo 37.
residues := {seq(i^2 mod 37, i = 0..36)};
residues≔0,1,3,4,7,9,10,11,12,16,21,25,26,27,28,30,33,34,36
30 has a square root modulo 37.
evalb(30 in residues);
true
ModularSquareRoot(30, 37);
17
17^2 mod 37;
30
24 does not have a square root modulo 37 and so an error message is displayed.
evalb(24 in residues);
false
ModularSquareRoot(24, 37);
Error, (in NumberTheory:-ModularSquareRoot) 24 is a quadratic non-residue modulo 37
The NumberTheory[ModularSquareRoot] command was introduced in Maple 2016.
For more information on Maple 2016 changes, see Updates in Maple 2016.
See Also
NumberTheory[ImaginaryUnit]
NumberTheory[ModularRoot]
NumberTheory[PrimitiveRoot]
NumberTheory[RootsOfUnity]
Download Help Document
What kind of issue would you like to report? (Optional)