Wednesday, 25 January 2012

The wonders of arcsinh

Do you sometimes need to plot a number that has large magnitude but can be positive or negative? I do and I have a trick to do it: instead of plotting x, I plot arcsinhx/2/log10. For positive x, it gives log10x; for negative x, -log10-x. It's quite accurate for x10 and is linear across zero. Pretty much exactly what I need!

Our friend, arcsinh, is the purple curve. The approximating logarithms are in red and blue.


To see why this works, it helps to know that

arcsinx=logx+x2+1

For x0,

logx+x2+1log2x.

For x0,

logx+sqrtx2+1logx+x1+1/2x2 log1/2x=-log-2x.

No comments:

Post a Comment