Certainly, calculating asinh that way loses precision near 0, because the arg to ln is near 1 and thus loses most of the bits off the right end. In fact, trying to implement a lot of the hyperbolic functions in a straightforward manner has similar problems--there's neither a log1p or expm1 function in PostScript. It turns out that log1p can be straightforwardly implemented from log, using the fact that log(1+x) ~ x for small x. I don't know a similar trick for expm1, but the McClaurin series converges quite fast. I've attached some PS code that defines expm1, log1p, and a set of trig and hyperbolic functions. --ms On Wed, Aug 6, 2008 at 8:21 AM, Steve Witham wrote:
...PostScript.... The problem is with [lack of] precision. PS starts out with only single precision floating point, and then a lot more precision gets thrown away for values near zero.
Can you explain the 2nd stmt? I thought PS used pretty standard single-precision. Do you just mean that calculating asinh( x ) = ln( x + sqrt( x^2 + 1 ) ) loses precision?
Btw, I have a page on fixing asinh(x) for x << -1, http://www.tiac.net/~sw/2007/02/asinh_perspective but never figured out how to fix it for around zero.
--Steve