@hackage quadratic-irrational0.1.2
An implementation of quadratic irrationals
Categories
License
MIT
Maintainer
Andrew Lelechenko andrew dot lelechenko at gmail dot com
Links
Versions
Installation
Tested Compilers
Dependencies (6)
- arithmoi >=0.9 && <0.14
- base >=4.9 && <5
- containers >=0.5 && <0.9
- integer-roots >=1.0 && <1.1
- semigroups >=0.8 && <0.21
- transformers >=0.3 && <0.7 Show all…
Dependents (1)
@hackage/acme-everything
quadratic-irrational
A library for exact computation with quadratic irrationals with support for exact conversion from and to (potentially periodic) simple continued fractions.
A quadratic irrational is a number that can be expressed in the form
(a + b √c) / d
where a, b and d are integers and c is a square-free natural number.
Some examples of such numbers are
-
7/2, -
√2, -
(1 + √5)/2(the golden ratio), -
solutions to quadratic equations with rational constants – the quadratic formula has a familiar shape.
A simple continued fraction is a number in the form
a + 1/(b + 1/(c + 1/(d + 1/(e + …))))
or alternatively written as
[a; b, c, d, e, …]
where a is an integer and b, c, d, e, … are positive integers.
Every finite SCF represents a rational number and every infinite, periodic SCF represents a quadratic irrational.
3.5 = [3; 2]
(1+√5)/2 = [1; 1, 1, 1, …]
√2 = [1; 2, 2, 2, …]