Today's Michael Penn video was about evaluating the following sum, attributed to Newton:
$$ S = \sum_{n = 0}^{\infty} (-1)^n \left( \frac{1}{4n+1} + \frac{1}{4n+3} \right) $$
He attacks this by expressing the sum as an integral and uses partial fractions. I commented that I expected a use of the residue theorem, and decided to attack it as follows.
It can be shown that $$S = \int_0 ^1 \frac{1+x^2}{1+x^4} \ dx$$ by some manipulation, as seen in the video. Let $u = \frac{1}{x}$ so $du = -\frac{1}{x^2} \ dx.$ Then the integral becomes
$$ S = \int_1 ^\infty \frac{1+u^2}{1+u^4} \ du. $$
Adding the two gives that
$$ I = 2S = \int_0 ^\infty \frac{1+x^2}{1+x^4} \ dx. $$
Let $f(z) = \frac{1+z^2}{1+z^4}.$ Observe that $f$ has a 1st-order pole at $e^{i\pi/4}$ with residue $P$, computed as
$$ P = \frac{1 + e^{\pi i/2}}{(e^{\pi i/2} + i)(2e^{\pi i/4})} = -\frac{i}{2\sqrt{2}}. $$
Now we consider
$$ I = \int_{C_R} f(z) \ dz$$
where $C_R$ is the quarter circle of radius $R$ in the first quadrant. I'll wave my hands at the usual argument (integrate on the real and imaginary axes and show the integral over the arc is zero by the usual $ML$ estimate), but we conclude that
$$ I = 2\pi i \left(- \frac{i}{2\sqrt{2}} \right) = \frac{\pi}{\sqrt{2}}$$
and thus $$\boxed{S = \frac{\pi}{2\sqrt{2}}}$$
Is this a valid use of the residue theorem? I'll admit my complex analysis is a little rusty, but I wanted to brush up on some tricks.
I'll remark that this was also asked here but that solution still relies on the partial fractions method and the $\psi_0$ function.
According to your OP's method, there are three parts for the contour, $C_1: z=x:x\in [0,R];~C_2: z=Re^{i\theta}: \theta\in [0,\pi/2);~C_3: z=iy: y\in[R, 0]$, and later we let $R\to\infty$
$$\int_{C_1} f(z) \ dz+\int_{C_2} f(z) \ dz+\int_{C_3} f(z) \ dz=2\pi i \cdot Res(z=e^{i\pi/4})$$
On $C_2$ the integral vanishes as $R\to\infty$.
$$\begin{align}\int_{C_1} f(z) \ dz&=\int_0 ^\infty \frac{1+x^2}{1+x^4} \ dx\\ \\ \int_{C_3} f(z) \ dz&=\int_\infty ^0 \frac{1+(iy)^2}{1+(iy)^4} ~i dy=-i\int^\infty _0 \frac{1-y^2}{1+y^4} ~ dy\end{align}$$
So we get:
$$\int_0 ^\infty \frac{1+x^2}{1+x^4} \ dx-i\int^\infty _0 \frac{1-y^2}{1+y^4} ~ dy=2\pi i\cdot \frac{-i}{2\sqrt2}=\frac{\pi}{\sqrt2}$$
By comparing the two sides, we get real part of LHS equals the real part of RHS: $$2S=\int_0 ^\infty \frac{1+x^2}{1+x^4} \ dx=\frac{\pi}{\sqrt2}\Longrightarrow S=\frac{\pi}{2\sqrt2}$$
We also get a byproduct, by letting the imaginary part of LHS equals the imaginary part of RHS:
$$i\int^\infty _0 \frac{1-y^2}{1+y^4} ~ dy=0\Longrightarrow \int^\infty _0 \frac{1}{1+y^4} ~ dy=\int^\infty _0 \frac{y^2}{1+y^4} ~ dy$$
and this equation can be easily verified by making substitution $y=\frac{1}t$