taking an integral without trigonometric substitution I needed to evaluate $$\int_{-\infty}^\infty\frac{1}{x^2+a^2}dx$$
I looked around and found it's solved by trigonometric substitution $x = a\tan\theta$ and the answer is $\frac{\pi}{a}$. I understand the derivation but have been curious: supposing I didn't know the "trick", are there more staightforward methods (even if more laborious) to find this integral?
For example, I figured out the power series $$\frac{1}{x^2+a^2} = \frac{1}{a^2} - \frac{1}{a^4}x^2 + \frac{1}{a^6}x^4 - ...$$
I can integrate the power series term-by-term. But what I end up with obviously diverges as $x\to \infty$ or $x \to -\infty$. Is there a way to continue with this approach and end up with the value of the integral? Or some other way, perhaps?
 A: Consider an upper half semicircular contour and note that those integrals vanishes.
Denote $f(z)=\frac{1}{z^2+a^2}$
Now,  find the pole of the given function and see that it has two poles which are $z=\pm ia$ but only $z=ia$ lies on upper half plane, hence residue is $R=(z-ia)f(z)\bigg|_{z=ia}= \frac{1}{2ia}$.
Now, apply the Residue Theorem, you will find
$I=2\pi i \cdot \frac{1}{2ia}= \frac{\pi}{a}$
A: You have the right motivation, just use a clever substitution to justify the power series.
\begin{align}
\int_{-\infty}^\infty\frac{dx}{x^2+a^2}&\overset{x=at}{=}\frac1a\int_{-\infty}^\infty\frac{dt}{1+t^2}\\
&=\frac2a\int_0^\infty\frac{dt}{1+t^2}\\
&=\underbrace{\frac2a\int_0^1\frac{dt}{1+t^2}}_{x=t}+\underbrace{\frac2a\int_1^\infty\frac{dt}{1+t^2}}_{x=\frac1t}\\
&=\frac2a\int_0^1\frac{dx}{1+x^2}+\frac2a\int_0^1\frac{dx}{1+x^2}\\
&=\frac4a\int_0^1(1-x^2+x^4-x^6+\dots)dx\\
&=\frac4a\left(1-\frac13+\frac15-\frac17+\dots\right)\\
&=\frac4a\times\frac\pi4\\
&=\boxed{\frac\pi a}
\end{align}
A: Another approach is as follows:
$$\begin{align}
\int_{-\infty}^\infty\frac{1}{x^2+a^2}dx 
&= 2\int_0^\infty \frac{1}{x^2+a^2}dx \\
&= \frac{2}{a^2} \int_0^\infty \frac{1}{1+(x/a)^2}dx \\
&= \frac{2}{a} \int_0^\infty \frac{1}{1+t^2}dt \\
&= \frac{2}{a} \arctan t\bigg|_0^\infty  \\
&= \frac{\pi}{a}\end{align}$$
Note that if $a = 0$, the integral diverges.
