Safe Haskell | Safe-Infered |
---|

The cyclotomic numbers are a subset of the complex numbers with the following properties:

- The cyclotomic numbers are represented exactly, enabling exact computations and equality comparisons.
- The cyclotomic numbers contain the Gaussian rationals
(complex numbers of the form
`p`

+`q`

`i`

with`p`

and`q`

rational). As a consequence, the cyclotomic numbers are a dense subset of the complex numbers. - The cyclotomic numbers contain the square roots of all rational numbers.
- The cyclotomic numbers form a field: they are closed under addition, subtraction, multiplication, and division.
- The cyclotomic numbers contain the sine and cosine of all rational multiples of pi.
- The cyclotomic numbers can be thought of as the rational field extended
with
`n`

th roots of unity for arbitrarily large integers`n`

.

This algorithm for cyclotomic numbers is adapted from code by Martin Schoenert and Thomas Breuer in the GAP project http://www.gap-system.org/ . See in particular source files gap4r4/src/cyclotom.c and gap4r4/lib/cyclotom.gi .

- data Cyclotomic
- i :: Cyclotomic
- e :: Integer -> Cyclotomic
- sqrtInteger :: Integer -> Cyclotomic
- sqrtRat :: Rational -> Cyclotomic
- sinDeg :: Rational -> Cyclotomic
- cosDeg :: Rational -> Cyclotomic
- conj :: Cyclotomic -> Cyclotomic
- real :: Cyclotomic -> Cyclotomic
- imag :: Cyclotomic -> Cyclotomic
- modSq :: Cyclotomic -> Rational
- toComplex :: Cyclotomic -> Complex Double
- isReal :: Cyclotomic -> Bool
- isRational :: Cyclotomic -> Bool
- isGaussianRational :: Cyclotomic -> Bool
- toRat :: Cyclotomic -> Maybe Rational

# Documentation

data Cyclotomic Source

A cyclotomic number.

The square root of -1.

e :: Integer -> CyclotomicSource

sqrtInteger :: Integer -> CyclotomicSource

The square root of an `Integer`

.

sqrtRat :: Rational -> CyclotomicSource

The square root of a `Rational`

number.

sinDeg :: Rational -> CyclotomicSource

Sine function with argument in degrees.

cosDeg :: Rational -> CyclotomicSource

Cosine function with argument in degrees.

conj :: Cyclotomic -> CyclotomicSource

Complex conjugate.

real :: Cyclotomic -> CyclotomicSource

Real part of the cyclotomic number.

imag :: Cyclotomic -> CyclotomicSource

Imaginary part of the cyclotomic number.

modSq :: Cyclotomic -> RationalSource

Modulus squared.

toComplex :: Cyclotomic -> Complex DoubleSource

Export as an inexact complex number.

isReal :: Cyclotomic -> BoolSource

Is the cyclotomic a real number?

isRational :: Cyclotomic -> BoolSource

Is the cyclotomic a rational?

isGaussianRational :: Cyclotomic -> BoolSource

Is the cyclotomic a Gaussian rational?

toRat :: Cyclotomic -> Maybe RationalSource

Return Just rational if the cyclotomic is rational, Nothing otherwise.