Finding Derivative of a complicated function I have the following function I want to be able to feed into the Newton-Rhapson root solving algorithm (C++ boost), since an analytical solution is not possible:$$f(p, k, n, Pr)=\left(\sum_{i = 0}^{\lfloor k \rfloor} \binom{n}{i}p^i(1 - p)^{n-i}\right)-Pr$$ $k, n, Pr$ are known values to be plugged in, and $p$ will be found by finding for what value of $p$ does $f(p,k,n,Pr) = 0$.
I know there are several methods of root finding, some use derivatives and some don't. I want to try to use the Newton algorithm as it's one I understand and one I believe works for this purpose. If you plot the function, the x axis goes between 0 and 1, and the line looks something like a backwards s, which can be stretched or squashed and so on depending on what values are fed into it.
For the root finder I need to be able to calculate the first derivative of the function, which I understand the method uses to make it's next 'guess' as it homes in on the root. Calculus has always eluded me quite a bit - I understand in principle from reading the derivative is the instantaneous rate of change and can be visualized as a tangent line that touches the point on the curve. I've read texts that deal with examples and present simple rules like if $f(x) = x^2$, then the derivative is $2x$. However with a function this complex I'm really not sure where to begin figuring out the first derivative. What's the best way to do this? 
Thanks,
Ben W.

Your expression is a sum of terms. Derivative of a sum is the sum of the derivatives.
Every term is a constant times the product of two factors, $p^i$ and $(1-p)^{n-i}$. The derivative of a product given by the product rule $(UV)'=U'V+UV'$.
Both factors are powers of $p$. The rule for powers is $(p^n)'=np^{n-1}$. (More generally, $((ap+b)^n)'=na(ap+b)^{n-1}$).
Put together, you get
$$\sum_{i = 0}^{\lfloor k \rfloor} \binom{n}{i}[ip^{i-1}(1 - p)^{n-i}-(n-i)p^i(1 - p)^{n-i-1}].$$ 
