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$$