A block of mass m is held at rest on a frictionless incline. The block compresses a spring by a length X from equilibrium. The spring constant is k. When the block is released, it travels a distance d up the slope. What is d?

Let's analyze this problem by D0EL.

Step 1: Define/draw diagram and coordinate system.

Step 2: Choose a consistent zero.

Step 3: Energy conservation

Step 4: Losses.

Step 2: The
* gravitational* potential energy zero
is the block's starting point.

Step 3:
U_{i} + K_{i} = U_{f} + K_{f}.

Because there is both gravitational U_{g} and spring potential
energy U_{s}, energy conservation becomes:
U_{gi} + U_{si} + K_{i} = U_{gf} + U_{sf} + K_{f}

K_{i} =0 and K_{f} = 0 because the block starts and ends
at rest.

U_{gi} = 0 and U_{sf} = 0 by construction.

Energy conservation becomes: U_{si} = U_{gf}
→ ½ kX^{2} = mgh

Using h = dsin θ, we solve for d and obtain:
d = kX^{2}/(2mg sin θ).