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 sinh(tanh(x)) and other similar functions. #165

Open
emsr opened this issue Dec 2, 2018 · 7 comments
Open

Add sinh(tanh(x)) and other similar functions. #165

emsr opened this issue Dec 2, 2018 · 7 comments

Comments

@emsr
Copy link
Owner

emsr commented Dec 2, 2018

Work on double exp integrals and recent fast math work in gcc indicates that sinh(tanh(x)), cosh(tanh(x)), sinh(atanh(x)), and cosh(atanh(x)). I'm not interested in optimizing but in accuracy.

@CaptainSifff
Copy link
Collaborator

Hi,
do you have a pointer on what is needed for the hyperbolic functions?
Are you interested in reliable series for e.g. sinh(tanh(x)) ?

@emsr
Copy link
Owner Author

emsr commented Jun 24, 2019 via email

@CaptainSifff
Copy link
Collaborator

And directly evaluating that function is not fast enough? or lacks precision for certain values since some overflow/underflow occurs?

@CaptainSifff
Copy link
Collaborator

CaptainSifff commented Aug 19, 2019

Hi Ed,
I've got something to play for you...
We consider the functions
C(x) = Cosh(a Tanh(x))
and
S(x) = Sinh(a Tanh(x))
and consider the behaviour for large x.
Denoting real infinity as "inf"
We find
C(inf) = Cosh(a) and S(inf) = Sinh(a)
I think I can show that the large-x behaviour is given by
C(x) ~ C(inf) * F(a,x)
and
S(x) ~ S(inf) * F(a,x)
with the same function F(a,x). Now we have
F(a,x) = y(a,x) * K_1(y(a,x))
with y(a,x) = 2 * a * exp(-x)
and K_1 denoting the modified Bessel function of the second kind (http://mathworld.wolfram.com/ModifiedBesselFunctionoftheSecondKind.html)
Since y(a,x) becomes exponentially small for large x we can use any Series around x=0 for K_1.
To give an approximation to first order that only relies on elementary functions we have:
F(a,x) ~ 1 + a^2 * exp(-2x) * (-1+2 \gamma + 2* ln(a) -x) + ...
Here \gamma is the Euler-Mascheroni constant(https://en.wikipedia.org/wiki/Euler%E2%80%93Mascheroni_constant)
I get good agreement in Mathematica between C(x) evaluated in Mathematica for a=1 and x>20.
If you have questions or my notation is unclear, just ask!

@CaptainSifff
Copy link
Collaborator

CaptainSifff commented Aug 19, 2019

Forget what I have previously written...
I found a "minor" bug in my calculation that makes everything far simpler....
To begin again:
We consider the functions
C(x) = Cosh(a Tanh(x))
and
S(x) = Sinh(a Tanh(x))
and consider the behaviour for large x.
Denoting real infinity as "inf"
We find
C(inf) = Cosh(a) and S(inf) = Sinh(a)
I think I can show that the large-x behaviour is given by
C(x) ~ C(inf) * F(a,x)
and
S(x) ~ S(inf) * F(a,x)
with the same function F(a,x). Now we have
F(a,x) = Cosh(2 * a * exp(-2 * x))
Since exp(-2 * x) becomes exponentially small for large x we can use any Series around x=0 for Cosh(x).
To give an approximation to second order in exp(-2x) that only relies on elementary functions we have:
F(a,x) ~ 1 + 2 * a^2 * exp(-4x)
(more terms could be obtained from the Taylor series of cosh(x) but they are probably not required...)
I get good agreement in Mathematica of C(x) evaluated in Mathematica for a=1 and x>20.
If you have questions or my notation is unclear, just ask!

@emsr
Copy link
Owner Author

emsr commented Aug 20, 2019

Very nice. I'm going to play with this myself.
I'm not sure what I'd call these ;-) but we'll think of something.

@CaptainSifff
Copy link
Collaborator

the most unimaginative I could come up with is:
C_a(x) := cosh(a * tanh(x))
S_a(x) := sinh( a * tanh(x))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants