A closed form for $1^{2}-2^{2}+3^{2}-4^{2}+ \cdots + (-1)^{n-1}n^{2}$ Please look at this expression:

$$1^{2}-2^{2}+3^{2}-4^{2} + \cdots + (-1)^{n-1} n^{2}$$

I found this expression in a math book. It asks us to find a general formula for calculate it with $n$.
The formula that book suggests is this: 

$$-\frac{1}{2}\times (-1)^{n} \times n(n+1)$$

Would you mind explaining to me how we get this formula? 

Let $S(n)=1^2+2^2+\dots+n^2$ and $T(n)=1^2-2^2+3^2-4^2+\dots+(-1)^{n-1}n^2$.
Suppose first $n=2k$ is even; then
$$
T(n)=T(2k)=
S(n)-2\bigl(2^2+4^2+\dots+(2k)^2\bigr)=
S(n)-8S(k)
$$
Since
$$
S(n)=\frac{1}{3}n\left(n+\frac{1}{2}\right)(n+1)=\frac{n(2n+1)(n+1)}{6}
$$
We have
$$
T(2k)=\frac{2k(4k+1)(2k+1)}{6}-8\frac{k(2k+1)(k+1)}{6}=
-\frac{2k(2k+1)}{2}
$$
If $n=2k+1$ is odd, then
$$
T(n)=T(2k+1)=S(n)-8S(k)=
\frac{(2k+1)(4k+3)(2k+2)}{6}-8\frac{k(2k+1)(k+1)}{6}
$$
and an easy computation gives
$$
T(2k+1)=\frac{(2k+1)((2k+1)+1)}{2}
$$
So
$$
T(n)=(-1)^{n-1}\frac{n(n+1)}{2}
$$
