Solution (source code)

= Solution

Multiply the <birth-death master equation> by $n$ and sum. Index shifts give
$$
\dot\mu=(B-D)\mu.
$$
For the second moment, a birth changes $n^2$ by $2n+1$ and a death changes it by $-2n+1$, so
$$
\frac d{dt}\mathbb E[N^2]
=2(B-D)\mathbb E[N^2]+(B+D)\mu.
$$
Since $\sigma^2=\mathbb E[N^2]-\mu^2$,
$$
\boxed{\ (\sigma^2)'=2(B-D)\sigma^2+(B+D)\mu\ }.
$$
Together these are the <moment equations of a linear birth-death process>.