By integrating the function:
$$ f(x) = \frac{1}{x^2 \tan(x)} $$
I would like to show that:
$$ \sum_{n=1}^\infty \frac{1}{n^2} = \frac{\pi^2}{6} $$
First, by integrating $f(x)$ over a semi-circle contour and using the residue theorem, I found that the function has simple poles at $x = n\pi$ for $n \in \mathbb{Z} \setminus \{0\}$, and a third-order pole at $x = 0$. The residues at $x = n\pi$ (for $n \neq 0$) are $\frac{1}{n^2 \pi^2}$, and the residue at $x = 0$ is $-\frac{1}{3}$ which I computed with the series expansion of $\frac{\cot(x)}{x^2}$.
Thus we have:
$$ \oint_{C} \frac{1}{x^2 \tan(x)} \, dx = 2\pi i \left( \sum_{n \in \mathbb{Z} \setminus \{0\}} \frac{1}{n^2 \pi^2} + \left(-\frac{1}{3}\right) \right). $$
I made the first assumption that as the radius of the contour goes to infinity, the integral over the arc vanishes. While I assume this is true (based on the fact that according to WolframAlpha $\lim_{R\to\infty}\frac{1}{R^2\tan(R\exp{i\theta})}=0$), I’m not sure how to rigorously prove this in this specific case.
Then the other assumption I made is that the remaining real part somehow vanishes when integrated over $\mathbb{R}$. Which yields the desired result:
$$ \sum_{n=1}^\infty \frac{1}{n^2} = \frac{\pi^2}{6}. $$
However, as you may have guessed this is not a satisfactory result at all. And I would like help formalizing the two assumptions I made and learn through them. (I assume there must exist a trick or a theorem that allows to prove those two things fast enough as this problem should be done is around 30 minutes)