Skip to content

Commit

Permalink
Fix missed 2 lines in tanh rewrite (JuliaLang#38508)
Browse files Browse the repository at this point in the history
This fixes a slight regression for tanh when the output should be close to but not exactly +-1. This is just fixing a typo from the PR that I merged a few days ago.
  • Loading branch information
oscardssmith committed Nov 20, 2020
1 parent 5be3e27 commit c36cf8c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 2 additions & 2 deletions base/special/hyperbolic.jl
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,8 @@ end
cosh(x::Real) = cosh(float(x))

# tanh methods
TANH_LARGE_X(::Type{Float64}) = 22.0
TANH_LARGE_X(::Type{Float32}) = 9.0f0
TANH_LARGE_X(::Type{Float64}) = 44.0
TANH_LARGE_X(::Type{Float32}) = 18.0f0
TANH_SMALL_X(::Type{Float64}) = 1.0
TANH_SMALL_X(::Type{Float32}) = 1.3862944f0 #2*log(2)
@inline function tanh_kernel(x::Float64)
Expand Down
4 changes: 3 additions & 1 deletion test/math.jl
Original file line number Diff line number Diff line change
Expand Up @@ -992,9 +992,11 @@ end
@test isnan_type(T, tanh(T(NaN)))
for x in Iterators.flatten(pcnfloat.([H_SMALL_X(T), T(1.0), H_MEDIUM_X(T)]))
@test tanh(x) tanh(big(x)) rtol=eps(T)
@test tanh(-x) tanh(big(-x)) rtol=eps(T)
@test tanh(-x) -tanh(big(x)) rtol=eps(T)
end
end
@test tanh(18.0) tanh(big(18.0)) rtol=eps(Float64)
@test tanh(8.0) tanh(big(8.0)) rtol=eps(Float32)
end

@testset "asinh" begin
Expand Down

0 comments on commit c36cf8c

Please sign in to comment.