# Finite Sums of Terms 2^(n-i) i^2

The task is to find a closed form for the sum

 \sum^{n}_{i=1}2^{n-i}i^2

Let's define two functions, the generating functions of the corresponding sequences of coefficients:

 f(x) = \sum^{n}_{i=1}2^{n-i}i^{2}x^{i-1}

and

 g(x) = \sum^{n}_{i=1}2^{n-i}x^{i}.

Note that what we need is f(1). Integrate f:

 \int^{x}_{0}f(y)dy = \sum^{n}_{i=1}2^{n-i}\int^{x}_{0}i^{2}y^{i-1}dy = \sum^{n}_{i=1}2^{n-i}ix^{i} + c_0.

Add g(x) to both sides and integrate again:

 (*) \int^{x}_{0}\int^{y}_{0}f(z)dzdy + \int^{x}_{0}g(y)dy = \sum^{n}_{i=1}2^{n-i}x^{i+1} + c_{0}x+c_{1},

where c_0 and c_{1} are arbitrary constants. The sum in the right hand side, that is equal to xg(x) is a geometric series and could be expressed in closed form. Let's do that.

 xg(x)=\sum^{n}_{i=1}2^{n-i}x^{i+1}=2^{n}x\sum^{n}_{i=1}\big( {{x} \over {2}} \big)^{i}=2^{n-1}x^{2}\sum^{n-1}_{i=0}\big( {{x} \over {2}} \big)^{i}.

It follows that

 xg(x)=2^{n-1}x^{2}{\frac{\big({\frac{x}{2}}\big)^{n}-1}{\frac{x}{2}-1}}=x^{2}\frac{x^{n}-2^{n}}{x-2}.

So that

 g(x)=x\frac{x^{n}-2^{n}}{x-2}.

We now differentiate (*) twice:

 f(x) + g'(x) = g'(x) + g'(x) + xg''(x),

i.e.,

 f(x) = g'(x) + xg''(x).

So that f(1) = g'(1) + g''(1).

All that remains is to compute the two derivatives g' and g''.