# ContinuedFraction RΒΆ

ContinuedFraction implements general continued fractions. This version is not restricted to simple, finite fractions and uses the Stream as a representation. The arithmetic functions assume that the approximants alternate below/above the convergence point. This is enforced by ensuring the partial numerators and partial denominators are greater than 0 in the Euclidean domain view of `R`

(i.e. `sizeLess?(0, x)`

).

- 0: %
- from AbelianMonoid
- 1: %
- from MagmaWithUnit
- *: (%, %) -> %
- from Magma
- *: (%, Fraction Integer) -> %
- from RightModule Fraction Integer
- *: (%, Fraction R) -> %
- from RightModule Fraction R
- *: (%, R) -> %
- from RightModule R
- *: (Fraction Integer, %) -> %
- from LeftModule Fraction Integer
- *: (Fraction R, %) -> %
- from LeftModule Fraction R
- *: (Integer, %) -> %
- from AbelianGroup
- *: (NonNegativeInteger, %) -> %
- from AbelianMonoid
- *: (PositiveInteger, %) -> %
- from AbelianSemiGroup
- *: (R, %) -> %
- from LeftModule R
- +: (%, %) -> %
- from AbelianSemiGroup
- -: % -> %
- from AbelianGroup
- -: (%, %) -> %
- from AbelianGroup
- /: (%, %) -> %
- from Field
- =: (%, %) -> Boolean
- from BasicType
- ^: (%, Integer) -> %
- from DivisionRing
- ^: (%, NonNegativeInteger) -> %
- from MagmaWithUnit
- ^: (%, PositiveInteger) -> %
- from Magma
- ~=: (%, %) -> Boolean
- from BasicType
- annihilate?: (%, %) -> Boolean
- from Rng
- antiCommutator: (%, %) -> %
- from NonAssociativeSemiRng

- approximants: % -> Stream Fraction R
`approximants(x)`

returns the stream of approximants of the continued fraction spadvar{`x`

}. If the continued fraction is finite, then the stream will be infinite and periodic with period 1.- associates?: (%, %) -> Boolean
- from EntireRing
- associator: (%, %, %) -> %
- from NonAssociativeRng
- characteristic: () -> NonNegativeInteger
- from NonAssociativeRing
- coerce: % -> %
- from Algebra %
- coerce: % -> OutputForm
- from CoercibleTo OutputForm
- coerce: Fraction Integer -> %
- from Algebra Fraction Integer
- coerce: Fraction R -> %
- from Algebra Fraction R
- coerce: Integer -> %
- from NonAssociativeRing
- coerce: R -> %
- from Algebra R
- commutator: (%, %) -> %
- from NonAssociativeRng

- complete: % -> %
`complete(x)`

causes all entries in spadvar{`x`

} to be computed. Normally entries are only computed as needed. If spadvar{`x`

} is an infinite continued fraction, a user-initiated interrupt is necessary to stop the computation.

- continuedFraction: (R, Stream R, Stream R) -> %
`continuedFraction(b0, a, b)`

constructs a continued fraction in the following way: if`a = [a1, a2, ...]`

and`b = [b1, b2, ...]`

then the result is the continued fraction`b0 + a1/(b1 + a2/(b2 + ...))`

.

- continuedFraction: Fraction R -> %
`continuedFraction(r)`

converts the fraction spadvar{`r`

} with components of type`R`

to a continued fraction over`R`

.

- convergents: % -> Stream Fraction R
`convergents(x)`

returns the stream of the convergents of the continued fraction spadvar{`x`

}. If the continued fraction is finite, then the stream will be finite.

- denominators: % -> Stream R
`denominators(x)`

returns the stream of denominators of the approximants of the continued fraction spadvar{`x`

}. If the continued fraction is finite, then the stream will be finite.- divide: (%, %) -> Record(quotient: %, remainder: %)
- from EuclideanDomain
- euclideanSize: % -> NonNegativeInteger
- from EuclideanDomain
- expressIdealMember: (List %, %) -> Union(List %, failed)
- from PrincipalIdealDomain
- exquo: (%, %) -> Union(%, failed)
- from EntireRing

- extend: (%, Integer) -> %
`extend(x, n)`

causes the first spadvar{`n`

} entries in the continued fraction spadvar{`x`

} to be computed. Normally entries are only computed as needed.- extendedEuclidean: (%, %) -> Record(coef1: %, coef2: %, generator: %)
- from EuclideanDomain
- extendedEuclidean: (%, %, %) -> Union(Record(coef1: %, coef2: %), failed)
- from EuclideanDomain
- factor: % -> Factored %
- from UniqueFactorizationDomain
- gcd: (%, %) -> %
- from GcdDomain
- gcd: List % -> %
- from GcdDomain
- gcdPolynomial: (SparseUnivariatePolynomial %, SparseUnivariatePolynomial %) -> SparseUnivariatePolynomial %
- from GcdDomain
- hash: % -> SingleInteger
- from SetCategory
- hashUpdate!: (HashState, %) -> HashState
- from SetCategory
- inv: % -> %
- from DivisionRing
- latex: % -> String
- from SetCategory
- lcm: (%, %) -> %
- from GcdDomain
- lcm: List % -> %
- from GcdDomain
- lcmCoef: (%, %) -> Record(llcm_res: %, coeff1: %, coeff2: %)
- from LeftOreRing
- leftPower: (%, NonNegativeInteger) -> %
- from MagmaWithUnit
- leftPower: (%, PositiveInteger) -> %
- from Magma
- leftRecip: % -> Union(%, failed)
- from MagmaWithUnit
- multiEuclidean: (List %, %) -> Union(List %, failed)
- from EuclideanDomain

- numerators: % -> Stream R
`numerators(x)`

returns the stream of numerators of the approximants of the continued fraction spadvar{`x`

}. If the continued fraction is finite, then the stream will be finite.- one?: % -> Boolean
- from MagmaWithUnit
- opposite?: (%, %) -> Boolean
- from AbelianMonoid

- partialDenominators: % -> Stream R
`partialDenominators(x)`

extracts the denominators in spadvar{`x`

}. That is, if`x = continuedFraction(b0, [a1, a2, a3, ...], [b1, b2, b3, ...])`

, then`partialDenominators(x) = [b1, b2, b3, ...]`

.

- partialNumerators: % -> Stream R
`partialNumerators(x)`

extracts the numerators in spadvar{`x`

}. That is, if`x = continuedFraction(b0, [a1, a2, a3, ...], [b1, b2, b3, ...])`

, then`partialNumerators(x) = [a1, a2, a3, ...]`

.

- partialQuotients: % -> Stream R
`partialQuotients(x)`

extracts the partial quotients in spadvar{`x`

}. That is, if`x = continuedFraction(b0, [a1, a2, a3, ...], [b1, b2, b3, ...])`

, then`partialQuotients(x) = [b0, b1, b2, b3, ...]`

.- prime?: % -> Boolean
- from UniqueFactorizationDomain
- principalIdeal: List % -> Record(coef: List %, generator: %)
- from PrincipalIdealDomain
- quo: (%, %) -> %
- from EuclideanDomain
- recip: % -> Union(%, failed)
- from MagmaWithUnit

- reducedContinuedFraction: (R, Stream R) -> %
`reducedContinuedFraction(b0, b)`

constructs a continued fraction in the following way: if`b = [b1, b2, ...]`

then the result is the continued fraction`b0 + 1/(b1 + 1/(b2 + ...))`

. That is, the result is the same as`continuedFraction(b0, [1, 1, 1, ...], [b1, b2, b3, ...])`

.

- reducedForm: % -> %
`reducedForm(x)`

puts the continued fraction spadvar{`x`

} in reduced form, i.e. the function returns an equivalent continued fraction of the form`continuedFraction(b0, [1, 1, 1, ...], [b1, b2, b3, ...])`

.- rem: (%, %) -> %
- from EuclideanDomain
- rightPower: (%, NonNegativeInteger) -> %
- from MagmaWithUnit
- rightPower: (%, PositiveInteger) -> %
- from Magma
- rightRecip: % -> Union(%, failed)
- from MagmaWithUnit
- sample: %
- from AbelianMonoid
- sizeLess?: (%, %) -> Boolean
- from EuclideanDomain
- squareFree: % -> Factored %
- from UniqueFactorizationDomain
- squareFreePart: % -> %
- from UniqueFactorizationDomain
- subtractIfCan: (%, %) -> Union(%, failed)
- from CancellationAbelianMonoid
- unit?: % -> Boolean
- from EntireRing
- unitCanonical: % -> %
- from EntireRing
- unitNormal: % -> Record(unit: %, canonical: %, associate: %)
- from EntireRing

- wholePart: % -> R
`wholePart(x)`

extracts the whole part of spadvar{`x`

}. That is, if`x = continuedFraction(b0, [a1, a2, a3, ...], [b1, b2, b3, ...])`

, then`wholePart(x) = b0`

.- zero?: % -> Boolean
- from AbelianMonoid

Algebra %

Algebra R

BiModule(%, %)

BiModule(Fraction Integer, Fraction Integer)

BiModule(Fraction R, Fraction R)

BiModule(R, R)

Module %

Module R