]>
Book Contents Previous Section 9.10 CliffordAlgebra Next Section 9.12 ContinuedFraction Book Index

## 9.11 Complex

The Complex constructor implements complex objects over a commutative ring R. Typically, the ring R is Integer, Fraction Integer, Float or DoubleFloat. R can also be a symbolic type, like Polynomial Integer. For more information about the numerical and graphical aspects of complex numbers, see ugProblemNumeric .

Complex objects are created by the complex complex Complex operation.

a := complex(4/3,5/2)

4 3+5 2 i

Type: Complex Fraction Integer
b := complex(4/3,-5/2)

4 3-5 2 i

Type: Complex Fraction Integer

The standard arithmetic operations are available.

a + b

8 3

Type: Complex Fraction Integer
a - b

5 i

Type: Complex Fraction Integer
a * b

289 36

Type: Complex Fraction Integer

If R is a field, you can also divide the complex objects.

a / b

-161 289+240 289 i

Type: Complex Fraction Integer

Use a conversion (ugTypesConvertPage in Section ugTypesConvertNumber ) to view the last object as a fraction of complex integers.

% :: Fraction Complex Integer

-15+8 i 15+8 i

Type: Fraction Complex Integer

The predefined macro %i is defined to be complex(0,1).

3.4 + 6.7 * %i

3.4+6.7 i

Type: Complex Float

You can also compute the conjugate conjugate Complex and norm norm Complex of a complex number.

conjugate a

4 3-5 2 i

Type: Complex Fraction Integer
norm a

289 36

Type: Fraction Integer

The real real Complex and imag imag Complex operations are provided to extract the real and imaginary parts, respectively.

real a

4 3

Type: Fraction Integer
imag a

5 2

Type: Fraction Integer

The domain Complex Integer is also called the Gaussian integers. If R is the integers (or, more generally, a EuclideanDomain), you can compute greatest common divisors.

gcd(13 - 13*%i,31 + 27*%i)

5+i

Type: Complex Integer

You can also compute least common multiples.

lcm(13 - 13*%i,31 + 27*%i)

143-39 i

Type: Complex Integer

You can factor factor Complex Gaussian integers.

factor(13 - 13*%i)

-(1+i)(2+3 i)(3+2 i)

Type: Factored Complex Integer
factor complex(2,0)

-i(1+i)2

Type: Factored Complex Integer
Book Contents Previous Section 9.10 CliffordAlgebra Next Section 9.12 ContinuedFraction Book Index