Title: | The Field of Cyclotomic Numbers |
---|---|
Description: | The cyclotomic numbers are complex numbers that can be thought of as the rational numbers extended with the roots of unity. They are represented exactly, enabling exact computations. They contain the Gaussian rationals (complex numbers with rational real and imaginary parts) as well as the square roots of all rational numbers. They also contain the sine and cosine of all rational multiples of pi. The algorithms implemented in this package are taken from the 'Haskell' package 'cyclotomic', whose algorithms are adapted from code by Martin Schoenert and Thomas Breuer in the 'GAP' project (<https://www.gap-system.org/>). Cyclotomic numbers have applications in number theory, algebraic geometry, algebraic number theory, coding theory, and in the theory of graphs and combinatorics. They have connections to the theory of modular functions and modular curves. |
Authors: | Stéphane Laurent [aut, cre], Scott N. Walck [cph] (author of the Haskell library 'cyclotomic') |
Maintainer: | Stéphane Laurent <[email protected]> |
License: | GPL-3 |
Version: | 1.3.0 |
Built: | 2024-11-01 04:39:56 UTC |
Source: | https://github.com/stla/cyclotomic |
Coercion to a 'cyclotomic' object
## S4 method for signature 'character' as.cyclotomic(x) ## S4 method for signature 'cyclotomic' as.cyclotomic(x) ## S4 method for signature 'numeric' as.cyclotomic(x) ## S4 method for signature 'bigz' as.cyclotomic(x) ## S4 method for signature 'bigq' as.cyclotomic(x)
## S4 method for signature 'character' as.cyclotomic(x) ## S4 method for signature 'cyclotomic' as.cyclotomic(x) ## S4 method for signature 'numeric' as.cyclotomic(x) ## S4 method for signature 'bigz' as.cyclotomic(x) ## S4 method for signature 'bigq' as.cyclotomic(x)
x |
a |
A cyclotomic
object.
as.cyclotomic(2) as.cyclotomic("1/3")
as.cyclotomic(2) as.cyclotomic("1/3")
Convert a cyclotomic number to a complex number.
asComplex(cyc)
asComplex(cyc)
cyc |
a cyclotomic number |
A complex number (generally inexact).
asComplex(zeta(4))
asComplex(zeta(4))
Complex conjugate of a cyclotomic number.
conjugate(cyc)
conjugate(cyc)
cyc |
a cyclotomic number |
A cyclotomic number, the complex conjugate of cyc
.
conjugate(zeta(4)) # should be -zeta(4)
conjugate(zeta(4)) # should be -zeta(4)
The from_just
function is imported from the
maybe package.
Follow the link to its documentation:
from_just
.
It has been imported for convenient use of the maybeRational
function, which possibly returns a 'Just' value.
Unary operators for cyclotomic objects.
## S4 method for signature 'cyclotomic,missing' e1 + e2 ## S4 method for signature 'cyclotomic,missing' e1 - e2
## S4 method for signature 'cyclotomic,missing' e1 + e2 ## S4 method for signature 'cyclotomic,missing' e1 - e2
e1 |
object of class |
e2 |
nothing |
A cyclotomic
object.
Square root of an integer or a rational number as a cyclotomic number. This is slow.
cycSqrt(x)
cycSqrt(x)
x |
an integer, a gmp rational number ( |
The square root of x
as a cyclotomic number.
cycSqrt(2) phi <- (1 + cycSqrt(5)) / 2 # the golden ratio phi^2 - phi # should be 1
cycSqrt(2) phi <- (1 + cycSqrt(5)) / 2 # the golden ratio phi^2 - phi # should be 1
The imaginary part of a cyclotomic number.
imaginaryPart(cyc)
imaginaryPart(cyc)
cyc |
a cyclotomic number |
A cyclotomic number.
imaginaryPart(zeta(9))
imaginaryPart(zeta(9))
Checks whether a cyclotomic number is a Gaussian rational number.
isGaussianRational(cyc)
isGaussianRational(cyc)
cyc |
a cyclotomic number |
A Boolean value.
Checks whether a cyclotomic number is a rational number.
isRational(cyc)
isRational(cyc)
cyc |
a cyclotomic number |
A Boolean value.
Checks whether a cyclotomic number is a real number.
isReal(cyc)
isReal(cyc)
cyc |
a cyclotomic number |
A Boolean value.
Cyclotomic number as exact rational number if possible.
maybeRational(cyc)
maybeRational(cyc)
cyc |
a cyclotomic number |
A maybe
value, just
a rational number if cyc
is a rational number, nothing
otherwise.
maybeRational(zeta(4)) maybeRational(cosDeg(60)) # use `from_just` to get the value
maybeRational(zeta(4)) maybeRational(cosDeg(60)) # use `from_just` to get the value
Complex number in polar form with rational magnitude and rational angle as a cyclotomic number.
polarDeg(r, theta) polarRev(r, theta)
polarDeg(r, theta) polarRev(r, theta)
r |
magnitude, an integer number, a gmp rational number, or a
fraction given as a character string (e.g. |
theta |
angle, an integer number, a gmp rational number, or a
fraction given as a character string (e.g. |
A cyclotomic number.
polarDeg(1, 90) # should be zeta(4) polarRev(1, "1/4") # should be zeta(4) as well
polarDeg(1, 90) # should be zeta(4) polarRev(1, "1/4") # should be zeta(4) as well
Roots of a polynomial of degree 2 as cyclotomic numbers.
quadraticRoots(a, b, c)
quadraticRoots(a, b, c)
a , b , c
|
the coefficients of the polynomial |
A list of two cyclotomic numbers, the roots of the polynomial ax2 + bx +c.
library(cyclotomic) quadraticRoots(a = 1, b = 2, c = -1)
library(cyclotomic) quadraticRoots(a = 1, b = 2, c = -1)
The real part of a cyclotomic number.
realPart(cyc)
realPart(cyc)
cyc |
a cyclotomic number |
A cyclotomic number.
realPart(zeta(9))
realPart(zeta(9))
Cosine and sine of a rational angle as a cyclotomic number.
cosDeg(theta) sinDeg(theta) cosRev(theta) sinRev(theta)
cosDeg(theta) sinDeg(theta) cosRev(theta) sinRev(theta)
theta |
an integer number, a gmp rational number, or a
fraction given as a character string (e.g. |
The function cosDeg
, resp. sinDeg
, returns the cosine,
resp. the sine, of its argument assumed to be given in degrees.
The function cosRev
, resp. sinRev
, returns the cosine,
resp. the sine, of its argument assumed to be given in revolutions.
A cyclotomic number.
cosDeg(60) cosDeg("2/3")^2 + sinDeg("2/3")^2 == 1
cosDeg(60) cosDeg("2/3")^2 + sinDeg("2/3")^2 == 1
For example, 'zeta(4) = i' is the primitive 4th root of unity, and 'zeta(5) = exp(2*pi*i/5)' is the primitive 5th root of unity. In general, 'zeta(n) = exp(2*pi*i/n)'.
zeta(n)
zeta(n)
n |
a positive integer |
A cyclotomic number.
zeta(4)
zeta(4)