Energy lost in capacitors Where is the energy equal to ${1\over2}CV^2$ lost while charging a capacitor?  (When deriving it I assumed $V$ was constant and resistance of wire or internal resistance was negligible.)
 A: There are many ways of analysing the charging of a capacitor.  

While deriving it I assumed V=constant 

The energy stored in a capacitor is $\displaystyle \int ^{Q_{\rm final}}_0 V\,dQ =  \int ^{V_{\rm supply}}_0 CV\,dV= \frac  12 C V_{\rm supply}^2$ but you will note that it was the supply voltage, $V_{\rm supply}$, which was constant not the voltage across the capacitor, $V$, which varied from $0$ to $V_{\rm supply}$ during the charging process.   
When fully charged the capacitor has a charge of $Q_{\rm final} = CV_{\rm final}$ stored on it which means that the energy supplied by the power supply, whose voltage, $V_{\rm supply}$, is assumed to be constant during the charging process, is $CV^2_{\rm supply}$.  
So there is a "missing" amount of energy between the energy supplied by the power supply and the energy stored in the capacitor.
To account for this "missing" energy one has to extend the analysis a little further and assume that the charging circuit had resistance and that the "missing" energy was actually heat dissipated in the resistance $R$ of the circuit.
Once you have a resistor in the circuit the charging of the capacitor is analysed via the differential equation $IR + \frac QC = V_{\rm supply}$ which in this example has solutions of the form $V(t) = V_{\rm supply}\left ( 1- \exp\left( - \dfrac{t}{RC} \right)\right )$ and $I(t) = \dfrac{V_{\rm final}}{R} \exp\left( - \dfrac{t}{RC} \right)$ where $V(t)$ is the voltage across the capacitor  and $I(t) $ is the current flowing in the circuit at a time $t$.  
You can then use these equations to show that the energy supplied by the power supply is $\displaystyle \int V_{\rm supply} I(t)\, dt = CV_{\rm final}^2$; the energy stored in the capacitor is $\displaystyle \int V(t)\, I(t)\, dt = \frac 12 CV_{\rm final}^2$; and the energy dissipated in the resistor is $\displaystyle \int I(t)^2R \, dt = \frac 12 CV_{\rm final}^2$.  
It certainly is rather strange that the resistance of the circuit does not feature in the final energy equations but you could think of the situation in this way.
If the resistance is very small the current which flows in the circuit whilst the capacitor is being charged is very large and the time constant $RC$ is very small which means that the charging process is very short so in an integral of the form $\displaystyle \int V I \,dt$ the large values of $I$ are compensated for by the small value of the time scale over which the majority of the charging is done.  
If you now want to consider making the resistance in the circuit smaller and smaller then you have to include the inductance $L$ which the circuit has as the circuit is a loop consisting of a power supply, a capacitor and a resistor.
You perhaps can understand why this must be so when you look at the equation for the current in the $RC$ circuit, $I(t) = \dfrac{V_{\rm final}}{R} \exp\left( - \dfrac{t}{RC} \right)$ where the current at the moment the switch is closed (the power supply turned on) is $\dfrac{V_{\rm supply}}{R}$ implying that the current reaches that maximum value instantaneously which is not possible.
So now the differential equation which must be solved is $L \frac{dI}{dt} +IR + \frac QC = V_{\rm supply}$ noting that the first term was neglected before.
The solutions to such a differential equation depend on the magnitudes of $L, C$, and $R$ and there are three possibilities, the circuit is over-damped, critically damped and under-damped.
For very low values of the resistance the circuit is under-damped and the voltage across the capacitor oscillates about its final steady state value of $V_{\rm supply}$.
The mechanical analogue of such an effect is releasing a mass at the end of a spring and noting that the mass oscillates about its static equilibrium position before it finally reaches its static equilibrium position with energy dissipated from the system as heat due to there being air resistance.  
With the electrical system there is another contribution to the loss of energy from the system and that is the emission of electromagnetic waves from the circuit because there unbound accelerating electrons emit electromagnetic radiation.
So even if in theory the circuit had no resistance it would still lose energy by the emission of electromagnetic radiation and the final state would be that the energy stored in the capacitor would still be $\frac 12 cV^2_{\rm supply}$.
A: Assuming you are charging a capacitor with a battery of constant voltage $V$, if you consider some internal resistance in the wire, you will see that final energy in the capacitor is $\frac{1}{2} CV^2$, the total heat dissipated in the resistance is also $\frac{1}{2} CV^2$. Also, the net charge transferred to voltage $V$ is $CV$, so work done by battery is $ CV^2$.
So, energy is conserved. Now, even if you don't consider, the wire will have some resistance (ideal wire does not exist in nature, even superconductors have some very little resistance). Any non zero value of resistance will dissipate heat $\frac{1}{2} CV^2$, so, in the limit $R$ going to zero, the heat dissipated in the resistor remains same.
A: When you are charging up a capacitor, magnitude of charge on one its plate increases in time, and because the voltage between its two plates is proportional to this charge:
$$
V_C = Q/C.
$$
So this voltage will increase in time. So $V_C$ cannot be constant during the charging.
In practice capacitors are charged via wires connected to a source of voltage. The source of voltage may have constant voltage $\Delta V$ right at its terminals, but due to resistance of the wires, this voltage will not transfer exactly on the capacitor terminals, but part of it will be lost along the wires.
Let the wires obey Ohm's law: then the voltage loss on the wires $\Delta V_w = RI$ where $R$ is sum of resistances of all the wires in the circuit and $I$ is current flowing in the circuit.
Then Kirchhoff's law of voltages says (all quantities are meant as positive numbers here)
$$
\Delta V = RI + Q/C.
$$
This is a differential equation for charge as a function of time and its solution states that both charge $Q$ and voltage of the capacitor $Q/C$ increase in time asymptotically to their maximum values.
