<s>[INST] What is $\lim_{x\to0} \frac{(\cos x + \cos 2x + \dots+ \cos nx - n)}{\sin x^2}$? What is the limit of $$\lim_{x\to0} \frac{\cos x + \cos 2x + \dots+ \cos nx - n}{\sin x^2}$$
 [/INST] $$
\begin{align}
& \lim_{x\to0}\frac{\cos x+\cos 2x+\cdots+\cos nx-n}{\sin x^2} \\[10pt]
& =\lim_{x\to0} \frac{\cos x -1+\cos 2x -1+\cdots+\cos nx-1}{x^2} \cdot\frac{x^2}{\sin x^2} \\[10pt]
& = -\left(\frac{1}{2} + \frac{4}{2}+\frac{9}{2}+\cdots+\frac{n^2}{2}\right)\cdot1=-\frac{n(n+1)(2n+1)}{12}.
\end{align}
$$
We applied
$$\lim_{x\to0}\frac{1-\cos nx}{x^2}=\frac{n^2}{2} $$
</s>