Skip to content
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

add hyperbolic functions #47

Merged
merged 3 commits into from
Apr 25, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/inverse.jl
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,18 @@ inverse(::typeof(log10)) = exp10
inverse(::typeof(expm1)) = log1p
inverse(::typeof(log1p)) = expm1


inverse(::typeof(sinh)) = asinh
inverse(::typeof(tanh)) = atanh
inverse(::typeof(coth)) = acoth
inverse(::typeof(csch)) = acsch

inverse(::typeof(asinh)) = sinh
inverse(::typeof(atanh)) = tanh
inverse(::typeof(acoth)) = coth
inverse(::typeof(acsch)) = csch


inverse(::typeof(sqrt)) = square
inverse(::typeof(square)) = sqrt

Expand Down
5 changes: 5 additions & 0 deletions test/test_inverse.jl
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,18 @@ end
end
for f in (
+, -, exp, exp2, exp10, expm1, cbrt, deg2rad, rad2deg, conj,
sinh, tanh, coth, csch, asinh, atanh, acsch, # all invertible hyperbolic functions aside from acoth
Base.Fix1(+, rand()), Base.Fix2(+, rand()), Base.Fix1(-, rand()), Base.Fix2(-, rand()),
Base.Fix1(*, rand()), Base.Fix2(*, rand()), Base.Fix1(/, rand()), Base.Fix2(/, rand()), Base.Fix1(\, rand()), Base.Fix2(\, rand()),
Base.Fix2(^, rand(-11:2:11)),
)
InverseFunctions.test_inverse(f, x)
InverseFunctions.test_inverse(f, -x)
end
# acoth only defined for |x| > 1
InverseFunctions.test_inverse(acoth, 1 + x)
InverseFunctions.test_inverse(acoth, -1 - x)

InverseFunctions.test_inverse(conj, 2 - 3im)
InverseFunctions.test_inverse(reverse, [10, 20, 30])

Expand Down
Loading