X=r-p. Maybe I don't understand, but I am assuming that you need to isolate for X? you simply subtract p from both sides.<span />
I think the answer is repulsive.... Sorry if I get this wrong? :)
At First, there is chemical Energy( in your muscels) which is Used to Push down the spring. This Energy becomes the Energy of the spring, which increases until you stop pushing. If you Put your hand away, the Energy of the spring will become kinetic energ. This Energy is at the highest Level the Moment the book ist Leaving the spring. Afterwards, the kinetic Energy decreases while the Gravitational Potential Energy increases.