NumberTheory - Maple Programming Help

Online Help

All Products    Maple    MapleSim


Home : Support : Online Help : Mathematics : Number Theory : NumberTheory/ModularSquareRoot

NumberTheory

  

ModularSquareRoot

  

modular square root

 

Calling Sequence

Parameters

Description

Examples

Compatibility

Calling Sequence

ModularSquareRoot(x, n)

Parameters

x

-

integer

n

-

positive integer

Description

• 

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.

Examples

with(NumberTheory):

The follow numbers have square roots modulo 37.

residues := {seq(i^2 mod 37, i = 0..36)};

residues0,1,3,4,7,9,10,11,12,16,21,25,26,27,28,30,33,34,36

(1)

30 has a square root modulo 37.

evalb(30 in residues);

true

(2)

ModularSquareRoot(30, 37);

17

(3)

17^2 mod 37;

30

(4)

24 does not have a square root modulo 37 and so an error message is displayed.

evalb(24 in residues);

false

(5)

ModularSquareRoot(24, 37);

Error, (in NumberTheory:-ModularSquareRoot) 24 is a quadratic non-residue modulo 37

Compatibility

• 

The NumberTheory[ModularSquareRoot] command was introduced in Maple 2016.

• 

For more information on Maple 2016 changes, see Updates in Maple 2016.

See Also

NumberTheory

NumberTheory[ImaginaryUnit]

NumberTheory[ModularRoot]

NumberTheory[PrimitiveRoot]

NumberTheory[RootsOfUnity]