The question is:
A capacitor of capacitance C1 is connected to a battery of potential V0. The battery is then disconnected and a second capacitor of capacitance C2 is connected to the first capacitor. The new potential of the capacitors is V. Express C2 in terms of C1, V0 and V.
I made two approaches.
At first I used charge conservation. If q is the charge of the first capacitor, then after the second capacitor is connected, q will be distributed among them. If q1 and q2 are charges of capacitor 1 and 2, respectively, then $q = q_1 + q_2$. Using this, I got $$C_2 = C_1*\frac{V_0-V}{V}$$
My second approach was using energy conservation. Before capacitor 2 was introduced, the energy saved in capacitor 1 was $E = \frac{1}{2}C_1V_0^2 $. Afterwards, the energy saved in each capacitor is given by, $E_1 = \frac{1}{2}C_1V^2$ and $E_2 = \frac{1}{2}C_2V^2$. If I assume $E = E_1 + E_2$, I get $$C_2 = C_1*\frac{V_0^2-V^2}{V^2}$$
Why am I getting two different expressions? The energy I began with doesn't seem to be the energy I ended up with. Why is that?