-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
isapprox broken on large numbers #12375
Comments
cc @jiahao, @alanedelman |
My basic problem with the current implementation is that
If we change it to rtoldefault(x::FloatingPoint, y::FloatingPoint) = cbrt(max(eps(typeof(x)), eps(typeof(y))))
atoldefault(x::FloatingPoint, y::FloatingPoint) = 0 then it would seem okay to me, although
|
I'd be happy to get rid of FWIW Knuth defines two approximate floating point comparisons based on a (unspecified) threshold ϵ relative to the fr-exponent: ~ for "approximately equal to" and ≈ for "essentially equal to". Ref: TAoCP 2/e, Vol. 2, p. 218 GSL implements ~ in gsl_fcmp. |
If we use Knuth's definition for the OP, then we get the rhs of (24) to be julia> Base.atoldefault(1e17,1)
4.0 |
The original default tolerances discussion (for background, though probably not too enlightening) is in #652. |
@pao, the current tolerances are dimensionally incorrect (they scale incorrectly with @jiahao, it seems to me Knuth's tolerance is too strict to be commonly useful as defaults for My feeling is that sqrt(ε) or cbrt(ε) [where ε is the relative precision, i.e. |
I like the idea of setting |
(And probably |
Only problems I can see are the boundaries (subnormals or Infs). Other than that, +1. |
I made no claim to the contrary. |
fix #12375 (fix scaling of isapprox)
See also #12472 for further developments. |
I was writing some tests for isapprox and made the following horrible discovery:
The issue lies in the default tolerances:
More generally numbers larger then 5e16 are close to everything by default, since
Julia Version 0.4.0-dev+5491
Commit cb77503 (2015-06-21 09:45 UTC)
Platform Info:
System: Linux (x86_64-unknown-linux-gnu)
CPU: Intel(R) Xeon(R) CPU E5-2670 v2 @ 2.50GHz
WORD_SIZE: 64
BLAS: libopenblas (USE64BITINT DYNAMIC_ARCH NO_AFFINITY Sandybridge)
LAPACK: libopenblas
LIBM: libopenlibm
LLVM: libLLVM-3.3
The text was updated successfully, but these errors were encountered: