How do we come up with the gravity assist (or slingshot) formula?

When you search up in google gravity assist formula, it comes up with the simplest version:

Which means that: Final velocity = Initial velocity + 2 (velocity of the planet)

Then if we do some more research we get a formula that takes into account the angle of approach.

But how do we come up to this formulas? What is the reasoning behind it?

And is there any formula that takes into account the mass of both bodies and the distance between those (altitude)?

After trying for different values of v and U, this is what we usually get (a V shape). This graph shows the final velocities for different angles of approach.

• I added the history tag because the origin of the formula may be much older than spaceflight, it could probably be derived from simple kinematics. Can you add a link to the source where you've found this formula? It might help if you look for other sources as well. I think the distance of closest approach (altitude) can be calculated from the initial conditions; once you choose $u$, $v$ and $\theta$ I think the distance of closest approach is already predetermined. It would be nice to have a diagram that shows what $\theta$ represents in your formula. – uhoh Oct 7 '17 at 11:14
• @uhoh θ represents an angle between 0 and 360, simple as that. – Matthew Oct 7 '17 at 16:31
• It looks like $\theta$ is the angle between the velocity of the planet and the velocity of the spacecraft; $cos(\theta) = \mathbf{v_x}\centerdot \mathbf{v_y} / |v_x||v_y|$ really just varies between -1 and +1, so $0° \le \theta \le 180°$. The equation and the final velocity don't care if $\theta$ is 90° or 270° for example, you'd get the same answer. – uhoh Oct 7 '17 at 16:41
• It's not "different angles of approach". The angle $\theta$ as shown in the link is $\pi/2$ minus half of the total bend angle resulting from the swingby. The extreme case shown in the diagram is $\theta=0$ or a bend angle of $\pi$. – Mark Adler Oct 8 '17 at 4:22

You get that formula simply using the Pythagorean theorem, also known as vector addition. The link already provides $v_{2x}=v_1\cos\theta+2u$ and $v_{2y}=v_1\sin\theta$. Then you simply compute the magnitude $v_2=\sqrt{v_{2x}^2+v_{2y}^2}$.

Usually the body shown as a red disk in the diagram is much, much, much more massive than the thing following the black curved trajectory. In that case, the mass of the smaller object has no bearing on the trajectory.

As for the "altitude", the closest approach distance from the center of the body, along with the approach velocity and mass of the large body, determines $\theta$. See this answer for how to calculate it. ($\delta$ there is $\pi-2\theta$ here). It is of course important that the closest approach distance from the center of the body be greater than the radius of the body, lest you have a very violent and extremely short-lived swingby.

We need to have in mind the term relative velocity. Where Vi is Initial relative velocity and Vf is final relative velocity.

Vi = V1 + U

Vf = -V2 + U

Since Vi = -Vf then V1 + U = V2 - U ; after we do some simple algebra we get that V2 = V1 + 2U Where V2 is the final velocity of the space shuttle, V1 is the initial velocity and U is the orbital velocity of the planet that the space shuttle has approached to do a slingshot.