cyclotomic-1.1.0: A subfield of the complex numbers for exact calculation.

Data.Number.RealCyclotomic

Description

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

1. The real cyclotomic numbers are represented exactly, enabling exact computations and equality comparisons.
2. The real cyclotomic numbers contain the rationals. As a consequence, the real cyclotomic numbers are a dense subset of the real numbers.
3. The real cyclotomic numbers contain the square roots of all nonnegative rational numbers.
4. The real cyclotomic numbers form a field: they are closed under addition, subtraction, multiplication, and division.
5. The real cyclotomic numbers contain the sine and cosine of all rational multiples of pi (equivalently, the sine and cosine of any rational number of degrees or any rational number of revolutions).

Floating point numbers do not do well with equality comparison:

(sqrt 2 + sqrt 3)^2 == 5 + 2 * sqrt 6
-> False

Data.Number.RealCyclotomic represents these numbers exactly, allowing equality comparison:

(sqrtRat 2 + sqrtRat 3)^2 == 5 + 2 * sqrtRat 6
-> True

RealCyclotomics can be exported as inexact real numbers using the toReal function:

sqrtRat 2
-> e(8) - e(8)^3
toReal \$ sqrtRat 2
-> 1.414213562373095

This module is based on the module Cyclotomic. Usually you would only import one of the modules RealCyclotomic or Cyclotomic, depending on whether you wanted only real numbers (this module) or complex numbers (the other). Functions such as sqrtRat, sinDeg, cosDeg are defined in both modules, with different type signatures, so their names will conflict if both modules are imported.

Synopsis

# Documentation

A real cyclotomic number.

Instances
 Source # Instance detailsDefined in Data.Number.RealCyclotomic Methods Source # Instance detailsDefined in Data.Number.RealCyclotomic Methods Source # abs and signum are undefined. Instance detailsDefined in Data.Number.RealCyclotomic Methods Source # Instance detailsDefined in Data.Number.RealCyclotomic MethodsshowList :: [RealCyclotomic] -> ShowS #

The square root of a Rational number.

Sine function with argument in degrees.

Cosine function with argument in degrees.

Sine function with argument in revolutions.

Cosine function with argument in revolutions.

Is the cyclotomic a rational?

Return an exact rational number if possible.

toReal :: RealFloat a => RealCyclotomic -> a Source #

Export as an inexact real number.

The square of the magnitude of a real cyclotomic.

The golden ratio, (1 + √5)/2.

Arguments

 :: Rational a -> Rational b -> Rational c -> RealCyclotomic area of triangle

Heron's formula for the area of a triangle with side lengths a, b, c.