RE: Hyperbolic trig functions Attn D.Newhall

new topic     » topic index » view thread      » older message » newer message

> Subject: Re: Hyperbolic trig functions Attn D.Newhall
> 
> 
> posted by: Larry Miller <larrymiller at sasktel.net>
> 
> If you wish to use these functions in the ESL project you would be most
welcome to do so.
> 
> Larry Miller

Just a note here.
The formulas are correct and can be found in any adequate textbook. However,
there could be a numerical accuracy isssue with using them as-is.

1/ Consider the hyp arcsin (more commonly named argsh). The below applies to
argch too, argth being a bit different.

When x is negative of large magnitude, the formula substracts a large
quantity from another one which is close to it. This is a common recipe for
FP underflow. Hence I'd suggest replacing it, for x<-30 or whatever, by:

argsh(x)=-log(-x)-log(1.0+sqrt(1.0+1.0/x*x))

You gain a bit too (but less) by using the equivalent formula for x>30
(optimal threshhold unknown - must be written somewhere): 

argsh(x)=log(x)+log(1.0+sqrt(1.0+1.0/x*x))

You could gain more accuracy by writing a function returning -1+sqrt(1+t*t)
for small t's, and use this inside the log. As this is not a multiprecision
library, probably not worth the effort.

2/ Likewise, there could be some numerical issues with using the argth
formula as is:
a/ For small values of x, 1+x / 1-x will develop some inaccuracies because x
is so much dominated by 1. Using the variant

argth(x)=log(1.0+2.0*x/(1.0-x))/2.0

will smooth out most of the problems.

b/ For x close to 1 the same kind of ideas as for argsh would push towards
using rather:

argth(x)=(-log(1.0-x)+log(1.0+x))/2.0

or, better but perhaps slower:

u=1-x
argth(x)=(-log(u)+log(2.0)+log(1.0-u/2.0))/2.0

Note for Derek N: I didn't implement these in the maths.e which I shipped
with my complex.e module, as it is supposed to be soon superseded by the
official module.

CChris

new topic     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu