# Why do I get the wrong answer when determining the charge in a capacitor using definition of voltage?

I want to determine the charge in a capacitor. I didn't remember the formula for it, $Q = C \cdot V$, so I tried to derive it. This is how I went forwards. I've made the assumption that the capacitor has no initial charge. $v = \frac{dw}{dq} \Leftrightarrow dw = v \space dq \Rightarrow \int dw = \int v \space dq \Rightarrow w = v \space q$.

Since the energy stored in a capacitor is $w = \frac{1}{2} C v_c^2$, I tried to plug this in which results in the equation for charge: $q = \frac{1}{2} C v_c$.

This is half of the expected value, so where it the faulty logic here?

If I start by using the definition of current, I get the correct equation:

$i = \frac{dq}{dt} \Leftrightarrow dq = i \space dt$

$i_c = C \frac{dv_c}{dt} \Leftrightarrow i_c \space dt = C \space dv_c$

$dq = C \space dv_c \Rightarrow q = C \space v_c$

• Oh no... this "half of energy" thing again.. – Eugene Sh. Nov 30 '17 at 20:32
• $v$ is not a constant, so your integral of $v\:dq$ is wrong. – Chu Nov 30 '17 at 20:40
• @Chu Of course! Silly me, there had to be something wrong with the math. Thanks! – eirik-ff Nov 30 '17 at 21:21

May as well document what Chu pointed out:

\begin{align*} \textrm{d} w &= v\:\textrm{d} q& Q&=C\: V\\ &\therefore\\ \int \textrm{d} w &= \int_0^Q v\:\textrm{d} q\\\\ W &= \int_0^Q v\:\textrm{d} q & &=\int_0^Q \frac{q}{C}\:\textrm{d} q\\\\ &= \frac{1}{C} \int_0^Q q\:\textrm{d} q & &= \frac{1}{C} \left[\frac{1}{2}q^2\right]\bigg|_0^Q\\\\ &= \frac{1}{C} \left[\frac{1}{2}Q^2\right] & &= \frac{1}{C} \left[\frac{1}{2}C^2V^2\right]\\\\ &= \frac{1}{2} C \: V^2 \end{align*}