$3.1.2.$ A weight of mass $m$ is suspended on a spring of stiffness $k$. How does the total force acting on the load depend on its displacement $x$ from the equilibrium position? Find the dependence of the potential energy of the load on its displacement $x$.
The only external force other than the elastic force of the spring $$ \boxed{F=-kx} $$ Let's find the change in energy when the spring moves by $dx$ $$ dU=Fdx=kxdx $$ After integrating $dU$ from $0$ to $U$ $$ U=\int_{0}^{U}dU=k\int_{0}^{x}xdx=\fbox{$\frac{kx^2}{2}$} $$
$$F=-kx;~U=\frac{kx^2}{2}$$