Energy stored in a capacitor in an RC circuit Suppose we have a capacitor of capacitance $C$ and a cell of emf $E$, why is the maximum energy stored in a capacitor equal to $\tfrac{1}{2}CE^2$? I feel confused because, the potential difference against the capacitor will be less than the emf of the cell because of the potential drop across the resistor. What is the flaw in my thinking?
 A: Once the capacitor has fully charged the current in the circuit will be zero, so the voltage drop across the resistor is zero and hence the voltage across the capacitor is equal to the cell voltage.
Having said this, the current falls exponentially with time so in principle the current takes an infinite time to fall to zero, and the voltage across the capacitor takes an infinite time to rise to $E$. However this is a somewhat pedantic position as in most cases the voltage across the capacitor will rapidly be indistinguishable from $E$.
A: 
What is the flaw in my thinking?

The voltage across the capacitor in the series RC circuit given, assuming zero initial capacitor voltage, is given by 
$$v(t) = E\left(1 - e^{-\frac{t}{RC}} \right), t \ge 0$$
Note that $v(t) \rightarrow E$ as $t \rightarrow \infty$.
The energy stored in the capacitor, as a function of time, is
$$U(t) = \frac{Cv^2}{2} = \frac{CE^2}{2}\left(1 - e^{-\frac{t}{RC}} \right)^2, t \gt 0$$
The maximum energy stored is thus
$$U_{max} = \frac{CE^2}{2}$$
