quadratic-irrational: An implementation of quadratic irrationals

[ algorithms, data, library, math, mit ] [ Propose Tags ] [ Report a vulnerability ]

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

A simple continued fraction is a number expressed 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, …]

[Skip to Readme]

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

Versions [RSS] 0.0.1, 0.0.2, 0.0.3, 0.0.4, 0.0.5, 0.0.6, 0.1.0, 0.1.1, 0.1.2
Change log ChangeLog.md
Dependencies 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) [details]
Tested with ghc ==8.0.2, ghc ==8.2.2, ghc ==8.4.4, ghc ==8.6.5, ghc ==8.8.4, ghc ==8.10.7, ghc ==9.0.2, ghc ==9.2.8, ghc ==9.4.8, ghc ==9.6.7, ghc ==9.8.4, ghc ==9.10.2, ghc ==9.12.2
License MIT
Copyright Copyright © 2014 Johan Kiviniemi
Author Johan Kiviniemi <devel@johan.kiviniemi.name>
Maintainer Andrew Lelechenko andrew dot lelechenko at gmail dot com
Category Math, Algorithms, Data
Home page https://github.com/ion1/quadratic-irrational
Bug tracker https://github.com/ion1/quadratic-irrational/issues
Source repo head: git clone https://github.com/ion1/quadratic-irrational.git
Uploaded by Bodigrim at 2025-07-15T22:36:29Z
Distributions LTSHaskell:0.1.2, NixOS:0.1.1, Stackage:0.1.2
Reverse Dependencies 1 direct, 0 indirect [details]
Downloads 5990 total (12 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2025-07-15 [all 1 reports]

Readme for quadratic-irrational-0.1.2

[back to package description]

quadratic-irrational

Build Status Hackage

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

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