Skip to content

Commit

Permalink
Add hyperbolic functions (#47)
Browse files Browse the repository at this point in the history
  • Loading branch information
aplavin authored Apr 25, 2024
1 parent 5d998dc commit fbca280
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "InverseFunctions"
uuid = "3587e190-3f89-42d0-90ee-14403ec27112"
version = "0.1.13"
version = "0.1.14"

[deps]
Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"
Expand Down
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

2 comments on commit fbca280

@oschulz
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/105631

Tip: Release Notes

Did you know you can add release notes too? Just add markdown formatted text underneath the comment after the text
"Release notes:" and it will be added to the registry PR, and if TagBot is installed it will also be added to the
release that TagBot creates. i.e.

@JuliaRegistrator register

Release notes:

## Breaking changes

- blah

To add them here just re-invoke and the PR will be updated.

Tagging

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.1.14 -m "<description of version>" fbca2801120c69e2311231fe7e2aa19f239fdc66
git push origin v0.1.14

Please sign in to comment.