# Energy stored in an object in spring

Suppose we have a vertical spring of spring constant $$k$$ and an object of mass $$m$$ is tied to it. If we stretch the object by a distance $$x$$,the work done by the restoring force is $$\frac{kx^2}{2}$$ and this work will be stored in the object as energy. If we try to find out what is the energy stored in the object now,why do we say it's $$\frac{kx^2}{2}$$ and not $$\frac{kx^2}{2}+mgh$$ since the body has also a potential energy? Addenum: We can see that the spring has done negative work on the body since the work done by spring is $$\int \vec{F}.d\vec{x}=\int -kx dx$$. Now doesn't negative work mean energy has been taken away from the body? Then how can it be stored in the body?

• Re, "this work will be stored in the object..." Actually, no. You said, "we stretch the object." If you mean that we pull or push the system away from its rest configuration, then we're ultimately doing work on the bonds between the atoms that comprise the spring, and that's where the energy is stored—in those bonds. May 18 at 20:46

Both $$mgh$$ and $$\frac{1}{2}kx^2$$ are potential energies, so the total energy "stored" in the object is the sum of those two terms, assuming no other force in applied and the objet is at rest.