Capacitor-spring analogy Imagine the two terminal of a parallel-plate capacitor are connected to the two terminal of a battery with electric potential difference $V$. The capacitance of the capacitor is $C$, the area of each plate is $A$ and distance between the plates is $d$. After getting charged, the capacitor is detached from the battery and then the distance between the plate $d$ is made twice the original i. e. $d'=2d$. Clearly, after getting separated twice the distance, the energy of the capacitor $U$ will increase since $U'=\frac{1}{2} \cdot \frac{Q^2}{C} =\frac{1}{2} \cdot \frac{Q^2}{\frac{\epsilon A}{d'}} = \frac{1}{2} \cdot \frac{Q^2}{\frac{\epsilon A}{2d}} = 2 \cdot \frac{1}{2} \cdot \frac{Q^2}{\frac{\epsilon A}{d}} = 2 U $ . But how can we describe the increases in energy of the capacitor by making an analogy of increasing in potential energy of a spring when stretched?
We know that the potential energy of a spring is $E_s = \frac{1}{2} k x^2$ where $k$ is the spring constant. The Wikipedia page claims that $k$ is analogous to $\frac{1}{C}$ when $U=\frac{1}{2} \cdot \frac{1}{C}Q^2$ but $k$ is a constant while capacitance $C$ changes. This doesn't seem right as $C$ isn't constant. Then how can we make the analogy with the spring while the stored energy is increasing in the capacitor?
Any help is appreciated.
 A: 
Clearly, after getting separated twice the distance, the energy of the
capacitor $U$ will increase

Yes, and the basic reason is work has to be done by an external agent to separate the plates against the attractive force between the plates. That work is energy transferred to the electric field of the capacitor and is responsible for doubling the stored energy.

But how can we describe the increases in energy of the capacitor by
making an analogy of increasing in potential energy of a spring when
stretched?

Since
$$C=\frac{\epsilon A}{d}$$
Doubling the separation (with the same $A$ and $\epsilon$) means halving the capacitance. Then, from
$$C=\frac{Q}{V}$$
For conservation of charge, halving the capacitance means doubling the voltage. Then the energy storied in the capacitor, in terms of the original capacitance, is then
$$U=\frac{1}{2}(C/2)(2V)^{2}=CV^2$$
Or double the original.
Since from the spring-capacitor analogy,
$$C=\frac{1}{k}$$
Halving the capacitance is analogous to doubling the spring constant, i.e., analogous to doubling its "stiffness". Doubling the spring constant, for the same displacement means doubling the force. So force in a spring is analogous to the voltage for a capacitor.
Now, to make your example that of a spring instead of a capacitor  you would have had a spring having spring constant $k$ stretched an amount $x$ by some external force and held. The elastic potential energy stored in the spring is then
$$U=\frac{1}{2}kx^2$$
And the force necessary to maintain the stretched spring is
$$F=kx$$
Now, somehow (miraculously) the spring constant doubled (the spring became twice as stiff). In order to keep the spring stretched by $x$ it would be necessary to double the externally applied force. So the original force has to double. In terms of the original value of $k$, for the same value of $x$ the force is now,
$$F=2kx$$
The energy now stored in the spring becomes
$$U=\int_{0}^{x}(2kx)dx=2\int (kx)=kx^2$$
So the energy stored in the spring would be double the original, just like in the case of the capacitor, when $C=1/k$.
Note that the new stored energy for the capacitor and the spring given above are in terms of the original values of $C$ and $k$.
Moreover, in addition to the analogy between the capacitance and spring constant, there is also the analogy between force, in the case of the spring, and voltage in the case of the capacitor. The doubling of the voltage for the case of the capacitor is analogous to doubling the force in the case of the spring.
Hope this helps.
A: The analogy is $x \to Q$ and $k \to 1/C$
So the stretching of a spring corresponds to charging up of a capacitor and vice versa.
Now if you increase the distance capacitors’ plates, then you’re changing your system. In the spring analogy, you are replacing it with a different spring (with a different $k$).
A: The Wikipedia analogy
The analogy quoted in the Wikipedia article does not exactly correspond to the situation you describe. It corresponds to the situation of charging up a capacitor. To separate an amount of charge $\text{d}Q$, you need to perform an amount of work $\text{d}U = V\text{d}Q$. Applying the definition $Q=CV$ we get the integral
$$U=\int_0^Q \text{d}U = \frac{1}{C} \int_0^Q Q\text{d}Q = \frac{1}{2}\frac{Q^2}{C}$$
Similarly, to extend the spring by a length $\text{d}x$, you need to exert a force $kx$ to exactly oppose the spring's own force $-kx$. The work $\text{d}U$ you do is therefore $\text{d}U = kx \text{d}x$ and the energy is
$$U=\int_0^x \text{d}U = k\int_0^x x\text{d}x = \frac{1}{2}kx^2$$
Therefore, we see that in both situations, the work needed to increase the displacements $Q$ and $x$ by infinitesimal amounts $\text{d}Q$ and $\text{d}x$ is proportional to the current values of $Q$ and $x$ themselves. The $1/C$ in the capacitor plays the role of $k$ in the spring.
Your situation
The situation you describe is different from the Wikipedia analogy as it involves increasing the separation $s$ of the capacitor plates rather than charging up the capacitor. The relationship between $\text{d}U$ and $\text{d}s$ is, in general, non-linear in $s$ and cannot be modeled as a simple spring.

*

*If $s$ is much larger than the typical size of a plate, then both plates are essentially point charges, so the work is
$$\text{d}U \approx \frac{Q^2}{4\pi\epsilon_0 s^2} \text{d}s$$
and $U \propto s^{-1}$.


*If $s$ is much smaller than the typical size of a plate, then $C\approx\epsilon_0 A/s$ and
$$U = \frac{1}{2}\frac{Q^2}{C} \approx \frac{Q^2}{2\epsilon_0 A}s$$
so $U \propto s$.
We therefore see that the system still behaves like a spring. The attractive electric force between the oppositely-charged capacitor plates acts as the spring force. It's just that this force does not obey the equation (Hooke's law) of an ideal spring which is $U\propto s^2$. In any case, the potential energy can still be found by integrating the force with respect to distance (although we found it by direct means in the second approximation, where $s$ is much smaller than the typical size of a plate).
A: 
After getting charged, the capacitor is detached from the battery and then the distance...

If we assume a capacitor only circuit without external EMF, then in that system what remains constant is the charge $Q$ on the capacitor plates. It will not change as you increase or decrease  the distance between the plates. So, the analogous entity should be $k$ and $Q$ since both in spring system and capacitor system, these remain constant throughout.
Now, by the equations, it is quite noticeable that in a spring $E_s$ increases quadratically with $x$(elongation). But in a capacitor, $E_c$ increases linearly with $x$(separation between plates).
So a real analogy(like we make between Gravitation and Electrostatics) cannot be drawn between the equations since they are not increasing/decreasing by the same amount as we increase/decrease $x$.
Nevertheless, we can always say that Energy will always increase both in spring and capacitor as we increase $x$ and vice versa
We can consider the equations
$$E_s = \frac{1}{2}(k)(x^2)$$
$$E_c = \frac{1}{2}(Q)(\frac{Q}{C})$$
In these equations
$k$ is analogous to $Q$ (Both constant)
$x^2$ is analogous to $\frac{Q}{C}$ (Both increases with $x$)
Also note that $\frac{Q}{C}$ is actually $V$ and rightly so, $V$ also increases linearly as we increase $x$(separation between plates)
