<s>[INST] Double Counting(combinatorial proof) for $1^2\binom{n}{1} + 2^2\binom{n}{2}+3^2\binom{n}{3}+...+n^2\binom{n}{n}$ = $n(n+1)2^{n-2}$ can anyone help me with double-counting proof for this equation:
$1^2\binom{n}{1} + 2^2\binom{n}{2}+3^2\binom{n}{3}+...+n^2\binom{n}{n}$ = $n(n+1)2^{n-2}$
I tried this example: we have n+1 bits and at least two "1" bits. it gives just the right side. and also looking at right side in $\binom{n+1}{2}2^{n-1}$ may help.
 [/INST] I only know how to prove it analytically. Let $f(x)=(1+x)^{n}=\sum_{k=0}^{n}{n \choose k}x^{k}.$
Differentiating, we have 
$$
f'(x)=\sum_{k=1}^{n}kx^{k-1}{n \choose k}.
$$
Multiply both sides by $x$ and differentiate them again, then we have
\begin{eqnarray*}
\frac{d}{dx}\{xf'(x)\} & = & \frac{d}{dx}\sum_{k=1}^{n}kx^{k}{n \choose k}\\
f'(x)+xf''(x) & = & \sum_{k=1}^{n}k^{2}x^{k-1}{n \choose k}.
\end{eqnarray*}
Put $x=1$, then we have 
\begin{eqnarray*}
 &  & \sum_{k=1}^{n}k^{2}{n \choose k}\\
 & = & f'(1)+f''(1)\\
 & = & n\cdot2^{n-1}+n(n-1)2^{n-2}\\
 & = & 2^{n-2}n(n+1),
\end{eqnarray*}
provided that $n\geq2$.
</s>