TITLE: A closed form for $\int_0^\pi \lvert \sin(m t) \cos(n t) \rvert \, \mathrm{d} t$
QUESTION [23 upvotes]: Motivated by this nice question I have been trying to compute the function $f: \mathbb{R}^+ \to \left[0,\frac{1}{2}\right]$ defined by

$$f(\alpha) = \lim_{x \to \infty} \frac{1}{x} \int \limits_0^x \lvert\sin(\alpha s) \cos(s)\rvert \, \mathrm{d} s \, .$$

Note that $f(\alpha) \leq \frac{1}{2}$ follows from the Cauchy-Schwarz inequality.
In the answers to the original question the equidistribution theorem is used to show that $f(3 - 2 \sqrt{2}) = \frac{4}{\pi^2}$ holds. This argument can be extended to every irrational number, so we have $f(\alpha) = \frac{4}{\pi^2} \approx 0.405285$ for any $\alpha \in \mathbb{R}^+ \setminus \mathbb{Q}^+$ .
For rational arguments we can take $m , n \in \mathbb{N}$ with $\gcd(m,n) =1$ . The change of variables $s = n t$ yields
$$ f \left(\frac{m}{n}\right) = \lim_{x \to \infty} \frac{1}{x} \int \limits_0^x \lvert\sin(m t) \cos(n t)\rvert \, \mathrm{d} t \, .$$
The integrand is periodic with period $\pi$, so
$$ f \left(\frac{m}{n}\right) = \lim_{x \to \infty} \frac{1}{x} \left[\bigg\lfloor \frac{x}{\pi} \bigg\rfloor \int \limits_0^\pi \lvert\sin(m t) \cos(n t)\rvert \, \mathrm{d} t + \mathcal{O} (1)\right] = \frac{1}{\pi} \int \limits_0^\pi \lvert\sin(m t) \cos(n t)\rvert \, \mathrm{d} t\, .$$
Now the idea is to split the interval of integration into subintervals on which the sign of the product is constant and then use
$$ \sin(m t) \cos(n t) = \frac{\sin[(m+n)t] + \sin[(m-n)t]}{2}$$
to find the integrals. The result is basically given by a finite sum of cosines evaluated at the zeroes of the integrand.
The first few results are
\begin{align}
f(1) &= \frac{1}{\pi} \approx 0.318301 \, , \\ 
f(2) &= \frac{4}{3 \pi} \approx 0.424413 \, , \\
f\left(\frac{1}{2}\right) &= \frac{2(2\sqrt{2}-1)}{3\pi} \approx 0.388004 \, .
\end{align}
Interestingly, most of the other values (especially those with large $m$ and $n$) seem to be very close to $\frac{4}{\pi^2}$ .
This method can be used (at least in principle) to compute $f$ at every rational argument, but it becomes increasingly complicated for larger values of $m$ and $n$ . Maybe I am overlooking a simple trick, maybe there is a better method. My question is:

How can we find a general expression for $f\left(\frac{m}{n}\right)$ with arbitrary coprime $m,n \in \mathbb{N}$ ?


Edit 1 July 2020
Thanks to Zacky's bounty and River Li's and asgeige's nice answers we have some closed-form results for special cases and a promising (but still somewhat complicated) conjecture for the general case. Using similar methods, I have also found
$$ f(m) = \frac{2}{\pi (m^2-1)} \left[m \csc \left(\frac{\pi}{2m}\right) \cos \left(\frac{\pi}{2m} 1_{2\mathbb{N}}(m)\right) - 1_{2 \mathbb{N}-1}(m)\right]$$
for $m \in \mathbb{N} \setminus \{1\}$ ($1_A$ is the indicator function of the set $A$), which implies $\lim_{m \to \infty} f(m) = \frac{4}{\pi^2}$. While a simple expression for general values of $m,n$ seems unlikely, it may be possible to show that $\lim_{n \to \infty} f \left(\frac{m}{n}\right) = \frac{4}{\pi^2}$ and $\lim_{m \to \infty} f \left(\frac{m}{n}\right) = \frac{4}{\pi^2}$ do indeed hold for fixed $m \in \mathbb{N}$ and $n \in \mathbb{N}$, respectively.

Edit 11 January 2021
Thanks to River Li's second answer we now have a proof of the conjectured limits. We can even use partial fractions and the pole expansions of $\csc$ and $\cot$ to simplify the remaining series and obtain the following general result (valid for $m, n \in \mathbb{N}$ coprime and not both equal to $1$):
$$ f\left(\frac{m}{n}\right) = \frac{g_m\left(\frac{\pi}{2m}\right) - g_m \left(\frac{\pi}{2n}\right)}{m^2-n^2} \, , \, g_m = \begin{cases} x \mapsto \frac{\csc(x)}{x} &, \, m \in 2 \mathbb{N} - 1 \\ x \mapsto \frac{\cot(x)}{x} &, \, m \in 2 \mathbb{N}\end{cases} \, . $$

REPLY [5 votes]: Assume that $m\ge 1, n\ge 1$, $m\ne n$ and $\mathrm{gcd}(m, n) = 1$.
By the identity
$$\left|\sin x\right| = \frac{2}{\pi}-\sum_{k = 1}^\infty \frac{4}{\pi(4k^2-1)}\cos(2k x),$$
we have
$$|\sin mt | = \frac{2}{\pi}-\sum_{i = 1}^\infty \frac{4}{\pi(4i^2-1)}\cos(2i mt)$$
and
$$|\cos nt| = |\sin (\pi/2 - nt)|
 = \frac{2}{\pi}-\sum_{j = 1}^\infty \frac{4}{\pi(4j^2-1)}(-1)^j \cos(2jnt).$$
Then we have
\begin{align}
|\sin (mt) \cos (nt)| &= \frac{4}{\pi^2}
- \frac{2}{\pi}\sum_{i = 1}^\infty \frac{4}{\pi(4i^2-1)}\cos(2i mt)\\
&\quad - \frac{2}{\pi}\sum_{j = 1}^\infty \frac{4}{\pi(4j^2-1)}(-1)^j \cos(2jnt)\\
&\quad + \sum_{i = 1}^\infty \sum_{j = 1}^\infty \frac{16(-1)^j}{\pi^2(4i^2-1)(4j^2-1)}\cos(2i mt)\cos(2jnt).
\end{align}
Note that
$$\int_0^\pi \cos(2i mt)\cos(2jnt) \mathrm{d} t = \left\{\begin{array}{ll}
                                                           0 & im - jn \ne 0 \\[4pt]
                                                           \frac{\pi}{2} & im - jn = 0.
                                                         \end{array}
\right.$$
Then we have
\begin{align}
\frac{1}{\pi}\int_0^\pi |\sin (mt) \cos (nt)| \mathrm{d} t
&= \frac{4}{\pi^2} + \sum_{i = 1}^\infty \sum_{j = 1}^\infty \frac{8(-1)^j}{\pi^2 (4i^2-1)(4j^2-1)}\delta(i m - jn)\\
&= \frac{4}{\pi^2} + \sum_{k=1}^\infty  \frac{8(-1)^{km}}{\pi^2 (4k^2n^2-1)(4k^2m^2-1)}\\
&= \frac{4}{\pi^2} + \frac{1}{m^2n^2}\sum_{k=1}^\infty  \frac{8(-1)^{km}}{\pi^2 (4k^2-1/n^2)(4k^2-1/m^2)}.
\end{align}
Note that
$$\left|\sum_{k=1}^\infty  \frac{8(-1)^{km}}{\pi^2 (4k^2-1/n^2)(4k^2-1/m^2)}
\right| \le \sum_{k=1}^\infty  \frac{8}{\pi^2 (4k^2-1)(4k^2-1)} = \frac{\pi^2 - 8}{2\pi^2}.$$
Thus, we have
$$\lim_{\max(m, n) \to \infty} \frac{1}{\pi}\int_0^\pi |\sin (mt) \cos (nt)| \mathrm{d} t = \frac{4}{\pi^2}.$$