<s>[INST] 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?
 [/INST] The following proof might be longer than necessary, but it illustrates a general method that is useful for many similar problems.
Let $$A(k) = 1^2 - 2^2 + 3^2 - 4^2 + \ldots + (-1)^{k-1} k^2$$ and
$$B(k)=(-1)^{k-1} \cdot \frac{k(k+1)}2.$$ It suffices to prove that $A(0)=B(0)$ and $$A(k)-A(k-1)=B(k)-B(k-1)$$ for all $k\ge1$.
It is clear that $A(0)=B(0)=0$.
$$\begin{align*} 
A(k) - A(k-1) &= (-1)^{k-1} k^2 \\
B(k) - B(k-1) &= (-1)^{k-1} \cdot \frac{k(k+1)}2 
- (-1)^{k-2} \cdot \frac{(k-1)k}2 \\
&= (-1)^{k-1} \left(\frac{k(k+1)}2 + \frac{(k-1)k}2 \right) \\
&= (-1)^{k-1} \left(\frac{k^2+k}2 + \frac{k^2-k}2 \right) \\
&= (-1)^{k-1} k^2
\end{align*}
$$
To complete the proof, note that for all $k \ge 0$,
$$
\begin{align*}
A(k) &= A(0) + \sum_{i=1}^k (A(i) - A(i-1)) \\
&= B(0) + \sum_{i=1}^k (B(i) - B(i-1)) \\
&= B(k).
\end{align*}
$$
</s>