# quadratic-irrational

An implementation of quadratic irrationals

https://github.com/ion1/quadratic-irrational

 LTS Haskell 22.34: 0.1.1@rev:2 Stackage Nightly 2024-09-17: 0.1.1@rev:2 Latest on Hackage: 0.1.1@rev:2

See all snapshots `quadratic-irrational` appears in

MIT licensed by
Maintained by
This version can be pinned in stack with:`quadratic-irrational-0.1.1@sha256:deabf55f0f7f1100e9b4fba62454c8ff019debacd4b9f9ea766c31eba595cee4,3633`

#### Module documentation for 0.1.1

Depends on 5 packages(full list with versions):

# `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, …]
``````

# 0.1.1 (2020-04-15)

• Support `arithmoi-0.11`.

# 0.1.0 (2019-04-26)

• Allow imaginary square roots, e. g., `qi 1 1 (-5) 1`.
• Remove `Ord QI` instance: complex values cannot be ordered.
• Roots of 0 are reduced: `qi a b 0 d` becomes `qi a 0 2 d`.
• Remove `qiZero` and `qiOne`.

# 0.0.6 (2018-08-29)

• Support GHC up to 8.6.1.

# 0.0.5 (2014-03-28)

• Add an `Ord` instance.

# 0.0.4 (2014-03-27)

• Make the description more precise.
• Add continuedFractionApproximate for rational partial evaluations of continued fractions.

# 0.0.3 (2014-03-26)

• Add a more verbose description of the library.

# 0.0.2 (2014-03-25)

• Add doctests.
• Fix qiModify potentially constructing `qi 1 0 5 1` instead of the equivalent but simpler `qi 1 0 0 1`.
• Add lenses.

# 0.0.1 (2014-03-24)

• Initial release.