A point mass $m$ having charge $q$ is connected with massless spring to a rigid wall on a horizontal surface.A horizontal uniform electric field $E$ is switched on and mass is displaced through a distance $x$ from equilibrium position.
Work done by electric force is $W=qE.x$ as electric force is constant.
But $F(external)$ on spring mas system is equal to $kx$. So $W=kx.x= kx^2$(equation 1) as external force i.e, electric force is constant.
We know that work done is stored in the form of potential energy and we know that potential energy stored in the spring is$ 1/2 kx^2$.
So $W = 1/2 kx^2$ (let it be equation 2)
But the above 2 equations are not equal. From where did the 1/2 come from in the 2nd equation???