Integral $\int_0^\infty \frac{y^{n}}{(1+y^2)^2}dy$ I wishing to calculating the integral$$
I:=\int_0^\infty \frac{y^{n}}{(1+y^2)^2}dy \qquad n=0,1,2
$$
 I am looking for real analytic solutions thanks, the closed form is cosecant function so it is very nice.
My input can be from a complex analytic method only:
Note, we have double poles at $y=\pm i$.    We close contour around a complex function $f(z)=z^n(1+z^2)^{-2}$ in the upper half plane to obtain
$$
\text{Res}_{z=i}=\frac{1}{4i}, \ (n=2)\quad \text{Res}_{z=i}=0, \ (n=1)\quad \text{Res}_{z=i}=\frac{1}{2i}, \ (n=0).
$$
Now we can write $2\pi i \cdot \text{Res}_{z=i} \ \forall \ n=0,1,2 $.  And then we can finish the problem.  But I wish to calculate I by real analysis methods, thanks.

Let $$I_m(a) = \int_0^{\infty} \frac{y^n}{a+y^m}dy$$. Then $-I_2'(1) = \int_0^{\infty} \frac{y^n}{(1+y^2)^2}$ is your integral.
Write $$I_m(a) = \frac{1}{a} \int_0^{\infty} \frac{y^n}{1+(y/a^{1/m})^m}dy \\= \frac{1}{a} a^\frac{n+1}{m}\int_0^{\infty} \frac{u^n}{1+u^m}du\\ = a^{\frac{n+1}{m}-1} \frac{\pi}{m \sin{\frac{\pi (n+1)}{m}}}.$$
Here I used an obvious substitution and an integral that can be found using the Beta function.
This gives $$-I_2'(1) = \frac{1-n}{2} \frac{\pi}{2} \csc{\frac{\pi}{2}(n+1)} = \frac{1-n}{4} \pi \sec{\frac{\pi n}{2}}$$
