Working with Complex Integers Using the GaussInt Package - Maple Programming Help

Online Help

All Products    Maple    MapleSim


Home : Support : Online Help : Applications and Example Worksheets : Number Theory : examples/GaussInt

Working with Complex Integers Using the GaussInt Package

Getting Started

While any command in the package can be referred to using the long form, for example, GaussInt:-GIgcd, it is often easier to load the package and then use the short form command names.

restart;

with(GaussInt):

Examples

The GaussInt package provides routines for working with Gaussian integers. Many of these commands are similar to commands from the NumberTheory package, but are designed to work with complex integers. The symbol capital I is reserved for one of the square roots of -1: I = −1.

Simple operators with complex integers are possible without any commands in the GaussInt package:

1+2I+3I

4+I

(1)

3+2I53I

21+I

(2)

3+2I53I

934+19I34

(3)

The GIquo command computes the integer quotient of m divided by n.

GIquo3+2I,53I

I

(4)

The GIrem command computes the integer remainder of m divided by n.

GIrem3+2I,53I

3I

(5)

If the GIquo command is called with an optional third argument that specifies a name, the result for the remainder is stored in the given name. The converse is also true for the GIrem command:

GIrem1+2I,3I,quot

−I

(6)

quot

I

(7)

quot3I+I

1+2I

(8)

The GIgcd command calculates the greatest common divisor of a sequence of Gaussian integers:

GIgcd3+5I,4+8I

1+I

(9)

GIquo3+5I,1+I

1+4I

(10)

GIrem3+5I,1+I

0

(11)

The GIdivisor command computes a set of divisors that are in the first quadrant of its Gaussian integer argument:

GIdivisor3+5I

1,1+I,1+4I,5+3I

(12)

The GIfactor command returns the Gaussian integer factorization of c:

GIfactor36+50I

1+I2−3+2I−38I

(13)

expand1+I23+2I38I

−36+50I

(14)

The GIprime command tests a value, z, for primality.

GIprime19

true

(15)

GIprime4+9I

true

(16)

GIprime4+8I

false

(17)

The GInorm command computes the norm of the Gaussian integer, z. The norm of a Gaussian integer z = a+Ib is defined as ||z|| = a+IbaIb = a2+b2

GInorm42I

20

(18)

42+22

20

(19)

See Also

GaussInt, NumberTheory