How was the equation for a gravitational assist derived?

Im currently writing a paper about a hypothetical probe meant to escape our solar system and I want to analyse how gravitational assists would be beneficial for its mission. I found a website with an equation for a perfect gravitational assist which resulted in the final velocity being the initial velocity plus 2 times the planets orbital velocity $$v2 = v1 + 2u.$$ The website said it was derived using the conservation of kinetic energy and momentum, however no matter what I do I cannot figure how they ended up with this equation. I was wondering if anyone could help me.

For more context, here is the website in question: https://www.mathpages.com/home/kmath114/kmath114.htm

Consider what happens to a light object such as a ball when it bounces off a heavy object such as a moving car. We suppose the collision between ball and car is elastic (so no loss of kinetic energy). Let the speed of the car relative to the street be $$V$$ and the initial speed of the ball relative to the street be $$u$$. Then if the ball is thrown directly towards the oncoming car, then the initial speed of the ball relative to the car is $$u+V$$. Now imagine you are sitting in the car. Perhaps you are the driver. Anyway there is a small ball approaching you and the car at this speed $$u+V$$ in your rest frame. The car itself is not moving in its own rest frame. What happens next is simply that the ball bounces off the car and then moves away from it at the same speed with which it approached, i.e. $$u+V$$ in the rest frame of the car. It is just like an elastic collision with a wall.
Now examine the final motion of this ball, but relative to the street. Its speed relative to the street must be this $$u+V$$ which is has relative to the car, plus the speed $$V$$ of the car relative to the street. So the final speed of the ball is $$v = u + 2 V .$$ Thus the ball has received a 'collision assist' from the car, and has its speed increased by $$2V$$---twice the speed of the car---relative to the street.