# 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 complexcomplexComplex operation.

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

43+52i |

_{Type: Complex Fraction Integer}

```
b := complex(4/3,-5/2)
```

43-52i |

_{Type: Complex Fraction Integer}

The standard arithmetic operations are available.

```
a + b
```

83 |

_{Type: Complex Fraction Integer}

```
a - b
```

5i |

_{Type: Complex Fraction Integer}

```
a * b
```

28936 |

_{Type: Complex Fraction Integer}

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

```
a / b
```

-161289+240289i |

_{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+8i15+8i |

_{Type: Fraction Complex Integer}

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

```
3.4 + 6.7 * %i
```

3.4+6.7i |

_{Type: Complex Float}

You can also compute the conjugateconjugateComplex and normnormComplex of a complex number.

```
conjugate a
```

43-52i |

_{Type: Complex Fraction Integer}

```
norm a
```

28936 |

_{Type: Fraction Integer}

The realrealComplex and imagimagComplex operations are provided to extract the real and imaginary parts, respectively.

```
real a
```

43 |

_{Type: Fraction Integer}

```
imag a
```

52 |

_{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-39i |

_{Type: Complex Integer}

You can factorfactorComplex Gaussian integers.

```
factor(13 - 13*%i)
```

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

_{Type: Factored Complex Integer}

```
factor complex(2,0)
```

-i(1+i)2 |

_{Type: Factored Complex Integer}