Need explanation on a binomial theorem related problem for $\sum_{k=0}^{n} \binom{n}{k}k$ So I ran into this summation $$\sum_{k=0}^{n} \binom{n}{k}k$$
So I have no idea what to do so I looked at what my professor this.  He said 

If we differentiate this $(1+x)^n = \sum_{k=0}^{n} \binom{n}{k}x^k$ we have $n(1+x)^{n-1} = \sum_{k=0}^{n} \binom{n}{k}kx^{k-1}$.  Plugging in $x=1$ gives $\sum_{k=0}^{n} \binom{n}{k}k = n2^{n-1}$.

First of all where did he come up with $(1+x)^n$ and why did he differentiate it?  And then why did he plug in $x = 1$?  I am confused.
 A: Disclaimer: this is an answer to the original question, that was about $\sum_{k=0}^{n}\binom{n}{k}k2^k$.

Assume to have $n$ white balls and to want to perform the following task:


*

*Pick some of the balls ($k\geq 1$) and paint them yellow

*Pick some of the yellow balls and paint them red

*Pick a yellow or red ball and paint it black.


It is pretty clear you may select the balls to be painted yellow in $\binom{n}{k}$ ways, a subset of the yellow balls in $2^k$ ways and the ball to be painted black in $k$ ways. Thus the number of ways for performing the above task is exactly $\sum_{k=0}^{n}\binom{n}{k}k 2^k$ (the contribution given by $k=0$ is irrelevant). On the other hand, the above task can be performed in the following, more efficient way:


*

*Pick some ball, paint it black and decide if has a yellow or red core ($n$ ways for choosing the ball, $2$ ways for choosing the color of its core)

*For each one of the remaining balls, decide if it stays white, becomes yellow or first yellow then red. $n-1$ balls, $3$ possible choices for each ball.


Conclusion:
$$ \sum_{k=0}^{n}\binom{n}{k}k 2^k = 2n\cdot 3^{n-1}.$$

Now the generating functions way. We have:
$$ (1+x)^n = \sum_{k=0}^{n}\binom{n}{k}x^k $$
hence by applying $\frac{d}{dx}$ to both sides:
$$ n (1+x)^{n-1} = \sum_{k=1}^{n}\binom{n}{k} k x^{k-1} $$
$$ nx (1+x)^{n-1} = \sum_{k=1}^{n}\binom{n}{k} k x^{k} $$
By evaluating the last identity at $x=2$ we reach the same conclusion as before.
A: To answer your first question look at the series expansion of $(1+x)^n$.
$$(1+x)^n=\sum_{k=0}^n \binom{n}{k} x^k = 1 + nx + \frac{n(n-1)}{2}x^2...+x^n$$
What happens when you differentiate both sides with respect to x. You get 
$$n(1+x)^{n-1}=n+2\times\frac{n(n-1)}{2}x...+nx^{n-1}=\sum_{k=0}^n \binom{n}{k}kx^{k-1}$$
Now multiply both sides by $x$.
$$nx(1+x)^{n-1}=nx+2\times\frac{n(n-1)}{2}x^2...+nx^{n}=\sum_{k=0}^n \binom{n}{k}kx^{k}$$
Now the right hand sides looks like something you need put $x=1$
$$\sum_{k=0}^n \binom{n}{k}k = n\times2^{n-1}$$
A: Here's one way to find $\displaystyle \sum_{k=0}^n k \binom n k.$
Let $X$ be the number of heads in in $n$ coin tosses. Then $\Pr(X=k) = \dbinom n k \left( \dfrac 1 2 \right)^n.$
But
$$
\operatorname{E}(X) = \text{average number of heads in $n$ tosses} \begin{cases}  =n/2 \\[10pt]
= \sum_{k=0}^n k \Pr(X=k) \end{cases}
$$
Hence those two expressions are equal.
