<s>[INST] How to compute the  formula $\sum  \limits_{r=1}^d r \cdot 2^r$? Given $$1\cdot 2^1 + 2\cdot 2^2 + 3\cdot 2^3 + 4\cdot 2^4 + \cdots + d \cdot 2^d = \sum_{r=1}^d r \cdot 2^r,$$
how can we infer to the following solution? $$2 (d-1) \cdot 2^d + 2. $$
Thank you
 [/INST] You can use iterative integration of finite differences. The method works as follows. Assume your problem statement is:
$$\sum^n_{r=1} a_r = ?$$
Assume there is a function $S_n$ such that:
$$\sum^n_{r=1} a_r = S_n - S_1 + c$$
By finite difference we have:
$$a_n = \sum^n_{r=1} a_r - \sum^{n-1}_{r=1} a_r = (S_n - S_1 + c) - (S_{n-1} - S_1 + c) = S_n - S_{n-1} = \Delta S_n$$
Now assume we have a guess $T_n$ for $S_n$ such that some error $S'_n$ remains:
$$S_n = T_n + S'_n$$
The error itself can be expressed as a new integral since finite difference distributes over sums. We have:
$$a_n = \Delta S_n = \Delta T_n + \Delta S'_n$$
And hence we have a new sub problem:
$$\sum^n_{r=1} a'_r = \sum^n_{r=1} (a_r - \Delta T_r) = S'_n - S'_1 + c$$
Lets apply the method to the problem at hand, we have:
$$a_r = r\cdot 2^r$$
We can guess:
$$T_n = n\cdot 2^{n+1}$$
We arrive at:
$$a'_r = r\cdot 2^r - (r\cdot 2^{r+1} - (r - 1) \cdot 2^{r-1+1}) = - 2^r$$
We can guess again:
$$T'_n = - 2^{n+1}$$
We arrive at:
$$a''_r = - 2^r - (- 2^{r+1} - - 2^{r-1+1}) = 0$$
So the integration terminated, and the closed form integral is:
$$S_n = T_n + T'_n = n\cdot 2^{n+1} - 2^{n+1}$$
Using this for the sum we get:
$$\sum^n_{r=1} r\cdot 2^r = S_n - S_1 + c = n\cdot 2^{n+1} - 2^{n+1} - (1\cdot 2^{1+1} - 2^{1+1}) + c = 2\cdot (n - 1)\cdot 2^n + c$$
For $c$ we get:
$$\sum^1_{r=1} r\cdot 2^r = 2 = 0 + c$$
Saw this already in the 1980's in computer algebra systems (CAS), simpler than Gosper's method and different scope.
Bye
</s>