-
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Closed
Description
When the result of rationalize(T, x, tol) doesn't fit in T (ie. rational components overflows T) the function catches the error and returns the last convergent that has been computed. However, this result is not necessarily the best rational approximation of x for T, as there likely exists a semi-convergent (between the last convergent and the one that throws) that is closer to x. For example :
julia> r1 = Rational{Int128}(pi)
60728338969805745700507212595448411044//19330430665609526556707216376512714945
julia> r2 = 135383245921877291206888365157940675591//43093825600584903152997992180848828034
135383245921877291206888365157940675591//43093825600584903152997992180848828034
julia> abs(BigFloat(r2) - big(pi)) < abs(BigFloat(r1) - big(pi))
truejulia> using Base.MathConstants
julia> r1 = Rational{Int64}(γ)
1055624077073011532//1828820909171081307
julia> r2 = 4434255124552851345//7682146196273606513
4434255124552851345//7682146196273606513
julia> abs(BigFloat(r2) - big(γ)) < abs(BigFloat(r1) - big(γ))
trueReactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels