I have the following sequence given:
$$\sum_{k=1}^{n} (-1)^{k}k^{2}$$
How can I do this? The sequence goes like this:
$$-1 + 4 - 9 + 16 - 25 + 36 - ...$$
So it doesn't have any variables inside. It looks like a geometric sequence for me, so the simple known formula would do the whole thing, but I actually doubt it's that simple.
So there are some generating functions that are quite similar, like:
$$\sum (-1)^{n}x^{n} = x - x^{2} + x^{3} - x^{4} + ...$$
But, uhm, well...what's next? The lack of x variable seems a bit strange to me.
Note that the generating function for the sequence $(-1)^k$ is $\frac{1}{1+x}$. Also observe that if $(a_k)$ is any sequence with generating function $f$, then the generating function for the sequence $(ka_k)$ is $x\frac{d}{dx} f$ and the generating function for the sequence $\sum a_k$ is $\frac{f}{1-x}$. With this in mind, we find the generating function for the sequence $(-1)^k k$ to be $$x\frac{d}{dx}\frac{1}{1+x}=-\frac{x}{(1+x)^2}$$ and so the generating function for $(-1)^k k^2$ is $$-x\frac{d}{dx}\frac{x}{(1+x)^2}=-\frac{(1-x)x}{(1+x)^3}$$
Thus, your generating function is $$-\frac{x}{(1+x)^3}$$
If we use partial fractions, we can write this as $$\frac{1}{(1+x)^3}-\frac{1}{(1+x)^2}$$ If we use the formla $$\frac1{(1+x)^k}=\sum_{n\ge 0}\binom{n+k-1}{k-1}(-x)^n$$ we finally get that the sum is $$\sum_{k=1}^n(-1)^k k^2=(-1)^n\left(\binom{n+2}{2}-\binom{n+1}{1}\right)$$
Edit: \begin{align} \frac{f}{1-x}&=\frac{1}{1-x}\sum_{k=0}^{\infty}a_kx^k=(1+x+...)\sum_{k=0}^{\infty}a_kx^k=\\ &=a_0+(a_0+a_1)x+(a_0+a_1+a_2)x^2+...= \\ &=\sum_{k=0}^\infty \left( \sum_{n=0}^k a_n\right)x^k \end{align}