RealContinuedFractions
Documentation for RealContinuedFractions.jl.
Examples
julia> using RealContinuedFractions
julia> fromcontfrac(contfrac(π, 4))
355//113
julia> fromcontfrac(contfrac(big(π), 25))
8958937768937//2851718461558
julia> cf = contfrac(6283//2000)
ContinuedFraction{Vector{Int64}}([3, 7, 14, 1, 8, 2])
julia> fromcontfrac(cf)
6283//2000
julia> fromcontfrac(Float64, cf)
3.1415
julia> convergents(contfrac(π, 5))
5-element Vector{Rational{Int64}}:
3//1
22//7
333//106
355//113
103993//33102Library
RealContinuedFractions.ContinuedFractionRealContinuedFractions._rationalRealContinuedFractions.contfracRealContinuedFractions.convergentRealContinuedFractions.convergentsRealContinuedFractions.fromcontfrac
Public
RealContinuedFractions.ContinuedFraction — TypeContinuedFraction(q::Q)Type representing a continued fraction, storing the terms with the type Q.
RealContinuedFractions.contfrac — Functioncontfrac(x::Real)
contfrac(x::Real, n::Integer)
contfrac(T::Type, x::Real)
contfrac(T::Type, x::Real, n::Integer)Compute the first n terms of the continued fraction of x, representing it with type T (defaults to Int).
RealContinuedFractions.convergent — Functionconvergents(cf::ContinuedFraction)
convergents(T::Type, cf::ContinuedFraction)Compute the last convergent of the continued fraction.
These are almost equivalent to
fromcontfrac(cf)
fromcontfrac(Rational{T}, cf)but perform the computation in the opposite order.
Moreover, it does not use the type Rational internally, so it does not check for overflow.
RealContinuedFractions.convergents — Functionconvergents(cf::ContinuedFraction)
convergents(T::Type, cf::ContinuedFraction)Compute the convergents of the continued fraction.
RealContinuedFractions.fromcontfrac — Functionfromcontfrac(cf::ContinuedFraction)
fromcontfrac(T::Type, cf::ContinuedFraction)Evaluate the continued fraction cf using the type T (defaults to the rational type associated with eltype(cf)).
Private
RealContinuedFractions._rational — Function_rational(::Type)Promote integral types to rational and leave others as they are.