TITLE: Two similar integration about continued fractions
QUESTION [5 upvotes]: Prove that \begin{align*}
\int_0^{+\infty} \cfrac{\sin nx}{x + \cfrac{1}{x + \cfrac{2}{x + \cfrac{3}{x + \cdots}}}} \, dx &= \cfrac{\sqrt {\cfrac{\pi }{2}} }{n + \cfrac{1}{n + \cfrac{2}{n + \cfrac{3}{n + \cdots}}}}\\
\int_0^{+\infty} \cfrac{\sin \cfrac{n\pi x}{2}}{x + \cfrac{1^2}{x + \cfrac{2^2}{x + \cfrac{3^2}{x + \cdots}}}} \, dx  &= \cfrac{1}{n + \cfrac{1^2}{n + \cfrac{2^2}{n + \cfrac{3^2}{n + \cdots}}}}.\end{align*}
We can follow this:
For the first one, we use
$$\cfrac{1}{x + \cfrac{1}{x + \cfrac{2}{x + \cdots}}} = e^{x^2/2} \int_x^\infty e^{-t^2/2} \, dt .$$
Then we must prove
$$\int_0^{+\infty} \sin nx \cdot e^{x^2/2} \, dx \int_x^\infty e^{-t^2/2 \, dt}  = \sqrt {\cfrac{\pi }{2}}  \cdot e^{n^2/2} \int_n^\infty e^{-t^2/2} \, dt .$$
For the second one, we use
$$\cfrac{1}{x + \cfrac{1^2}{x + \cfrac{2^2}{x + \cfrac{3^2}{x +  \cdots }}}} = 2\sum_{n = 1}^\infty \cfrac{(-1)^{n + 1}}{x + 2n - 1} = 2 \int_0^1 \cfrac{t^x}{1 + t^2} \, dt.$$
We need to show
$$\int_0^1 \cfrac{2n\pi}{(1 + x^2)(n^2 \pi ^2 + 4\ln^2 x)}dx = \int_0^1 \frac{x^n}{1 + x^2} \, dx .$$
But how can we continue?

REPLY [2 votes]: Hint
Note
$$4\int_0^{+\infty}\cos(4t\ln x)\cdot e^{-2n\pi t} \, dt = \frac{2n\pi}{n^2\pi^2 + 4\ln^2 x}$$
then you only find
$$\int_0^{+\infty}\left(\int_0^1 \frac{\cos(4t\ln x)}{1+x^2} \, dx\right) e^{-2n\pi t} \, dt$$
you only let
$x=e^{-u}$, then
$$\int_0^1 \frac{\cos(4t\ln x)}{1+x^2} \, dx = \int_0^{+\infty} \frac{\cos(4tu)}{2\cosh u}$$
then it is well know,and you can do it(if you can't,you can see this simaler problem:Solve $\int \limits_{0}^{\infty} \frac{\cos(x)}{\cosh(x)} dx$ without complex integration.