Alternative way of finding expected value of the negative binomial distribution In a homework problem recently I was faced with the following task: 

Let $X$ have the negative binomial distribution
  $$
f(n;\alpha,p) \equiv P(X = n) = \frac{\Gamma(n+\alpha)}{n!\Gamma(\alpha)} p^\alpha (1-p)^n, \quad n = 0,1,2,\ldots
$$
  Show that $P(X = n)$ can be written on the form
  $$
\exp\bigg\{\frac{\theta n-A(\theta)}\phi - c(n;\phi)\bigg\}1_{\{0,1,2,\ldots\}}(n),
$$
  find $A(\theta)$ and use this to find $E[X]$.

It was rather easy to realize that I would want to do $f(n;\alpha,p) = \exp\{\log f(n;\alpha,p)\}$ and do a change of variable $\theta = \log(1-p)$, since
$$
P(X=n) = \exp\bigg\{
\overbrace{\log\Gamma(n+\alpha) - \log\Gamma(n+1) - \log\Gamma(\alpha)}^{c(n;\phi)} + \overbrace{\alpha \log p}^{-A(\theta)} + \overbrace{n\log(1-p)}^{n\theta}
\bigg\}1_{\{0,1,2,\ldots\}}
$$
with $\phi = 1$.
So I got $A(\theta) = -\alpha \log(1-\mathrm e^\theta)$, and now comes the sneaky part that I do not understand. My professor continues from here to realize that $E[X] = A'(\theta)$, which gives exactly the expected value of a negative binomially distributed variable!
I might just be missing something elementary, but I do not see how we can get the expected value from differentiating $A$. Can someone enlighten me, please?
 A: I found this explanation in Lehmann and Casella, Theory of Point Estimation:
If I'm reading correctly, $P(X=n)$ has the form 
\begin{align*}
  P(X=n)=\exp \left\{c(n;\phi) -A(\theta) + n\theta\right\}.
\end{align*}
Then, since $P$ integrates to 1, 
\begin{align}
   \int \exp \left\{c(n;\phi) -A(\theta) + n\theta\right\} \ dn=1.
\end{align}
Now, you'll have to look up Leibniz integration rule for an explanation of why we can pass $\frac{\partial}{\partial \theta}$ under the integral sign, but if we apply $\frac{\partial}{\partial \theta}$ to both sides of this equation then 
\begin{align*}
  \int (-\frac{d}{d\theta} A(\theta) + n) P(X=n) \ dn = 0.
\end{align*}
Using the fact that $\int P(X=n) dn =1$, this becomes
\begin{align*}
    \int n P(X=n) &= \frac{d}{d\theta} A(\theta), \text{ or equivalently},\\
    E[X] &= A'(\theta).
\end{align*}
NOTE: the integral for this problem is $\sum_{n=0}^\infty \ \cdots \ P(X=n)$, but the argument extends to continuous variables. 
FURTHER NOTE: I think the reason for passing the derivative under the integral sign is that the integral is with respect to a different variable than the derivative.
