Compute $\int \frac{\sin(\pi x)^2}{\sin(\pi x/2)^2-a^2} \ dx$ Let $a \in (0,1)$, I would like to integrate
$$\int_0^{x_{\downarrow}} \frac{\sin(\pi x)^2}{\sin(\pi x/2)^2-a^2} \ dx +\int_{x_{\uparrow}}^1 \frac{\sin(\pi x)^2}{\sin(\pi x/2)^2-a^2} \ dx. $$
Now $\sin(\pi x/2)^2$ is a monotonically increasing function from $0$ to $1$, therefore there exists a unique $x^*$ such that $\sin(\pi x^*/2)^2 = a^2.$ Now $x^* \in (x_{\downarrow},x_{\uparrow})$ such that both of the above integrals are well-defined.
Please let me know if you have any questions.
Here $x_{\downarrow}$ and $x_{\uparrow}$ are two values of which one is below $x^*.$
 A: Note that
\begin{align}
\frac{\frac14\sin^2\pi x}{\sin^2\frac{\pi x}2-a^2}
=-a^2 + \cos^2\frac{\pi x}2 + \frac{a^2(1-a^2)}{\sin^2\frac{\pi x}2-a^2}
\end{align}
Integrate respectively to obtain
\begin{align}
&\int_ 0^{x_{\downarrow}} \frac{\sin^2\pi x}{\sin^2\frac{\pi x}2-a^2}dx\\
=& \ 2(1-2a^2) x_{\downarrow} +\frac2\pi\sin\pi x_{\downarrow}
-\frac{8a\sqrt{1-a^2}}\pi\tanh^{-1}\frac{\sqrt{1-a^2} \tan\frac{\pi x_{\downarrow}}2}a
\\\\
&\int^1_{x_{\uparrow}} \frac{\sin^2\pi x}{\sin^2\frac{\pi x}2-a^2}dx\\
=& \ 2(1-2a^2)(1- x_{\uparrow})-\frac2\pi\sin\pi x_{\uparrow}
+\frac{8a\sqrt{1-a^2}}\pi\coth^{-1}\frac{\sqrt{1-a^2} \tan\frac{\pi x_{\uparrow}}2}a
\end{align}
A: HINT
Well, we want to solve:
$$\mathscr{I}_\text{n}:=\int\frac{\sin^2\left(\pi x\right)}{\sin^2\left(\frac{\pi x}{2}\right)-\text{n}}\space\text{d}x\tag1$$
Let's do the following steps:

*

*Substitute $\text{u}=\sin\left(\frac{\pi x}{2}\right)$;

*Factor out constants;

*Substitute $\text{u}=\sin\left(\text{s}\right)$;

*Substitute $\text{p}=\cot\left(\text{s}\right)$;

*Use partial fractions.

You can now write:
$$\mathscr{I}_\text{n}=\frac{8}{\pi}\int\left(\frac{\text{n}-1}{1+\text{p}^2}-\frac{\text{n}\left(\text{n}-1\right)}{\text{n}\left(1+\text{p}^2\right)-1}+\frac{1}{\left(1+\text{p}^2\right)^2}\right)\space\text{dp}\tag2$$

I'll let you finish.

