I want to calculate integral : $$\int_{0}^{\infty}\frac{x^2+16}{x^4+10x^2+9}$$ Which because its integrand is an even function of $x$, can be rewritten as $$\frac{1}{2}\int_{-\infty}^{\infty}\frac{x^2+16}{x^4+10x^2+9}$$ Consider the function $$f(z)=\frac{z^2+16}{z^4+10z^2+9}$$ The dominator has simple zeros at $z=\pm3i $ and $z=\pm i$. Let's count $Res[f(3i)] = \lim_{z \to 3i}\frac{z^1+16}{(z+3i)(z+i)(z-i)} = \frac{7}{48i}$ Similarly, $Res[f(-3i)] = \frac{7}{48i}$
$Res[f(i)] = \frac{15}{16i} = -Res[f(-i)]$.
So, $$\frac{1}{2}\int_{-\infty}^{\infty}\frac{x^2+16}{x^4+10x^2+9} = \frac{14\pi}{48i}$$ Is the idea good? Of course, I am considering the semicircular contour $\gamma_R$, which starts at $R$, traces a semicircle in the upper half plane to $−R$ and then travels back to R along the real axis. Why this integral is equal to zero if we integrate on semicircle in the upper half plane?
You have the right idea, but the result is not correct. We have $\operatorname{res}_{3i} f=-\frac{7}{48i}$. So assuming the integral along the semicircle goes to zero we get: $$\frac{1}{2}\int_{-\infty}^\infty\frac{x^2+16}{x^4+10x^2+9}=\pi i\left(\operatorname{res}_{3i} f+\operatorname{res}_{i} f\right)=\pi i\left(\frac{-7}{48i}+\frac{15}{16i}\right)=\dots$$
We still need to argue why the integral over the semicircle goes to zero. Note for this that $\vert f(z)\vert\leq C\vert z\vert^{-2}$ for large enough $\vert z\vert$ and some constant $C$. So we can bound the integral over the semicircle $\gamma_R$ with radius $R$: $$\left\vert\int_{\gamma_R} f(z)dz\right\vert\leq CR^{-2}\operatorname{length}(\gamma_R)=CR^{-2}\pi R=\frac{C\pi}{R}\to0~~\text{as }R\to\infty $$