A spring, a ramp, and a mass

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

Assume that all the energy initially stored in the spring is transferred to the block.

Should we do this using forces or using energy? It's tricky to analyze a spring problem using forces, because the spring force is not constant. Energy is much easier to deal with.

Use the master energy equation:

Ui + Ki + Wnc = Uf + Kf

The initial position is where the block starts. The final position is where the blocks stops (it may well start to slide back down, but we don't care about that).

There is no friction so Wnc = 0.

One thing to remember is that there are two kinds of potential energy here, gravitational potential energy Ug and spring (elastic) potential energy Us. Expanding the master energy equation a little gives:

Ugi + Usi + Ki = Ugf + Usf + Kf

Take the zero level for gravitational potential energy to be the block's starting point. The final position is where the blocks stops (it may well start to slide back down, but we don't care about that).

All sorts of things are zero. Ki and Kf are zero because the block starts and ends at rest.
Ugi = 0, and we're assuming Usf = 0. The energy equation becomes:

Usi = Ugf

½ kX2 = mgh

From geometry, h = dsin(θ)

½ kX2 = mgdsin(θ)

Solving for d gives:
d =
kX2
2mg sin(θ)

For a particular case where k = 50 N/m, X = 0.10 m, m = 0.080 kg, and θ = 30 degrees, d works out to:

d = 0.64 m