Energy dissipated across a resistor when charging a capacitor I am a beginner in Physics and I am a little confused about RC circuits.  I am working on a project in which I am measuring the power loss from a resistor when charging a capacitor in an R-C circuit.
I understand that the energy stored on a capacitor is $E=\frac {CV^2}{2}$. And the power loss on the resistor would be $RI^2$ integrated over time.
Questions


*

*Wouldn't $\frac {CV^2}{2}$ also equal $RI^2$ integrated over time? I am finding that my calculated values for power loss across a resistor and energy on a capacitor are not equal or even close to one another. 

*Would it be power lost or energy lost across the resistor? I am a little confused about units.
Thank you very much!
 A: Your confusion seems to be about the distinction between energy and power. Here $I^2 R$ is power dissipated, and its integral is an energy. So your opening paragraph should read "The power loss in the resistor is $I^2 R$ so the energy lost would be $I^2 R$ integrated over time". 
Here is how it works out. I will first treat the case where a capacitor has been charged to some voltage $V_0$ and then starting at time $t=0$ is discharged through a resistor, with no other components in the circuit (including no battery or voltage source for example). After that I will comment on what happens when charging a capacitor from zero.
For a discharging capacitor the formula for the current in the circuit can be derived from circuit laws, it is:
$$
I = I_0 e^{-t / RC}
$$
where $I_0 = V_0/R$ if $V_0$ is the initial voltage on the capacitor, which is $V_0 = Q/C$ for a stored charge $Q$. The combination $(RC)$ has the dimensions of time and is called the time constant of the circuit.
The power dissipated in the resistor at any given moment is
$$
R I^2 = R I_0^2 e^{-2 t / RC}
$$
therefore the total energy lost to this dissipation is
$$
E = \int_0^\infty R I_0^2 e^{-2t/RC} dt = R I_0^2\left[ -(RC/2) e^{-2t/RC} \right]_0^\infty
= \frac{1}{2} I_0^2 R^2 C .
$$
Now, using $I_0 = V_0/R$ we can also write this
$$
E = \frac{1}{2} C V_0^2 
$$
which we can recognize as the energy initially stored in the capacitor.
This illustrates nicely the principle of conservation of energy.
Now let's treat a charging capacitor.
All the above applies unchanged, because the current behaves the same way!
Nevertheless, this is a different experiment. When a capacitor is charged from zero to some final voltage by the use of a voltage source, the above energy loss occurs in the resistive part of the circuit, and for this reason the voltage source then has to provide both the energy finally stored in the capacitor and also the energy lost by dissipation during the charging process. Now it is the energy provided by the voltage source that gives the overall conservation of energy. The maths shows this perfectly correctly but one has to be aware of this aspect of the physics in order to understand what the maths means.
A: Well, when we have a series RC-circuit we can use Laplace transform to analyse it in detail. Using Kirchoff law we can write:
$$\text{v}_\text{s}\left(t\right)=\text{v}_\text{R}\left(t\right)+\text{v}_\text{C}\left(t\right)\tag1$$
Using the relations of the voltage and current in a resitor and a capacitor we can rewrite equation $(1)$ as follows:
$$\text{v}_\text{s}'\left(t\right)=\text{i}_\text{R}'\left(t\right)\cdot\text{R}+\text{i}_\text{C}\left(t\right)\cdot\frac{1}{\text{C}}\tag2$$
Because it is a series circuit we know that the input current, $\text{i}_\text{in}\left(t\right)$, is the same as the current trough the resistor and the capacitor so we can write:
$$\text{v}_\text{s}'\left(t\right)=\text{i}_\text{in}'\left(t\right)\cdot\text{R}+\text{i}_\text{in}\left(t\right)\cdot\frac{1}{\text{C}}\tag3$$
Using the Laplace transform and assuming that the intial conditons are equal to $0$ we can write for equation $(3)$:
$$\text{s}\cdot\text{V}_\text{s}\left(\text{s}\right)=\text{s}\cdot\text{I}_\text{in}\left(\text{s}\right)\cdot\text{R}+\text{I}_\text{in}\left(\text{s}\right)\cdot\frac{1}{\text{C}}\space\Longleftrightarrow\space\text{I}_\text{in}\left(\text{s}\right)=\frac{\text{s}\cdot\text{V}_\text{s}\left(\text{s}\right)}{\text{s}\cdot\text{R}+\frac{1}{\text{C}}}\tag4$$
Assuming that the input voltage is a constant stabel DC-voltage ($\hat{\text{u}}$) gives for the supply voltage in the s-domain we get:
$$\text{V}_\text{s}\left(\text{s}\right)=\frac{\hat{\text{u}}}{\text{s}}\tag5$$
So, for the input current we get:
$$\text{I}_\text{in}\left(\text{s}\right)=\frac{\text{s}}{\text{s}\cdot\text{R}+\frac{1}{\text{C}}}\cdot\frac{\hat{\text{u}}}{\text{s}}=\frac{\hat{\text{u}}}{\text{s}\cdot\text{R}+\frac{1}{\text{C}}}\tag6$$
So, the voltage across the capacitor is given by:
$$\text{V}_\text{c}\left(\text{s}\right)=\frac{1}{\text{s}\cdot\text{C}}\cdot\frac{\hat{\text{u}}}{\text{s}\cdot\text{R}+\frac{1}{\text{C}}}\tag7$$
And for the voltage across the resistor we get:
$$\text{V}_\text{R}\left(\text{s}\right)=\text{R}\cdot\frac{\hat{\text{u}}}{\text{s}\cdot\text{R}+\frac{1}{\text{C}}}\tag8$$

So, for the energy we get:

*

*$$\text{e}_\text{C}\left(t\right)=\int_0^t\hat{\text{u}}\cdot\left(1-\exp\left(-\frac{\tau}{\text{RC}}\right)\right)\cdot\hat{\text{u}}\cdot\exp\left(-\frac{\tau}{\text{RC}}\right)\space\text{d}\tau=$$
$$\frac{\hat{\text{u}}^2\cdot\text{R}\cdot\text{C}}{2}\cdot\exp\left(-\frac{2t}{\text{RC}}\right)\cdot\left(\exp\left(\frac{t}{\text{RC}}\right)-1\right)\tag9$$

*$$\text{e}_\text{R}\left(t\right)=\int_0^t\text{R}\cdot\text{i}_\text{in}^2\left(\tau\right)\space\text{d}\tau=\text{R}\cdot\int_0^t\left(\hat{\text{u}}\cdot\exp\left(-\frac{\tau}{\text{RC}}\right)\right)^2\space\text{d}\tau=$$
$$\frac{\hat{\text{u}}^2\cdot\text{R}^2\cdot\text{C}}{2}\cdot\left(1-\exp\left(-\frac{2t}{\text{RC}}\right)\right)\tag{10}$$

And, as an example, let's say $\hat{\text{u}}=\text{R}=\text{C}=1$, than we can plot the solution:

Where the blue curve the energy in the capacitor is and the yellow curve is the energy in the resistor.
