If the natural position of the spring is taken as the reference position, the elastic potential energy of the spring at its natural position will be zero. Thus, potential energy stored in the spring on compressing it by a distance x is equal to the elastic potential energy of the spring,i.e.,
\(\begin{array}{c}P{E_{{\rm{el}}}} = \frac{1}{2}k{x^2}\\45.0\;{\rm{J}} = \frac{1}{2}\left( {88.0\;{\rm{N/m}}} \right){x^2}\\{x^2} = \frac{{2 \times 45.0\;{\rm{J}}}}{{88.0\;{\rm{N/m}}}}\\{x^2} = 1.023\;{{\rm{m}}^2}\\x = 1.01\;{\rm{m}}\end{array}\)
Thus, the spring is compressed by a distance of 1.01 m.