## 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 $\mathrm{arcsinh}\left(x/2\right)/\mathrm{log}\left(10\right)$. For positive $x$, it gives ${\mathrm{log}}_{10}x$; for negative $x$, $-{\mathrm{log}}_{10}\left(-x\right)$. It's quite accurate for $∣ x∣ 10$ 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

$\mathrm{arcsin}x=\mathrm{log}\left(x+\sqrt{{x}^{2}+1}\right)$

For $x≫0$,

$log⁡x+x2+1≈log⁡2x$.

For $x≪0$,

$log⁡x+sqrtx2+1≈log⁡x+x1+1/2x2 ≈log⁡1/2x=-log⁡-2x$.