Answer
$W=k \int_{a}^{b} x \ dx=\dfrac{1}{2} k (b^2-a^2)$
Therefore, the negative work can be possible when $|b| \lt |a| $ and then the spring returns to its equilibrium state.
Work Step by Step
The work required to compress the spring beyond equilibrium can be calculated as:
$\text{Work}, W= \int_{a}^{b} kx \ dx $; where $k$ is the spring constant.
$W=k \int_{a}^{b} x \ dx \\=\dfrac{k}{2}[x]_a^b \\=k[\dfrac{b^2}{2}-\dfrac{a^2}{2}]\\=\dfrac{1}{2} k (b^2-a^2)$
Therefore, the negative work can be possible when $|b| \lt |a| $ and then the spring returns to its equilibrium state.