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 $\u2223 x\u2223 10$ and is linear across zero. Pretty much exactly what I need!

To see why this works, it helps to know that

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

For $x\gg 0$,

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

For $x\ll 0$,

$$\begin{array}{cc}\hfill \mathrm{log}\left(x+\mathrm{sqrt}{x}^{2}+1\right)& \approx \mathrm{log}\left(x+\u2223 x\u2223 \left(1+1/2{x}^{2}\right)\right)\hfill \\ \hfill \approx \mathrm{log}\left(1/2\u2223 x\u2223 \right)=-\mathrm{log}\left(-2x\right)\hfill \end{array}$$.

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\gg 0$,

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

For $x\ll 0$,

$$\begin{array}{cc}\hfill \mathrm{log}\left(x+\mathrm{sqrt}{x}^{2}+1\right)& \approx \mathrm{log}\left(x+\u2223 x\u2223 \left(1+1/2{x}^{2}\right)\right)\hfill \\ \hfill \approx \mathrm{log}\left(1/2\u2223 x\u2223 \right)=-\mathrm{log}\left(-2x\right)\hfill \end{array}$$.

## No comments:

## Post a Comment