The hardware and bandwidth for this mirror is donated by dogado GmbH, the Webhosting and Full Service-Cloud Provider. Check out our Wordpress Tutorial.
If you wish to report a bug, or if you are interested in having us mirror your free-software or open-source project, please feel free to contact us at mirror[@]dogado.de.
The field of cyclotomic numbers.
The set of cyclotomic numbers is a field obtained by extending the
set of rational numbers with the complex roots of unity. The main
function used to construct a cyclotomic number in this package is
zeta
, it returns a primitive root of the unity. For example
zeta(4)
is the primitive fourth root of unity, that is the
imaginary unit.
library(cyclotomic)
<- zeta(4)
im ^2
im## -1
Arithmetic on cyclotomic numbers can be performed with this package. It is exact. In particular it allows to deal with the Gaussian rational numbers: the complex numbers whose both real and imaginary part are rational.
<- as.cyclotomic(5)
a <- as.cyclotomic("3/2")
b + im * b)^2
(a ## 91/4 + 15*zeta(4)
Note that while zeta(4)
is printed as
zeta(4)
, this is not the case for all roots of unity:
zeta(9)
## -zeta(9)^4 - zeta(9)^7
The set of cyclotomic numbers contains all the square roots of rational numbers, and therefore the package allows exact calculations on such square roots. For example, using float numbers, the following equality does not hold true:
sqrt(5/3) == sqrt(5) / sqrt(3)
## [1] FALSE
But it holds true using the cyclotomic arithmetic:
cycSqrt("5/3") == cycSqrt(5) / cycSqrt(3)
## [1] TRUE
The set of cyclotomic numbers also contains the cosine and the sine of the rational multiples of pi. In particular, it contains the cosine and the sine of any rational number when this number represents an angle given in degrees.
cosDeg(60)
## 1/2
sinDeg(60) == cycSqrt(3) / 2
## [1] TRUE
This package is a port of the Haskell library cyclotomic, written by Scott N. Walck.
These binaries (installable software) and packages are in development.
They may not be fully stable and should be used with caution. We make no claims about them.
Health stats visible at Monitor.