Mass falling onto a spring from an inclined plane

I was studying for my AP Physics test when I came across the following problem, which seemed to confuse me: The ramp is frictionless, and the spring is initially at it's relaxed length, and the angle is $\theta = 45^{\circ}$.

I worked through this by considering the potential energy lost as the kinetic energy gained just before the mass hits the spring, with the equation

$mgh = \frac{1}{2}mv^2$,

and plugging in the known values, getting:

$40\cdot9.8\cdot\frac{2}{\sqrt{2}} = \frac{1}{2} \cdot 40 \cdot v^2$,

to solve for $v$, which gives $v = 5.25 \frac{m}{s}$. However, I am unsure whether this is the correct answer, as I am unsure when the maximum speed occurs. If it exists after the compression of the spring, how do I go about calculating it?

Thank you.

• As the spring provides a decelerating force once the block hits it, the speed is indeed maximum just prior to hitting the spring.
– Gert
Nov 18 '16 at 5:38
• Due to gravity, the block m is accelerating downward until the moment it hits the spring. When it hits the spring, a spring force which will act to decelerate the block will start to develop. However, since the spring force is proportional to the amount that the spring has been compressed and since the spring is initially uncompressed, the spring force acting on the block will be very small initially. That means that the block will continue to accelerate downward after initial contact and therefore its maximum speed will occur after contact with the spring.
– user93237
Nov 18 '16 at 5:39
• @Samuel Weir Will this occur at the point of equilibrium, when kx = mgsin theta? Nov 18 '16 at 5:43
• @ShreyasB. - At the instant that the block is at its maximum speed, its instantaneous acceleration should be zero, which means that the instantaneous net force on it (along its direction of sliding movement) at that moment should be zero. I think that you've got the right idea with your equation.
– user93237
Nov 18 '16 at 5:46

So make the component of weight down the slope equal in magnitude to the magnitude of the force up the slope due to the spring being compressed an amount $x_o$.
At this point the box has moved $d+x_o$ along the slope and so you can now use energy conservation to find the maximum speed of the box.