Prove $1^2-2^2+3^2-4^2+......+(-1)^{k-1}k^2 = (-1)^{k-1}\cdot \frac{k(k+1)}{2}$ I'm trying to solve this problem from Skiena book, "Algorithm design manual".
I don't know the answer but it seems like the entity on the R.H.S is the summation for series $1+2+3+..$. However the sequence on left hand side is squared series and seems to me of the form:
$-3-7-11-15\ldots $
I feel like its of the closed form:
$\sum(-4i+1)$
So how do I prove that the equality is right?

Hint: In order  to show
\begin{align*}
\sum_{j=0}^k(-1)^{j-1}j^2=(-1)^{k-1}\frac{k(k+1)}{2}\qquad\qquad k\geq 0\tag{1}
\end{align*}
we consider sequences $(a_k)_{k\geq 0}$ and the corresponding generating functions $\sum_{k=0}^{\infty}a_kx^k$ as building  blocks to generate the left hand sum in (1). This enables us to calculate the right hand side of (1).
\begin{array}{crl}
  (a_k)_{k\geq 0}\qquad &\qquad A(x)=&\sum_{k=0}^{\infty}a_kx^k\\
  \hline\\
  ((-1)^{k-1})_{k\geq 0}\qquad&\qquad -\frac{1}{1+x}=&\sum_{k=0}^{\infty}(-1)^{k-1}x^k\\
  ((-1)^{k-1} k)_{k\geq 0}\qquad&\qquad -\left(x\frac{d}{dx}\right)\frac{1}{1+x}
  =&\frac{x}{(1+x)^2}\\
&=&\sum_{k=0}^{\infty}(-1)^{k-1}kx^k\\
  ((-1)^{k-1} k^2)_{k\geq 0}\qquad&\qquad -\left(x\frac{d}{dx}\right)^2\frac{1}{1+x}
  =&\frac{x(1-x)}{(1+x)^3}\\
&=&\sum_{k=0}^{\infty}(-1)^{k-1}k^2x^k\\
  (\sum_{j=0}^{k}(-1)^{j-1} j^2)_{k\geq 0}\qquad&\qquad -\frac{1}{1-x}\left(x\frac{d}{dx}\right)^2\frac{1}{1+x}
  =&\frac{x}{(1+x)^3}\\
&=&\sum_{k=0}^{\infty}\left(\sum_{j=0}^{k}(-1)^{j-1}j^2\right)x^k\tag{2}\\
  \end{array}
We can see in the small intro above the operator $x\frac{d}{dx}$ transforms $a_k$ to $ka_k$ and the multiplication with $\frac{1}{1-x}$ acts as summation operator.
It is also convenient to use the coefficient of operator $[x^n]$ to denote the coefficient of $x^n$ in a generating series.

We  obtain from (2) for $k\geq 1$
\begin{align*}
 \sum_{j=0}^{k}(-1)^{j-1}j^2&=[x^k] \frac{-1}{1-x}\left(x\frac{d}{dx}\right)^2\frac{1}{1+x}\\
 &=[x^k] \frac{x}{(1+x)^3}\\
 &=[x^{k-1}]\sum_{n=0}^{\infty}\binom{-3}{n}x^{n}\tag{3}\\
 &=\binom{-3}{k-1}\\
 &=(-1)^{k-1}\binom{k+1}{2}\tag{4}\\
 &=(-1)^{k-1}\frac{k(k+1)}{2}
  \end{align*}

Comment:


*

*In (3) we use the binomial series representation.

*In (4) we use the formula $\binom{-n}{k}=\binom{n+k-1}{k}(-1)^k$ for binomial coefficients.
