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? 
 A: 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}
$$
A: We can also use the geometric sum $$\sum_{k=1}^{n}\left(-1\right)^{k-1}x^{k}=-\frac{x\left(\left(-1\right)^{n}x^{n}-1\right)}{x+1}
 $$ so taking the derivative and multiplicand by $x$ $$\sum_{k=1}^{n}\left(-1\right)^{k-1}kx^{k}=-\frac{\left(-1\right)^{n}nx^{n+1}}{x+1}+\frac{x^{2}\left(\left(-1\right)^{n}x^{n}-1\right)}{\left(x+1\right)^{2}}-\frac{x\left(\left(-1\right)^{n}x^{n}-1\right)}{x+1}
 $$ and finally taking again the derivative and setting $x=1$ we have

$$\sum_{k=1}^{n}\left(-1\right)^{k-1}k^{2}=\color{red}{\frac{\left(-1\right)^{n-1}n\left(n+1\right)}{2}}$$ 

as wanted.
A: One may observe that, for all $k\ge1$, one has
$$
\frac{1}{2}(-1)^{k-1} k(k+1)-\frac{1}{2}(-1)^{k} (k-1)k=(-1)^{k-1} k^2
$$ then summing from $k=1$ to $k=n$, terms telescope and one gets the announced result:

$$
\frac{1}{2}(-1)^{n-1} n(n+1)=\sum_{k=1}^n(-1)^{k-1} k^2.
$$

A: A natural and tricky way to do this:
Let $\displaystyle S_n=\sum_{k=1}^n k^2=\frac{n(n+1)(2n+1)}2$ and $\displaystyle P_n=\sum_{k=1}^n(-1)^{k-1} k^2$.
Note that $$S_n-P_n=2\sum_{k=1, k\text{ even}}^nk^2=\sum_{k=1}^{\lfloor \frac n2\rfloor}(2k)^2=8\sum_{k=1}^{\lfloor \frac n2\rfloor}k^2=\frac 86 \frac{\lfloor \frac n2\rfloor(\lfloor \frac n2\rfloor+1)(2\lfloor \frac n2\rfloor+1)}2$$
Note that $2\lfloor \frac n2\rfloor = n$ if $n$ is even and $n-1$ if $n$ is odd.
Rewrite $$S_n-P_n=\frac{n(n+2)(2n+2)}6 \text{ for even n}$$
$$S_n-P_n=\frac{2(n-1)n(n+1)}6 \text{ for odd n}$$
and you'll get your formula for $P_n$
A: Another approach is to write for $n=2m$
$$\begin{align}
\sum_{k=1}^{2m}(-1)^{k-1}k^2&=\sum_{k=1}^{m}(2k-1)^2-\sum_{k=1}^{m}(2k)^2\\\\
&=\sum_{k=1}^{m}\left((2k-1)^2+(2k)^2\right)-2\sum_{k=1}^{m}(2k)^2\\\\
&=\sum_{k=1}^{2m}k^2-8\sum_{k=1}^{m}k^2\\\\
&=\frac{2m(2m+1)(4m+1)}{6}-8\frac{m(m+1)(2m+1)}{6}\\\\
&=-m(2m+1)\\\\
&=-\frac12 n(n+1)
\end{align}$$
as expected for even values of $n$.
If $n=2m+1$, we repeat the previous development with the addition of the extra term $(2m+1)^2$.  The result is that the sum is equal to $+\frac12 n(n+1)$.  
Putting it all together, we obtain the coveted result 
$$\sum_{k=1}^{n}(-1)^{k-1}k^2=(-1)^{n-1}\frac12 n(n+1)$$
A: We wish to show that
$$
1^{2}-2^{2}+3^{2}-4^{2} + \dotsb + (-1)^{n-1} n^{2}=
(-1)^{n+1}\frac{n(n+1)}{2}\tag{1}
$$
To do so, induct on $n$. 
The base case $n=1$ is simple to verify.
Now, suppose that $(1)$ holds. Then
\begin{align*}
1^{2}-2^{2}+3^{2}-4^{2} + \dotsb + (-1)^{n} (n+1)^{2}
&= (-1)^{n+1}\frac{n(n+1)}{2}+(-1)^{n} (n+1)^{2} \\
&= (-1)^n\left\{
-\frac{1}{2}\,n^2-\frac{1}{2}\,n+n^2+2\,n+1
\right\} \\
&= (-1)^{n+2}\left\{
\frac{1}{2}\,n^2+\frac{3}{2}\,n+1
\right\} \\
&= (-1)^{n+2}\frac{1}{2}\left\{
n^2+3\,n+2
\right\} \\
&= (-1)^{n+2}\frac{(n+1)(n+2)}{2}\\
\end{align*}
This closes the induction.
A: $$\sum_{r=1}^{2k}(-1)^{r-1}r^2=\sum_{r=1}^k\{(2r-1)^2-(2r)^2\}=\sum_{r=1}^k(1-4r)$$
Using the summation formula of Arithmetic Series, 
$$\sum_{r=1}^k(1-4r)=\dfrac k2\{2(1-4)+(k-1)(-4)\}=-k(2k+1)$$
Put $2k=n$
$$\sum_{r=1}^{2k+1}(-1)^{r-1}r^2=\sum_{r=1}^{2k}(-1)^{r-1}r^2+(-1)^{2k+1-1}(2k+1)^2$$ $$=-k(2k+1)+(2k+1)^2=(2k+1)\{(2k+1-k)\}=?$$
Put $2k+1=n\iff k=\dfrac{n-1}2$
