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+2⁢I+3−I
4+I
3+2⁢I⁢5−3⁢I
21+I
3+2⁢I5−3⁢I
934+19⁢I34
The GIquo command computes the integer quotient of m divided by n.
GIquo⁡3+2⁢I,5−3⁢I
I
The GIrem command computes the integer remainder of m divided by n.
GIrem⁡3+2⁢I,5−3⁢I
−3⁢I
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:
GIrem⁡1+2⁢I,3−I,quot
−I
quot
quot⁢3−I+−I
1+2⁢I
The GIgcd command calculates the greatest common divisor of a sequence of Gaussian integers:
GIgcd⁡−3+5⁢I,4+8⁢I
1+I
GIquo⁡−3+5⁢I,1+I
1+4⁢I
GIrem⁡−3+5⁢I,1+I
0
The GIdivisor command computes a set of divisors that are in the first quadrant of its Gaussian integer argument:
GIdivisor⁡−3+5⁢I
1,1+I,1+4⁢I,5+3⁢I
The GIfactor command returns the Gaussian integer factorization of c:
GIfactor⁡−36+50⁢I
1+I2⁢−3+2⁢I⁢−3−8⁢I
expand⁡1+I2⁢−3+2⁢I⁢−3−8⁢I
−36+50⁢I
The GIprime command tests a value, z, for primality.
GIprime⁡19
true
GIprime⁡4+9⁢I
GIprime⁡4+8⁢I
false
The GInorm command computes the norm of the Gaussian integer, z. The norm of a Gaussian integer z = a+I⁢b is defined as ||z|| = a+I⁢b⁢a−I⁢b = a2+b2
GInorm⁡4−2⁢I
20
42+−22
See Also
GaussInt, NumberTheory
Download Help Document