# Derivation of Energy Stored in a Capacitor

I was looking at the standard derivations of the energy stored in a capacitor, and any that I find seem to begin with the following or a similar integral:

$$W=U=\int_{Q=0}^{Q_f} \phi \, dq$$

Which makes sense, but I'd like to know if there's a way to derive the energy stored in a capacitor $U=\frac12 C \phi^2$ through the definition of work: $W=\int \vec F\cdot \, d\vec{s}$

Here's my work thus far. I can get the correct equation, but I'm not sure if there's a quicker way, or if my reasoning is flawed.

We start with the work needed to move the stored charge into it's placement:

$$W = \int_{r=\infty}^{r=0} {\vec{F} \cdot \, d\vec{s}}$$

Because $\vec{F} = q\vec{E}$, and $\vec{E} = -\vec\nabla \phi$:

$$\int_{r=\infty}^{r=0}{q\vec{E} \cdot \, d\vec{s} }= \int_{r=\infty}^{r=0}{q(-\vec\nabla \phi) \cdot \, d\vec{s} }$$

Our path $\vec{s}$ can be any curve parameterized by time, it is most convenient to be in spherical coordinates $r(t)\hat{r} +\theta(t)\hat{\theta}+\varphi(t)\hat{\varphi}$

So then $d\vec{s} = dr \, \hat{r} + d\theta \, \hat{\theta}+ d\varphi \, \hat{\varphi}$

$\vec\nabla \phi$ is path independent, and therefore does not vary with $\theta$ or $\varphi$, so $\vec\nabla \phi = \frac{\delta \phi}{\delta r} \hat{r} + 0\hat{\theta}+0\hat{\varphi}$, we have

$$\int_{r=\infty}^{r=0}{-q ({\frac{\delta \phi}{\delta r} \hat{r} + 0\hat{\theta}+0\hat{\varphi}}) \cdot \, (dr \, \hat{r} + d\theta \, \hat{\theta}+ d\varphi \, \hat{\varphi}) }= \int_{r=\infty}^{r=0}{-q {\frac{\delta \phi}{\delta r}} \, dr } = \int_{ \phi=0}^{ \phi= \phi_f}{-q \, d \phi } = - \int_{ \phi=0}^{ \phi= \phi_f}{C \phi \, d \phi} =-\frac{1}{2}C \phi_f^2$$

Using $W = - \Delta U$, we have

$$U=\frac{1}{2}C \phi_f^2$$

I think that most of what you've done is correct, and you will have benefitted from this detailed calculation. However, as you probably realise, it's unnecessarily complicated, and is unnecessarily restricted to a capacitor with spherical geometry. The point is that the value of your integral $$\int _{r_1} ^{r_2}q [-\vec{\nabla \phi}].d \vec{s}$$ is path independent for a capacitor of any geometry, and is equal to $q[\phi (r_1)-\phi (r_2)]$.
Work done = charge transferred $\times$ pd between plates
At the end I think you get muddled about the purpose of your integrations. The point is that as the plates acquire charge the pd between them builds up according to $$\Delta \phi=\frac{Q}{C}.$$
So we need to integrate the work done as we transfer each small chunk, q (best now called $dQ$) of charge. So work done is given by $$W=\int _0 ^Q \frac{Q}{C} dQ.$$