Here's the Postscript source code if you want to read how the perspective
calculation was done, display or print it in high resolution,
or fiddle with the
-rw-r--r-- 1 sw staff 79061 19 Feb 23:18 logmap3.ps.bz2 -rw-r--r-- 1 sw staff 342108 19 Feb 23:26 logmap3.ps.gz
asinh( x ) = ln( x + sqrt( x2 + 1 ) )But if you implement it just that way in floating point, there is a problem when x < 0: with x a large negative number, sqrt( x2 + 1 ) is nearly the same as -x, so you are subtracting two large numbers with a small difference. As -x gets bigger, the difference is in digits that are farther to the right, until finally they disappear off the end. When (as in the test below) one wants to take the asinh of fairly large numbers, this loses accuracy until the difference is zero and ln( 0 ) blows up.
But since the function behaves pretty well when x >= 0, and since asinh( -x ) = -asinh( x ), a simple fix is this:
asinh( x ) =Here's a graph of y = asinh( sinh( x ) ), which should be a straight line, using the naive implementation of asinh (in red) and the improved one (in green). The log of the error is also plotted for the two implementations. Click the picture to see it full size:ln( sqrt( x2 + 1 ) + x ) if x >= 0
-ln( sqrt( x2 + 1 ) - x ) if x < 0
The pdf version is nice because pdf viewers let you zoom way in on
-rw-r--r-- 1 sw staff 106329 19 Feb 23:16 asinh_test3.pdf.gzHere's the Postscript code if you want to print a hires version, understand the calculations, or tweak the all-important "step" parameter. When step is smaller you get more interesting details, but the calculation takes longer. For some reason (bug?), I haven't gotten this to work with step = .00002 or lower.
-rw-r--r-- 1 sw staff 4566 19 Feb 23:16 asinh_test3.psUp to my blog-oid: Analepses