# Confused about relating spring force to maximum distance

I keep working through this problem and getting the wrong answer:

A spring with spring constant k is positioned vertically and then compressed from its equilibrium length by a distance Δy. A ball of mass m is placed on top of the spring, and is launched into the air when the spring is released. The ball travels to a maximum height hmax. Using the Work-Kinetic Energy theorem, determine hmax in terms of the given variables and any other constants you deem necessary.

The thought process was ∆K = $K_f - K_i$ = W --> $\frac{mv^2}{2}-\frac{mv_0^2}{2}$ = W

$W$ = $W_s - W_g$ where $W_s$ is a spring and $w_g$ is gravity

The final velocity is also zero so $K_f$ = 0. Which gives us

$\frac{mv_0^2}{2} = -k∆y^2 - mgh_m$ (solve for $h_m$)

$h_m = \frac{-k∆y^2}{2mg}+\frac{v_0^2}{2g}$

I might be completely off but I can't figure out what else to do. I would be very grateful is someone walked me through it

-
How are you defining your symbols? In particular what is $v_0$? –  NowIGetToLearnWhatAHeadIs Feb 11 at 2:20
initial velocity –  sreya Feb 11 at 2:20
And how do you know you have the wrong answer? –  NowIGetToLearnWhatAHeadIs Feb 11 at 2:22
Because the homework is automated. It tells me my answer is incorrect –  sreya Feb 11 at 2:23
Are you given the value for $v_0$? If so try plugging the value in to simplify the expression and see if that works. –  NowIGetToLearnWhatAHeadIs Feb 11 at 2:24

There are two forces acting on the object: gravity and the spring force. The spring force acts in the direction of motion, so that it speeds up the object and does work. The amount of work that it does is $W_s = \frac{1}{2} k (\Delta y)^2$. On the other hand gravity acts in the direction opposite to velocity, and so it contributes a negative work. The work due to gravity is $W_g=-mg(h_{max} + \Delta y)$.
For the total work to be zero we must have $W_s = -W_g$ or $\frac{1}{2} k (\Delta y)^2 = mg(h_{max} + \Delta y)$. Solving for $h_{max}$, we find $h_{max} = \frac{k}{2mg} (\Delta y)^2 - \Delta y = \Delta y (\frac{k \Delta y}{2 m g} -1)$.