Quadratic Residue - Maple Help
For the best experience, we recommend viewing online help using Google Chrome or Mozilla Firefox.

Online Help

All Products    Maple    MapleSim


Home : Support : Online Help : Mathematics : Number Theory : Quadratic Residue

NumberTheory

  

QuadraticResidue

  

quadratic residuosity of a number

 

Calling Sequence

Parameters

Description

Examples

Compatibility

Calling Sequence

QuadraticResidue(a, n)

Parameters

a

-

integer

n

-

positive integer

Description

• 

The QuadraticResidue(a, n) command returns 1 if a is a quadratic residue modulo n, and returns −1 if a is a quadratic non-residue modulo n.

• 

If there exists an integer b such that b2 is congruent to a modulo n, then a is said to be a quadratic residue modulo n. If there does not exist such a b, then a is said to be a quadratic non-residue modulo n.

Examples

> 

with⁡NumberTheory:

Numbers congruent to a perfect square are always quadratic residues. The converse is true as well.

> 

QuadraticResidue⁡11,22

1

(1)
> 

121mod22

11

(2)
> 

QuadraticResidue⁡22,11

1

(3)

12 is a quadratic residue modulo 24.

> 

QuadraticResidue⁡12,24

1

(4)
> 

62mod24

12

(5)

3 is not a quadratic residue modulo 7.

> 

QuadraticResidue⁡3,7

−1

(6)
> 

seq⁡a2mod7,a=0..6

0,1,4,2,2,4,1

(7)

In the following plot, for each row index i and column index j, if the box indexed by i and j is black then j is a quadratic residue modulo i. If the box is white then j is a quadratic non-residue modulo i.

> 

Q≔Matrix⁡100&comma;100&comma;i&comma;j↦`if`⁡i<j&comma;−1&comma;QuadraticResidue⁡j&comma;i

Q≔1−1−1−1−1−1−1−1−1−1…11−1−1−1−1−1−1−1−1…1−11−1−1−1−1−1−1−1…1−1−11−1−1−1−1−1−1…1−1−111−1−1−1−1−1…1−111−11−1−1−1−1…11−11−1−11−1−1−1…1−1−11−1−1−11−1−1…1−1−11−1−11−11−1…1−1−1111−1−111…⋮⋮⋮⋮⋮⋮⋮⋮⋮⋮100 × 100 Matrix

(8)
> 

Statistics:-HeatMap⁡Q&comma;colour=white&comma;black

Compatibility

• 

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

• 

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

See Also

NumberTheory