closed-form solution for 1/tanh(x) - 1/x that can be evaluated at/near x=0?

351 Views Asked by At

I'm looking to evaluate $\frac{1}{\tanh x}-\frac{1}{x}$ over a range that includes x=0. Is there an alternate form that is both exact, and numerically stable at/near x=0? For now I'm using the Taylor series $x/3-x^3/45+(2 x^5)/945$ for $|x|<0.01$ but it seems hacky to do so.

http://www.wolframalpha.com/share/img?i=d41d8cd98f00b204e9800998ecf8427edv2ojqjdl0&f=HBQTQYZYGY4TQM3EMI3WENBWGUYDCM3GGVSDKZRZGFRTGMBWMMYQaaaa

I'm hoping this is similar to the case of the quadratic formula, which has alternate forms $x=\frac{-b \pm \sqrt{b^2-4ac}}{2a}$ and $x=\frac{2c}{-b \mp \sqrt{b^2-4ac}}$ that can be used for accurate solutions when $|4ac| \ll b^2$.