# This file is part of the IntervalArithmetic.jl package; MIT licensed

sinh(a::Interval) = @round(sinh(a.lo), sinh(a.hi))

cosh(a::Interval) = @round(cosh(mig(a)), cosh(mag(a)))

tanh(a::Interval) = sinh(a) / cosh(a)

asinh(a::Interval{T}) where T = log(a + sqrt(sqr(a) + one(a)))

function acosh(a::Interval{T}) where T
    domain = unsafe_interval(one(T), T(Inf))
    return acosh_inner(a ∩ domain)
end
acosh_inner(a::Interval) = log(a + sqrt(a - one(a)) * sqrt(a + one(a)))

function atanh(a::Interval{T}) where T
    domain = unit_ball(T)
    return atanh_inner(a ∩ domain)
end
function atanh_inner(a::Interval{T}) where T
    abs(a) == one(a) && return emptyinterval(a)
    return unsafe_atomic(T, 0.5) * (log1p(a) - log1p(-a))
end

acoth(a::Interval) = atanh(inv(a))

coth(a::Interval) = inv(tanh(a))

csch(a::Interval) = inv(sinh(a))

sech(a::Interval) = inv(cosh(a))

for f in (:sinh, :cosh, :tanh, :asinh, :acosh, :atanh, :coth, :csch, :sech,
          :atanh_inner, :acosh_inner, :acoth)
    @eval ($f)(x::EmptyInterval) = x
end
