# Math Help - Solving sum

1. ## Solving sum

How to solve this or simplify? $\sum_{k=0}^{n}\binom{n}{k}k^2p^k(1-p)^(n-k)$

2. ## Re: Solving sum

Originally Posted by Garas
How to solve this or simplify? $\sum_{k=0}^{n}\binom{n}{k}k^2p^k(1-p)^{n-k}$
Start with the binomial expansion $(p+q)^n = \sum_{k=0}^{n}\binom{n}{k}p^kq^{n-k}.$ Differentiate partially with respect to p (keeping q constant), then multiply both sides by p. That will give $np(p+q)^{n-1} = \sum_{k=0}^{n}\binom nk kp^kq^{n-k}.$ Now do the same thing again: $np(p+q)^{n-1} + n(n-1)p^2(p+q)^{n-2} = \sum_{k=0}^{n}\binom nk k^2p^kq^{n-k}.$ Finally, put $q=1-p$ to get $\sum_{k=0}^{n}\binom{n}{k}k^2p^k(1-p)^{n-k} = np+n(n-1)p^2.$