CreatingRhythms-0.0.27.0
Copyright(c) Eric Bailey 2024-2025
LicenseMIT
Maintainereric@ericb.me
Stabilityexperimental
PortabilityPOSIX
Safe HaskellSafe-Inferred
LanguageGHC2021

Data.Rhythm.ContinuedFractions

Description

Simple continued fractions represented by nonempty lists of terms.

\[ \begin{align*} [b_0; b_1, b_2, b_3, \dotsc] &= b_0 + \cfrac{1}{b_1 + \cfrac{1}{b_2 + \cfrac{1}{b_3 + \dotsm}}} \\ &= b_0 + \mathop{\vcenter{\Huge\mathcal{K}}}_{n=1}^{\infty} \frac{1}{b_n} \end{align*} \]

Synopsis

Documentation

collapseFraction :: ContinuedFraction -> Rational Source #

Evaluate a finite ContinuedFraction.

>>> collapseFraction (ContinuedFraction (1 :| [2,3,4]))
43 % 30

continuedFractionSqrt :: Integral a => a -> ContinuedFraction Source #

Calculate the ContinuedFraction representation of the square root of a given number.

>>> continuedFractionSqrt 7
[2;1,1,1,4]