Evaluate $\int_0^\pi \left(\frac{\sin{2x}\sin{3x}\sin{5x}\sin{30x}}{\sin{x}\sin{6x}\sin{10x}\sin{15x}}\right)^2 dx$ (from MIT Integration Bee 2023) This is from the final round of MIT Integration Bee 2023.
$$\int_0^\pi \left(\frac{\sin{2x}\sin{3x}\sin{5x}\sin{30x}}{\sin{x}\sin{6x}\sin{10x}\sin{15x}}\right)^2 dx$$
The given answer is $7\pi$.

I found a way to do it using contour integrals (see answer below), but this is not a calculation I can finish within 4 minutes (the time limit in the competition). I am still looking for other elegant methods, possibly without using contour integrals.
 A: From @Archisman Panigrahi,
\begin{eqnarray}
I&=&\frac{1}{2} \int_0^{2\pi} \left(\frac{\cos{x}\cos{15x}}{\cos{3x}\cos{5x}}\right)^2 dx= \frac{1}{2} \int_0^{2\pi} \left(\frac{\cos{14x}+\cos{16x}}{\cos{2x}+\cos{8x}}\right)^2 dx\\
&=&\frac{1}{4} \int_0^{4\pi} \left(\frac{\cos{7x}+\cos{8x}}{\cos{x}+\cos{4x}}\right)^2 dx=\frac{1}{2} \int_0^{2\pi} \left(\frac{\cos{7x}+\cos{8x}}{\cos{x}+\cos{4x}}\right)^2 dx.
\end{eqnarray}
Using
$$ \cos\theta=\frac12(z+z^{-1}),z=e^{i\theta} $$
one has
\begin{eqnarray}
&&\frac{\cos{7x}+\cos{8x}}{\cos{x}+\cos{4x}}=\frac{z^7+z^{-7}+z^8+z^{-8}}{z+z^{-1}+z^4+z^{-4}}\\
&=&\frac{1+z+z^{15}+z^{16}}{z^4(1+z^3+z^5+z^8)}=-1-(z+z^{-1})+(z^3+z^{-3})+(z^4+z^{-4})\\
&=&-1-2\cos x+2\cos3x+2\cos4x 
\end{eqnarray}
and hence
$$I=\frac{1}{2} \int_0^{2\pi} \left(\frac{\cos{7x}+\cos{8x}}{\cos{x}+\cos{4x}}\right)^2 dx=\frac12\int_0^{2\pi}(-1-2\cos x+2\cos3x+2\cos4x)^2=7\pi.$$
A: $$A=\frac{\sin (2 x)\, \sin (3 x)\, \sin (5 x) \,\sin (30 x) }{\sin (x) \,\sin (6 x) \,\sin (10 x) \,\sin (15 x) }$$ Simplifying $$A=-1-2 \cos (2 x)+2 \cos (6 x)+2 \cos (8 x)$$ Squaring and simplifying again
$$A^2=7+8 \cos (2 x)-2 \cos (4 x)-8 \cos (6 x)-8 \cos (8 x)-4 \cos (10
   x)+$$ $$2 \cos (12 x)+4 \cos (14 x)+2 \cos (16 x)$$
$$\int A^2\, dx=7 x+4 \sin (2 x)-\frac{1}{2} \sin (4 x)-\frac{4}{3} \sin (6
   x)-\sin (8 x)-$$ $$\frac{2}{5} \sin (10 x)+\frac{1}{6} \sin (12
   x)+\frac{2}{7} \sin (14 x)+\frac{1}{8} \sin (16 x)$$
Edit (detailed steps for the simplication)
Use the half-angle formulae for $\sin(2x)$, $\sin(30x)$ in numerator and for $\sin(6x)$, $\sin(10x)$ in denominator. This gives
$$A=\frac {\cos (x)\, \cos (15 x) }{\cos (3 x)\, \cos (5 x) }$$
Using product to sum and let $x=\frac t 2$
$$A=\frac{\cos (14 x)+\cos (16 x)}{\cos (2 x)+\cos (8 x)}=\frac{\cos (7 t)+\cos (8 t)}{\cos (t)+\cos (4 t)}$$
Now, $t=\cos ^{-1}(z)$ and multiple angle formulae to make
$$A=\frac{128 z^8+64 z^7-256 z^6-112 z^5+160 z^4+56 z^3-32 z^2-7z+1 } {8 z^4-8 z^2+z+1 }$$
Factorization
$$A=\frac{ (z+1) (2 z-1) \left(4 z^2-2 z-1\right) \left(16 z^4+8 z^3-16 z^2-8
   z+1\right)} {(z+1) (2 z-1) \left(4 z^2-2 z-1\right) }$$
Simplify and back to $t$
$$A=16 \cos ^4(t)+8 \cos ^3(t)-16 \cos ^2(t)-8 \cos (t)+1$$
Now, using
$$\cos^2(t)=\frac 12(1+\cos(2t))$$
$$\cos^3(t)=\frac 14 (3 \cos (t)+\cos (3 t))$$
$$\cos^4(t)=\frac{1}{8} (3+4 \cos (2 t)+\cos (4 t))$$
Replace, make $t=2x$ to find the result.
A: Let $f(x)$ denote the egregious fraction of sines inside the square. Writing $w = e^{2ix}$, we have
\begin{align*}
f(x)
&:= \frac{(\sin 2x)(\sin 3x)(\sin 5x)(\sin 30x)}{(\sin x)(\sin 6x)(\sin 10x)(\sin 15x)} \\
&= w^{-4} \underbrace{ \frac{(w^2 - 1)(w^3 - 1)(w^5 - 1)(w^{30} - 1)}{(w - 1)(w^6 - 1)(w^{10} - 1)(w^{15} - 1)} }_{=:g(w)}.
\end{align*}
Writing the fraction part in the last line as $g(w)$, algebraic manipulation using the finite geometric series formula yields
\begin{align*}
g(w)
= \frac{(w + 1)(w^{15} + 1)}{(w^3 + 1)(w^5 + 1)}
= \frac{w^{10} - w^5 + 1}{w^2 - w + 1}
= w^8 + w^7 - w^5 - w^4 - w^3 + w + 1,
\end{align*}
where we utilized the long division in the last step.1) Now, we write
$$ g(w) = \sum_{k\geq 0} a_k w^k $$
for simplicity. Then by noting that $f(x)$ is real-valued,
\begin{align*}
\int_{0}^{\pi} f(x)^2 \, \mathrm{d}x
&= \int_{0}^{\pi} f(x)\overline{f(x)} \, \mathrm{d}x \\
&= \int_{0}^{\pi} \left( e^{-8ix} g(e^{2ix}) \right) \overline{\left( e^{-8ix} g(e^{2ix}) \right)} \, \mathrm{d}x \\
&= \sum_{j,k} a_j \overline{a_k} \int_{0}^{\pi} e^{2ix(j-k)} \, \mathrm{d}x \\
&= \pi \sum_{k \geq 0} |a_k|^2 \\
&= 7\pi.
\end{align*}

1) Alternatively, if OP is familiar with some abstract algebra, we can proceed as below:
\begin{align*}
g(w)
= \prod_{d \mid 30} (w^d - 1)^{\mu(30/d)}
= \Phi_{30}(w)
= w^8 + w^7 - w^5 - w^4 - w^3 + w + 1,
\end{align*}
where $\mu$ is the Möbius function and $\Phi_n$ is the cyclotomic polynomial.
