Find out if the series $\sum_{k=1}^{\infty}k^2\left(\cos\left(\pi k-\frac{1}{k}\right)-(-1)^k\right)$ is divergent. I need to find out if the folowing series is divergent.
$$
\sum_{k=1}^{\infty}k^2\left(\cos\left(\pi k-\frac{1}{k}\right)-(-1)^k\right)
$$
I did the following:
$$
k^2\left(\cos\left(\pi k-\frac{1}{k}\right)-(-1)^k\right)=
k^2\left(\cos\left(\pi k-\frac{1}{k}\right)-\cos(\pi k)\right)=\\  
=-2k^2\sin\left(\pi k-\frac{1}{2k}\right)\sin\left(\frac{-1}{2k}\right)=
2k^2\sin\left(\pi k-\frac{1}{2k}\right)\sin\frac{1}{2k}=\\
=2k^2(-1)^{k+1}\sin^2\frac{1}{2k}=A\\
\lim_{k\rightarrow\infty}A=\lim_{k\rightarrow\infty}(-1)^{k+1}\frac{2k^2}{4k^2}=
\lim_{k\rightarrow\infty}\frac{(-1)^{k+1}}{2}\ne0\Rightarrow\\
\text{The initial series is divergent.}
$$
Is my solution correct?
 A: Yes, it's correct. Also you can use taylor series of $\cos$ to show the parentheses tend to $0$ by rate of a multiple of $\frac{1}{k^2}$ that result like what yourself achieved.
A: $\sum_{k=1}^{\infty}k^2\left(\cos\left(\pi k-\frac{1}{k}\right)-(-1)^k\right)
$
Let
$a_k
=\cos\left(\pi k-\frac{1}{k}\right)-(-1)^k
$.
$\begin{array}\\
a_{2n}
&=\cos\left(\pi 2n-\frac{1}{2n}\right)-(-1)^{2n}\\
&=\cos\left(-\frac{1}{2n}\right)-1\\
&=\cos\left(\frac{1}{2n}\right)-\cos(0)\\
&=-2\sin^2(1/(4n))\\
&=-\dfrac1{8n^2}+\dfrac{c_{2n}}{n^4}
\qquad\text{where } |c_{2n}| < 1\\
\text{so}\\
(2n)^2a_{2n}
&=-\dfrac1{2}+\dfrac{c_{2n}}{n^2}\\
a_{2n+1}
&=\cos\left(\pi (2n+1)-\frac{1}{2n+1}\right)-(-1)^{2n+1}\\
&=\cos\left(\pi-\frac{1}{2n+1}\right)+1\\
&=-\cos\left(\frac{1}{2n+1}\right)+\cos(0)\\
&=2\sin^2(1/(2(2n+1)))\\
&=\dfrac1{2(2n+1)^2}+\dfrac{c_{2n+1}}{n^4}
\qquad\text{where } |c_{2n+1}| < 1\\
\text{so}\\
(2n+1)^2a_{2n+1}
&=\dfrac1{2}+\dfrac{c_{2n}}{n^2}\\
\end{array}
$
Since the terms
do not go to zero,
the sum diverges.
Note that if the first $2n$ terms are considered,
the sum does converge,
so this series could be said
to converge to two sums,
one for the even terms
and one for the odd terms.
Also note that if we consider
$\sum ka_k$,
then
$ka_k
\approx \dfrac{(-1)^{k+1}}{4k}
$,
so this will converge
by the alternating series theorem.
