3 ms·
I get 0 with Julia 1.1.1 on Ubuntu: julia> e(x) = x == 0 ? 1 : (exp(x) - 1) / x e (generic function with 1 method) julia> q(x) = abs(x - sqrt(x^2 + 1))
by mkl 7y ago
I get 0 with Julia 1.1.1 on Ubuntu:
julia> e(x) = x == 0 ? 1 : (exp(x) - 1) / x
e (generic function with 1 method)
julia> q(x) = abs(x - sqrt(x^2 + 1)) - 1 / (x + sqrt(x^2 + 1))
q (generic function with 1 method)
julia> h(x) = e(q(x) ^ 2)
h (generic function with 1 method)
julia> for x in (15., 16., 17., 9999.)
println(h(x))
end
0.0
0.0
0.0
0.0
I get the same in Python. They're all using standard hardware 64 bit floating point numbers in the same way.