Finding $\lim_{n\to\infty}\frac1{n^3}\sum_{k=1}^{n-1}\frac{\sin\frac{(2k-1)\pi}{2n}}{\cos^2\frac{(k-1)\pi}{2n}\cos^2\frac{k\pi}{2n}}$ 
For all $n\ge 1$, let
$$
a_{n}=\sum_{k=1}^{n-1} \frac{\sin \left(\frac{(2 k-1) \pi}{2 n}\right)}{\cos ^{2}\left(\frac{(k-1) \pi}{2 n}\right) \cos ^{2}\left(\frac{k \pi}{2 n}\right)}
$$
Find $\displaystyle\lim_{n\to\infty}\frac{a_n}{n^3}$.

This is a problem from the 2019 Putnam competition.
The official solutions use two different strategies; one reduces the expression as a telescoping sum and the other uses the asymptotic property of sine near zero. The two community-wiki answers below essentially elaborate on the official solutions.
Remark. I am curious if one can write $\displaystyle\frac{a_n}{n^3}$ as a Riemann sum so that one can write the limit as an integral. Naively, the fraction looks very much like $\frac{1}{n}\sum_{k=1}^{n-1}\cdots$, which is in the setting of Riemann sums. (This only serves as a comment, not a requirement for solving the problem.)
 A: This is based on one of the official solutions for the problem.
We first write $a_n$ as a telescoping sum. Notice that
$$
\frac{1}{AB} = \left(\frac{1}{A}-\frac{1}{B}\right)\cdot \frac{1}{B-A}\,.
$$
It follows that the summand of $a_n$ can be written as
$$
\left(\frac{1}{\cos ^{2}\left(\frac{(k-1) \pi}{2 n}\right)}-\frac{1}{\cos ^{2}\left(\frac{k \pi}{2 n}\right)}\right)\cdot
\frac{\sin \left(\frac{(2 k-1) \pi}{2 n}\right)}{\cos ^{2}\left(\frac{k \pi}{2 n}\right)-\cos ^{2}\left(\frac{(k-1) \pi}{2 n}\right)}\tag{1}
$$
If we can show that the quantity
$$
\frac{\sin \left(\frac{(2 k-1) \pi}{2 n}\right)}{\cos ^{2}\left(\frac{k \pi}{2 n}\right)-\cos ^{2}\left(\frac{(k-1) \pi}{2 n}\right)}\tag{2}
$$
is independent of $k$, then we have a telescoping sum.
By the double angle and sum-product identities for cosine, we have
\begin{align} 
&\phantom{=}2 \cos ^{2}
\left(\frac{(k-1) \pi}{2 n}\right)
-2 \cos ^{2}\left(\frac{k \pi}{2 n}\right) \\
&=\cos \left(\frac{(k-1) \pi}{n}\right)-\cos \left(\frac{k \pi}{n}\right) 
\quad &(2\cos^2x = \cos 2x - 1)
\\ 
&=2 \sin \left(\frac{(2 k-1) \pi}{2 n}\right) \sin \left(\frac{\pi}{2 n}\right) 
\quad &(\cos \theta-\cos \varphi=-2 \sin \left(\frac{\theta+\varphi}{2}\right) \sin \left(\frac{\theta-\varphi}{2}\right))
\end{align}
and it follows that the summand in $a_n$ can be written as
$$
\frac{1}{\sin \left(\frac{\pi}{2 n}\right)}\left(-\frac{1}{\cos ^{2}\left(\frac{(k-1) \pi}{2 n}\right)}+\frac{1}{\cos ^{2}\left(\frac{k \pi}{2 n}\right)}\right)
$$
Thus the sum telescopes and we find that
$$
a_{n}=\frac{1}{\sin \left(\frac{\pi}{2 n}\right)}\left(-1+\frac{1}{\cos ^{2}\left(\frac{(n-1) \pi}{2 n}\right)}\right)=-\frac{1}{\sin \left(\frac{\pi}{2 n}\right)}+\frac{1}{\sin ^{3}\left(\frac{\pi}{2 n}\right)}
$$
Finally, since $\lim_{x\to 0}\frac{\sin x}{x}=1$, we have
$$
\lim_{n\to\infty} n\sin\frac{\pi}{2n} = \frac{\pi}{2}
$$
and thus
$$
\lim_{n\to\infty}\frac{a_n}{n^3} = \frac{8}{\pi^3}\;.
$$
A: This solution is based on one of the official solutions for the problem.
The dummy variable $k$ is a dummy variable in $a_n$. Since
\begin{align}
\sum_{k=1}^{n-1}f(k;n) &= f(1;n)+f(2;n)+\cdots+f(n-1;n)\\
&= f(n-1;n) + f(n-2;n) +\cdots f(n-(n-1);n)\\
&= \sum_{k=1}^{n-1}f(n-k;n)
\end{align}
we can substitute $n-k$ for $k$ to obtain
$$
a_{n}=\sum_{k=1}^{n-1} \frac{\sin \left(\frac{(2 k+1) \pi}{2 n}\right)}{\sin ^{2}\left(\frac{(k+1) \pi}{2 n}\right) \sin ^{2}\left(\frac{k \pi}{2 n}\right)}
$$
We then use the estimate
$$
\frac{\sin x}{x} = 1+O(x^2)\quad \text{as }  x\to 0
$$
to rewrite the summand as
$$
\frac{\left(\frac{(2 k-1) \pi}{2 n}\right)}{\left(\frac{(k+1) \pi}{2 n}\right)^{2}\left(\frac{k \pi}{2 n}\right)^{2}}\left(1+O\left(\frac{k^{2}}{n^{2}}\right)\right)
$$
which simplifies to
$$
\frac{8(2 k-1) n^{3}}{k^{2}(k+1)^{2} \pi^{3}}+O\left(\frac{n}{k}\right)
$$
Consequently,
$$
\begin{aligned} \frac{a_{n}}{n^{3}} &=\sum_{k=1}^{n-1}\left(\frac{8(2 k-1)}{k^{2}(k+1)^{2} \pi^{3}}+O\left(\frac{1}{k n^{2}}\right)\right) \\ 
&=\left[\frac{8}{\pi^{3}} \sum_{k=1}^{n-1} \frac{(2 k-1)}{k^{2}(k+1)^{2}}\right]
+O\left(\frac{\log n}{n^{2}}\right) \end{aligned}
$$
Finally, note that
$$
\sum_{k=1}^{n-1} \frac{(2 k-1)}{k^{2}(k+1)^{2}}=\sum_{k=1}^{n-1}\left(\frac{1}{k^{2}}-\frac{1}{(k+1)^{2}}\right)=1-\frac{1}{n^{2}}\;.
$$
It is now easy to finish the calculation.
