<s>[INST] Generating functions - deriving a formula for the sum $1^2 + 2^2 +\cdots+n^2$ I would like some help with deriving a formula for the sum $1^2 + 2^2 +\cdots+n^2$ using generating functions. 
I have managed to do this for $1^2 + 2^2 + 3^2 +\cdots$ by putting
$$f_0(x) = \frac{1}{1-x} = 1 + x + x^2 + x^3 +\cdots$$
$$f_1(x) = x \frac{d}{dx}[f_0(x)] = \frac{1}{(1-x)^2} = 0 + x + 2x^2 + 3x^3 +\cdots$$
$$f_2(x) = x \frac{d}{dx}[f_1(x)] = \frac{x^2+x}{(1-x)^3} = 0^2 + 1^2x + 2^2x^3 + 3^2x^3+\cdots,$$
and I assume I'm supposed to be able to do something similar in this case, but things get trickier when it's bounded by n and I keep getting stuck.
 [/INST] Brute force:
$$f(x) \triangleq \sum_{r=0}^{n+1}x^r=\frac{x^{n+2}-1}{x-1} $$
$$f'(x) = \sum_{r=0}^{n+1}rx^{r-1} = \sum_{r=0}^{n}(r+1)x^r$$
$$f''(x) =  \sum_{r=0}^{n}r(r+1)x^{r-1} \therefore xf''(x)=\sum_{r=0}^{n}r(r+1)x^{r} = \sum_{r=0}^n\left(r^2+r\right)x^r$$
$$f'(x)-(f(x)-x^{n+1}) = \sum_{r=0}^{n}rx^r$$
So $$\sum_{r=1}^nr^2x^r =xf''(x) - (f'(x)-(f(x) - x^{n+1}))$$
Finally take the limit as $x \to 1$, which might get ugly, and Bob's your uncle.
[edit]
Changed $$\sum_{r=1}^nr^2x^r =f''(x) - (f'(x)-(f(x) - x^{n+1}))$$ to $$\sum_{r=1}^nr^2x^r =xf''(x) - (f'(x)-(f(x) - x^{n+1}))$$
</s>