Skip to content

Commit fbca280

Browse files
authored
Add hyperbolic functions (#47)
1 parent 5d998dc commit fbca280

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name = "InverseFunctions"
22
uuid = "3587e190-3f89-42d0-90ee-14403ec27112"
3-
version = "0.1.13"
3+
version = "0.1.14"
44

55
[deps]
66
Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"

src/inverse.jl

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,18 @@ inverse(::typeof(log10)) = exp10
143143
inverse(::typeof(expm1)) = log1p
144144
inverse(::typeof(log1p)) = expm1
145145

146+
147+
inverse(::typeof(sinh)) = asinh
148+
inverse(::typeof(tanh)) = atanh
149+
inverse(::typeof(coth)) = acoth
150+
inverse(::typeof(csch)) = acsch
151+
152+
inverse(::typeof(asinh)) = sinh
153+
inverse(::typeof(atanh)) = tanh
154+
inverse(::typeof(acoth)) = coth
155+
inverse(::typeof(acsch)) = csch
156+
157+
146158
inverse(::typeof(sqrt)) = square
147159
inverse(::typeof(square)) = sqrt
148160

test/test_inverse.jl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,18 @@ end
5454
end
5555
for f in (
5656
+, -, exp, exp2, exp10, expm1, cbrt, deg2rad, rad2deg, conj,
57+
sinh, tanh, coth, csch, asinh, atanh, acsch, # all invertible hyperbolic functions aside from acoth
5758
Base.Fix1(+, rand()), Base.Fix2(+, rand()), Base.Fix1(-, rand()), Base.Fix2(-, rand()),
5859
Base.Fix1(*, rand()), Base.Fix2(*, rand()), Base.Fix1(/, rand()), Base.Fix2(/, rand()), Base.Fix1(\, rand()), Base.Fix2(\, rand()),
5960
Base.Fix2(^, rand(-11:2:11)),
6061
)
6162
InverseFunctions.test_inverse(f, x)
6263
InverseFunctions.test_inverse(f, -x)
6364
end
65+
# acoth only defined for |x| > 1
66+
InverseFunctions.test_inverse(acoth, 1 + x)
67+
InverseFunctions.test_inverse(acoth, -1 - x)
68+
6469
InverseFunctions.test_inverse(conj, 2 - 3im)
6570
InverseFunctions.test_inverse(reverse, [10, 20, 30])
6671

0 commit comments

Comments
 (0)