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 trig functions #968

Open
rtavenner opened this issue Jul 15, 2018 · 3 comments
Open

Add hyperbolic trig functions #968

rtavenner opened this issue Jul 15, 2018 · 3 comments
Labels
breaking would require a MAJOR release request

Comments

@rtavenner
Copy link

Suggestion: Provide hyperbolic trig functions (sinh, cosh, tanh, asinh, acosh, atanh) in Basics.
All of these are already javascript functions (Math.cosh, Math.sinh, etc.), so this should be easy to implement.

Current workaround:

cosh : Float -> Float
cosh x = (e^x + e^ -x) / 2
sinh : Float -> Float
sinh x = (e^x - e^ -x) / 2
tanh x : Float -> Float
tanh x = sinh x / cosh x
asinh : Float -> Float
asinh x = logBase e (x + sqrt (1 + x^2))
acosh : Float -> Float
acosh x = logBase e (x + sqrt (x^2 - 1))
atanh : Float -> Float
atanh x = (logBase e ((1 + x) / (1 - x))) / 2

(I got these formulas from Wolfram Mathworld.)

I use these functions a lot! In my own code, I have manually defined cosh and sinh 5 times, acosh 3 times, and asinh twice.

Note: This suggestion probably belongs in the meta-issue "Math and Numbers" (#721).

@evancz evancz added the request label Feb 9, 2021
@evancz
Copy link
Member

evancz commented Feb 9, 2021

I believe that adding these to Basics would be a breaking change. In the unlikely event that code like import Something exposing (cosh) is out there, it would be cause an "ambiguous name" error.

Idea to create a Math module could be relevant, so linked for reference. #1088

@evancz evancz added the breaking would require a MAJOR release label Feb 9, 2021
@JoshuaHall
Copy link

What functionality would adding these break? Wouldn't this be a semver minor update, since you are just adding a feature? While adding this feature could potentially make other libraries slightly less useful or cause conflicts/import errors, those errors aren't really your concern because the benefits of adding this outweigh the slight negatives in the short term.

@rtavenner
Copy link
Author

This was a surprise. I had completely forgotten I had posted this issue!

I believe that adding these to Basics would be a breaking change. In the unlikely event that code like import Something exposing (cosh) is out there, it would be cause an "ambiguous name" error.

Huh. That didn't occur to me. And it's not even as unlikely as you suggest — that actually appears in my own code.

(The module that exposed cosh was one I had written myself, to work around the fact that these functions weren't builtin.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking would require a MAJOR release request
Projects
None yet
Development

No branches or pull requests

3 participants