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^*.$

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}
