Compressed spring jump to what maximum height? The question is shared to me by my physics teacher, we have never solved it:
Imagine a spring standing vertically with one end pressed on the table, now you press down the spring from the upper end by x meter, then you remove your hand. Now if the compression is enough, the spring could raise its bottom off the table. It asks: what is the max height the top of the spring will reach.

There are point masses M1, M2 attached at bottom and top of the massless spring respectively. You are given that spring has natural length L, spring constant k, initially compressed by x meter, gravitational acceleration g.
I don't see a clear way to solve this, my best attempt was to produce a simulation as in the gif, but it didn't clear up much things. My best hope is a expression in terms of those parameters that expresses this max height.
Link to simulation: https://www.desmos.com/calculator/7mvofzasjn
Edit: I have seen people posting answers, but what they didn't realize is that the spring can be very stretched or compressed when the top of the spring is at its highest! This means there is EPE leftover in the spring. But how much? That would depend on how stretched it is then, which one probably would determine when one really solved the problem.
 A: This is an interesting problem, and it turns out that you can solve for it exactly using the technique of normal coordinates.  I'll try to give you the general outline of how it works in this case without violating this forum's "no complete answers" policy.
Let $x_1$ be the position of the lower mass and $x_2$ be the position of the upper mass.  The force on the lower mass is $F_1 = - m g - k (x_1 - x_2 - L)$;  the force on the upper mass is $F_2 = - m g + k (x_1 - x_2 - L)$.  So the two equations of motion for the masses are
\begin{align}
\ddot{x}_1 &= - g - \frac{k}{m} (x_1 - x_2 - L), \tag{1}\\
\ddot{x}_2 &= - g + \frac{k}{m} (x_1 - x_2 - L). \tag{2}
\end{align}
These two equations are coupled, which means that both quantities $x_1$ & $x_2$ appear in both equations and influence each other (which is what makes this a hard problem.)  But let's try defining two new coordinates to describe the system:  $X = (x_1 + x_2)/2$, which is the position of the center of mass of the system;  and $y = x_1 - x_2 - L$, which is the amount of extension of the spring.  You can hopefully see that if I tell you $X$ and $y$ at any given time, it describes the system just as well as if I told you $x_1$ and $x_2$;  in fact, we have
$$
x_1 = X + \frac{1}{2} (y + L) \qquad x_2 = X - \frac{1}{2} (y + L). \tag{3}
$$
And if you take the derivatives of $X$ and $y$, you can also see that
$$
\ddot{X} = \frac{1}{2} (\ddot{x}_1 + \ddot{x}_2) \qquad \ddot{y} = \ddot{x}_1 - \ddot{x}_2.
$$
Plugging in our values for the accelerations from (1) and (2) and simplifying, we get
$$
\ddot{X} = - g \qquad \ddot{y} = - \frac{2k}{m} y
$$
These two equations are decoupled, in that neither equation contains both $X$ and $y$.  What's more, the form of these equations should be familiar to you;  what this says is that $X$ (the position of the CM) just moves in parabolic motion, while $y$ oscillates in simple harmonic motion.  In particular, you can try to figure out what the solutions $X(t)$ and $y(t)$ are;  and then you can figure out what $x_1(t)$ and $x_2(t)$ are using the relations in Equation (3);  and then you can find the value of $t$ at which $x_2$ is maximized.
A: By observation and for maximum height, we can say that the extension/compression of the spring at the topmost point will be zero. By assuming that and using conservation of mechanical energy,
#At initial compressed position, the bottom is at ground level. But the top is at
(L-x) meters above the ground.
#At the topmost point, bottom is at height h and since there is no compression, top is at height h+L
So,
$$\frac{1}{2}kx^2+M_2g(L-x)=M_1gh+M_2g(h+L)$$
By rearranging the terms we get,
$$h_b=\frac{kx^2-2M_2gx}{2g(M_1+M_2)}$$
This is the height that the bottom of the spring reaches, so the top reaches a maximum height of
$$h_t=\frac{kx^2-2M_2gx}{2g(M_1+M_2)}+L$$
