Limit of $x^2\sin\left(\ln\sqrt{\cos\frac{\pi}{x}}\right)$

Recall that, as $u \to 0$, we have $$ \begin{align} \cos u& =1-\frac {u^2}{2}+\mathcal{O}(u^3)\\ \sin u& =u+\mathcal{O}(u^3)\\ \ln (1+u)&=u-\frac {u^2}{2}+\mathcal{O}(u^3) \end{align} $$ giving, as $x \to \infty$, $$ \cos\frac{\pi}{x}=1-\frac{\pi^2}{2x^2}+\mathcal{O}\left(\frac{1}{x^3}\right) $$ $$ \begin{align} \log \left(\cos\frac{\pi}{x}\right)&=\log \left(1-\frac{\pi^2}{2x^2}+\mathcal{O}\left(\frac{1}{x^3}\right)\right)\\\\ \log \left(\cos\frac{\pi}{x}\right)&=-\frac{\pi^2}{2x^2}+\mathcal{O}\left(\frac{1}{x^3}\right)\\\\ \log \left(\sqrt{\cos\frac{\pi}{x}}\right)&=-\frac{\pi^2}{4x^2}+\mathcal{O}\left(\frac{1}{x^3}\right) \end{align} $$ and $$ \begin{align} \sin \left(\log \left(\sqrt{\cos\frac{\pi}{x}}\right)\right)&=-\frac{\pi^2}{4x^2}+\mathcal{O}\left(\frac{1}{x^3}\right)\\\\ x^2\sin \left(\log \left(\sqrt{\cos\frac{\pi}{x}}\right)\right)&=-\frac{\pi^2}{4}+\mathcal{O}\left(\frac{1}{x}\right) \end{align} $$ giving $-\dfrac{\pi^2}{4}$ for the desired limit.


Do the substitution $t=1/x$, so the limit is easier: $$ \lim_{t\to0^+}\frac{\sin\ln\sqrt{\cos(\pi t)}}{t^2} $$ Now observe that, since $\ln\sqrt{\cos\pi t}$ is monotonic in a right neighborhood of $0$, you can say that $$ \lim_{t\to0^+}\frac{\sin\ln\sqrt{\cos(\pi t)}}{\ln\sqrt{\cos(\pi t)}}=1 $$ so you want to compute $$ \lim_{t\to0^+}\frac{\ln\sqrt{\cos(\pi t)}}{t^2}= \frac{1}{2}\lim_{t\to0^+}\frac{\ln\cos(\pi t)}{t^2} $$ Let's set $\pi t=2u$, so the limit becomes $$ \frac{\pi^2}{8}\lim_{u\to0^+}\frac{\ln(1-2\sin^2u)}{u^2} $$ Now recall that $\lim_{z\to0}(\ln(1-z))/z=-1$ and you can write the limit as $$ -\frac{\pi^2}{8}\lim_{u\to0^+}\frac{2\sin^2u}{u^2} $$ so the given limit ends up to be $-\pi^2/4$.