<s>[INST] $\lim_{x\to 0} \frac{\cos \left(\pi \cdot \frac{1-\cos (ax)}{x^2}\right)}{x^2} $ I have to find for which values of $a \in \Bbb N, a \ne 0$ the following limit exists and it is finite:
$$\lim_{x\to 0} \frac{\cos \left(\pi \cdot \frac{1-\cos (ax)}{x^2}\right)}{x^2}  $$
Applying L'Hôpital's rule:
$$\frac{1-\cos (ax)}{x^2}\sim \frac{\sin (ax) \cdot a}{2x}\sim \frac{a^2}{2}$$
Then $$ \frac{\cos (\pi \cdot \frac{1-\cos (ax)}{x^2})}{x^2}  \sim   \frac{\cos (\pi \cdot \frac{a^2}{2})}{x^2}.$$
$$\cos (\pi \cdot \frac{a^2}{2})=0 \implies a^2=1+2k, \quad k \in \Bbb N$$
and in this case the limit is $0$.
In the book the suggested solution is $a^2=1+2k$ for which the limit is $$ \frac{(-1)^k \cdot (2k+1)^2\cdot\pi}{24}$$
but I don't understand this solution.
Trying to solve the limit with $a^2=1+2k$:
$$ \frac{\cos \left(\pi \cdot \frac{1-\cos (ax)}{x^2}\right)}{x^2} \sim \frac{-\sin (\pi \cdot \frac{1-\cos ax}{x^2}) \cdot \pi \cdot  \frac{\sin (ax)  a  x^2 - (1-\cos (ax))  2x}{x^4}}{2x} $$$$ =  \sin \left( \frac{\pi}{2}+k \pi\right) \cdot \pi \cdot \frac{(1-\cos(ax))2- \sin(ax) ax}{2 \cdot x^4}$$$$= (-1)^k \cdot \pi \cdot \frac{(1-\cos(ax))2- \sin(ax) ax}{2 \cdot x^4} $$
 [/INST] Using l'Hôpital in this case is not the best strategy. You have
$$
\cos(ax)=1-\frac{a^2x^2}{2}+\frac{a^4x^4}{24}+o(x^4)
$$
and therefore
$$
\pi\frac{1-\cos(ax)}{x^2}=\pi\frac{a^2}{2}-\pi\frac{a^4x^2}{24}+o(x^2)
$$
In order for the limit to be finite, we need that
$$
\frac{a^2\pi}{2}=\frac{\pi}{2}+k\pi
$$
for some integer $k$, so $a^2=1+2k$. Now the numerator is
$$
\cos\Bigl(\frac{\pi}{2}+k\pi-\frac{a^4\pi x^2}{24}+o(x^2)\Bigr)=
(-1)^k\sin\Bigl(\frac{a^4\pi x^2}{24}+o(x^2)\Bigr)=
(-1)^k\frac{a^4\pi x^2}{24}+o(x^2)
$$
and therefore the limit is
$$
(-1)^k\frac{(2k+1)^2\pi}{24}
$$
Obviously $k$ should be a nonnegative integer.
</s>