Energy in electric field I'm having some trouble understanding a homework question and would appreciate some help.
The question is as follows:

Jenny charges a capacitor with the help of a battery. She then removes
  the battery and halves the distance between the two plates. How does
  the energy conserved in the capacitor change?

I solved the question like this:
$E=\frac{U}d$ and $U= \frac{W}Q$
$\implies W=EQd$
Hence, the energy doubles (as $E=\frac{U/d}2 \implies 2E=\frac{U}d$)
where: 
$W$ = energy, $E$ = Electric field intensity, $Q$ = charge, $U$ = voltage, $d$ = distance
This answer doesn't make any sense to me, considering the law of conservation of energy (So, Where did all that energy come from?)
It also turns out that my answer is wrong, in fact the energy is halved. This also doesn't make any sense to me, what am I missing?
 A: 1) There's a problem with your $U=W/Q$ (or, equivalently, $W=QU$) formula.  You can review Crazy Buddy's analysis, or do it yourself by imagining charging a capacitor from 0 to a final voltage U with a constant current I.  The instantaneous voltage u(t) grows linearly with time, so when you integrate the energy under the power curve $\left(U = \int {p(t) dt} =I \int{u(t)dt} \right)$ you're figuring the area of a triangle, and a factor of 1/2 emerges.  The correct formula is $W=(1/2) QU$.
2) The key to this problem is that the battery is disconnected before the plates are moved.  Once disconnected, the charge Q on the capacitor is fixed; hence the electric field E is also fixed (via Gauss' law), independent of the plate spacing. Since the voltage $U=Ed$, reducing the spacing reduces the voltage, and the energy.
[For grins, you might consider a different case in which the battery is not disconnected.  Then the voltage on the capacitor, not the charge, is fixed, and the result when the plate spacing is reduced is quite different.]
3) As pointed out by others, the field does work as the spacing is reduced.  
A: The energy stored by a capacitor with capacitance $C$ and charged to voltage $V$ is equal to $\frac{1}{2}CV^2$
For a parallel plate capacitor, the capacitance $C$ is equal to $\frac{\epsilon A}{d}$
So, when the distance between the plates is halved, the capacitance is doubled.
Also, for the same capacitor, we have that the voltage $V$ is equal to $\frac{Q}{C}$.
So, when the capacitance is doubled, the voltage is halved.
Denoting the initial capacitance and voltage by $C_0, V_0$, the final energy, after the distance is halved is given by:
$E = \dfrac{1}{2}(2C_0)(\frac{V_0}{2})^2 = \dfrac{1}{4}C_0V_0^2 = \dfrac{E_0}{2}$
So, halving the distance between the plates of a disconnected, charged capacitor reduces the stored energy by half.  Why?
There is a force between the plates acting to pull them together.  When you allow the plates to move closer, there is work done by the system, reducing the stored energy.
