How to derive the formula $$\sum_{n=1}^{\infty}\tan^{-1}\left(\frac{x^{2}}{n^{2}}\right)=\tan^{-1}\left[\frac{\tan\left(\frac{x\pi}{\sqrt{2}}\right)-\tanh\left(\frac{x\pi}{\sqrt{2}}\right)}{\tan\left(\frac{x\pi}{\sqrt{2}}\right)+\tanh\left(\frac{x\pi}{\sqrt{2}}\right)}\right]$$
Is the formula correct? How do I derive the above formula? I tried to apply the formula integral as the limit of sum formula.