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)
).
- 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
- ^: (%, Integer) -> %
from DivisionRing
- ^: (%, NonNegativeInteger) -> %
from MagmaWithUnit
- ^: (%, PositiveInteger) -> %
from Magma
- annihilate?: (%, %) -> Boolean
from Rng
- antiCommutator: (%, %) -> %
- 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 -> %
- coerce: 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: ifa = [a1, a2, ...]
andb = [b1, b2, ...]
then the result is the continued fractionb0 + a1/(b1 + a2/(b2 + ...))
.
- continuedFraction: Fraction R -> %
continuedFraction(r)
converts the fraction spadvar{r
} with components of typeR
to a continued fraction overR
.
- 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
- gcdPolynomial: (SparseUnivariatePolynomial %, SparseUnivariatePolynomial %) -> SparseUnivariatePolynomial %
from GcdDomain
- inv: % -> %
from DivisionRing
- latex: % -> String
from SetCategory
- 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, ifx = continuedFraction(b0, [a1, a2, a3, ...], [b1, b2, b3, ...])
, thenpartialDenominators(x) = [b1, b2, b3, ...]
.
- partialNumerators: % -> Stream R
partialNumerators(x)
extracts the numerators in spadvar{x
}. That is, ifx = continuedFraction(b0, [a1, a2, a3, ...], [b1, b2, b3, ...])
, thenpartialNumerators(x) = [a1, a2, a3, ...]
.
- partialQuotients: % -> Stream R
partialQuotients(x)
extracts the partial quotients in spadvar{x
}. That is, ifx = continuedFraction(b0, [a1, a2, a3, ...], [b1, b2, b3, ...])
, thenpartialQuotients(x) = [b0, b1, b2, b3, ...]
.
- plenaryPower: (%, PositiveInteger) -> %
- 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: ifb = [b1, b2, ...]
then the result is the continued fractionb0 + 1/(b1 + 1/(b2 + ...))
. That is, the result is the same ascontinuedFraction(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 formcontinuedFraction(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 %
- squareFreePart: % -> %
- subtractIfCan: (%, %) -> Union(%, failed)
- 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, ifx = continuedFraction(b0, [a1, a2, a3, ...], [b1, b2, b3, ...])
, thenwholePart(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
NonAssociativeAlgebra Fraction Integer