Let's say you have a hydraulic lever. On the end with the smaller area, you want to slowly pour sand, so as to compress a spring on the other end, which has the bigger area. If you want to find how much mass of sand is needed to compress this spring a certain distance, would you use Hooke's law or W=kx^2/2 ? My reasoning is that you would say kx^2/2=mgy, where y is the vertical displacement of the smaller piston, so mgy is the work done by the sand, and since "the work done on the input piston by the applied force is equal to the work done by the output piston in lifting the load placed on it" (according to my book), then mgy must equal kx^2/2. Is this right?