To develop the problem it is necessary to apply the concepts related to Hooke's Law. For which it is understood that
[tex]F = kx[/tex]
Where,
k = Spring constant
x = Displacement of Spring
By the theorem of work we understand that it is the force realized when there is the path of an object therefore
[tex]dW =Fdx[/tex]
Our value of F is
[tex]dW = (kx)dx[/tex]
Integrating
[tex]W = k\int\limit_0^{x_1} xdx[/tex]
Therefore the expresion is
[tex]W = \frac{kx_1^2}{2}[/tex]