I was trying to solve the head on collision slingshot problem where the rocket moving with speed $v_1$ approaches a planet which is moving with speed $U_1$. I wanted the final speed of the rocket ($v_2$). $U_2$ is the final speed of the planet. Mass of planet is $M$. Mass of rocket is $m$. So I made two equations-
$$ M(U_1)^2 + m(v_1)^2 = M(U_2)^2 + m(v_2)^2 $$ $$ M(U_1) - m(v_1) = M(U_2) - m(v_2) $$
However, I am unable to eliminate $U_2$ to get ($v_2 = 2U_1 + v_1$) as the answer by also taking $\frac{m}{M} = 0$
Note :- This is a head on u-turn slingshot.