ContinuedFraction(R)
contfrac.spad line 1
[edit on github]
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)
).
- * : (%, %) -> %
- from Magma
- * : (%, R) -> %
- from RightModule(R)
- * : (%, Fraction(R)) -> %
- from RightModule(Fraction(R))
- * : (%, Fraction(Integer)) -> %
- from RightModule(Fraction(Integer))
- * : (R, %) -> %
- from LeftModule(R)
- * : (Fraction(R), %) -> %
- from LeftModule(Fraction(R))
- * : (Fraction(Integer), %) -> %
- from LeftModule(Fraction(Integer))
- * : (Integer, %) -> %
- from AbelianGroup
- * : (NonNegativeInteger, %) -> %
- from AbelianMonoid
- * : (PositiveInteger, %) -> %
- from AbelianSemiGroup
- + : (%, %) -> %
- from AbelianSemiGroup
- - : % -> %
- from AbelianGroup
- - : (%, %) -> %
- from AbelianGroup
- / : (%, %) -> %
- from Field
- 0 : () -> %
- from AbelianMonoid
- 1 : () -> %
- from MagmaWithUnit
- = : (%, %) -> Boolean
- from BasicType
- ^ : (%, Integer) -> %
- from DivisionRing
- ^ : (%, NonNegativeInteger) -> %
- from MagmaWithUnit
- ^ : (%, PositiveInteger) -> %
- from Magma
- annihilate? : (%, %) -> Boolean
- from Rng
- antiCommutator : (%, %) -> %
- from NonAssociativeSemiRng
- approximants : % -> Stream(Fraction(R))
approximants(x)
returns the stream of approximants of the continued fraction 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 : R -> %
- from Algebra(R)
- coerce : Fraction(R) -> %
- from Algebra(Fraction(R))
- coerce : Fraction(Integer) -> %
- from Algebra(Fraction(Integer))
- coerce : Integer -> %
- from NonAssociativeRing
- coerce : % -> OutputForm
- from CoercibleTo(OutputForm)
- commutator : (%, %) -> %
- from NonAssociativeRng
- complete : % -> %
complete(x)
causes all entries in x
to be computed. Normally entries are only computed as needed. If 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 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 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 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 n
entries in the continued fraction 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
- 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 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 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 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 x
. That is, if x = continuedFraction(b0, [a1, a2, a3, ...], [b1, b2, b3, ...])
, then partialQuotients(x) = [b0, b1, b2, b3, ...]
.
- plenaryPower : (%, PositiveInteger) -> %
- from NonAssociativeAlgebra(%)
- 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 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 x
. That is, if x = continuedFraction(b0, [a1, a2, a3, ...], [b1, b2, b3, ...])
, then wholePart(x) = b0
.
- zero? : % -> Boolean
- from AbelianMonoid
- ~= : (%, %) -> Boolean
- from BasicType
IntegralDomain
Module(Fraction(Integer))
noZeroDivisors
LeftModule(Fraction(Integer))
EntireRing
Algebra(%)
RightModule(%)
Monoid
GcdDomain
Algebra(R)
AbelianMonoid
BiModule(R, R)
BasicType
EuclideanDomain
NonAssociativeSemiRng
NonAssociativeAlgebra(Fraction(Integer))
CancellationAbelianMonoid
Algebra(Fraction(R))
MagmaWithUnit
NonAssociativeRing
RightModule(R)
RightModule(Fraction(Integer))
BiModule(Fraction(R), Fraction(R))
unitsKnown
LeftModule(%)
canonicalUnitNormal
RightModule(Fraction(R))
CommutativeStar
Module(%)
SetCategory
LeftOreRing
CoercibleTo(OutputForm)
Algebra(Fraction(Integer))
LeftModule(Fraction(R))
Rng
Field
CommutativeRing
TwoSidedRecip
Magma
UniqueFactorizationDomain
NonAssociativeAlgebra(R)
SemiGroup
LeftModule(R)
DivisionRing
BiModule(%, %)
NonAssociativeAlgebra(Fraction(R))
AbelianGroup
AbelianSemiGroup
NonAssociativeSemiRing
canonicalsClosed
NonAssociativeAlgebra(%)
Module(Fraction(R))
Module(R)
PrincipalIdealDomain
BiModule(Fraction(Integer), Fraction(Integer))
NonAssociativeRng
Ring
SemiRng
SemiRing