Understanding Slingshot Effect using MATLAB 

 August 5, 2022

By  Shubham


Interplanetary space probes often use the "gravitational slingshot" effect to propel them to high velocities. It is also known by its other names, such as slingshot effect, a gravity assist manoeuvre, or swing-by. But what is this effect, and why do we use it? What is the physics behind this effect? Let's seek an answer to these questions in this blog.

What is the slingshot effect?

Slingshot effect or gravity assist is the use of the relative movement and gravity of a planet or other astronomical object to alter the path and speed of a spacecraft. This effect is usually performed to save fuel and reduce expenses. The slingshot effect is also used to either accelerate or deaccelerate a spaceship, that is, to increase or decrease its speed and change the direction in which it is headed.

How does the slingshot effect work?

Imagine a spacecraft which is travelling towards a planet which is also moving in its orbit. As it approaches the planet, it is caught in its gravitational field. In this gravitational field, two things happen in different instances. First, there is an increase/decrease in the spacecraft's speed. This change in velocity depends on whether the spacecraft is approaching or leaving the planet. The second thing that happens is the change in the spacecraft's direction. The planet's gravitational field makes it swing around, so its trajectory changes.

 When the spacecraft approaches from the planet's orbital velocity direction, there is an increase in speed. Similarly, speed decreases when the spacecraft moves away from the planet's orbital velocity direction. In both types of manoeuvres, the speed gained from approaching and lost from leaving is nearly identical. Also, the energy transfer compared to the planet's total orbital energy is negligible. The sum of the kinetic energies of both bodies remains constant. By controlling the approach, the outcome of the manoeuvre can be manipulated, and the spacecraft can acquire some of the planet's velocity relative to the Sun.
Slingshot effect

Slingshot Effect for a satellite

This slingshot manoeuvre can be analysed as an elastic mechanical interaction in which both momentum and kinetic energy remain constant. Hence, the spacecraft will gain speed relative to the Sun and acquire kinetic energy due to this interaction. On the other hand, the planet will be slowed marginally due to losing an equivalent amount of kinetic energy. However, this slowing down of the planet will be almost negligible.

Derivation of slingshot effect:

Consider two bodies having mass m_1 and m_2 having initial velocities u_1 and u_2 and final velocities v_1 and v_2. We know that the momentum before and after collision is conserved. Therefore,


The kinetic energy will also be conserved and is expressed by,


On solving these equations for v_1 and v_2, we get,



In the case of a spacecraft flying past a planet, the mass of the spacecraft (m_1) is negligible compared with that of a planet (m_2) (m_1<<m_2), so this reduces to:

v_1\approx -u_1+2u_2

v_2\approx u_2

The last equation tells us that the spacecraft reverses direction, increasing speed while the planet's velocity is unchanged. This is why the slingshot effect increases its speed and kinetic energy when passing a moving planet.

Modelling slingshot effect in MATLAB

We will start with some initialisation conditions to set the initial velocity and displacement in the x-y plane. We will also establish a simulation time step and step size. We will use these things and calculate the direction and speed almost every time. One more thing we have to initialise is the planet's displacement and velocity, which will be approached by our spacecraft. We will use the equations for kinetic energy and velocity derived in the above section. We have to loop through the equation to get a result for each instance of time so that these results can be plotted on the graph and a comparative study can be performed. In our model, we will try to plot the relationship between the spacecraft's speed and the separation distance between the spacecraft and the planet. We will also plot the relationship between the spacecraft's energy and the planet. However, for a specific result, the other things can be ignored. For example, suppose you want to check the relationship between the energy of the two bodies. The plot for speed and separation distance can be ignored in that case.

% Author: Shubham Kumar, Gunjan Gupta, MATLAB Helper
% Topic:
% Website: https://matlabhelper.com
% Date: 28-06-2022
% Version: R2021b

close all

Get Access to
Code & Report!

Slingshot effect or Gravity Assist is a spacecraft manoeuvre used extensively to gain speed and change trajectory in space without needing fuel. You can implement this quickly in MATLAB with our code; Developed in MATLAB R2021b.

Now that we have the code for the slingshot effect, we will run and analyse our result.

Analysing the result

On running the code, we get the following result:

Slingshot Effect code output

1. Speed of spacecraft and separation distance, 2. Relationship between kinetic energy of both spacecraft and planet

Let's interpret this result. The first graph shows the relation between the speed of the spacecraft and separation distance. As evident from the graph, we can see that with time, the separation between the spacecraft and the planet decreases and the speed of the spacecraft increases. This happens due to the gravitational pull of the planet.

The second graph shows the relation between the spacecraft's energy and the planet. The red line provides the spacecraft's kinetic energy, while the blue line provides the planet's energy. Considering the setup as a single mechanical model, we can see that the planet is losing kinetic energy and that the spacecraft gains an equivalent amount of kinetic energy. However, the sum of the kinetic energies of both bodies remains constant. The black line shows the constant energy in this system.

Application of slingshot effect:

Rocket engines can be used to increase and decrease the speed of the spacecraft. However, rocket thrust takes propellant, propellant has mass, and even a small change in velocity translates to a far larger requirement for the fuel needed to escape Earth's gravity well.

Because additional fuel is needed to lift fuel into space, space missions are designed with a tight propellant "budget". Therefore, speed and direction change methods that do not require fuel to be burned are advantageous because they allow extra manoeuvring capability and course enhancement without spending fuel from the limited amount carried into space. Gravity assist manoeuvres can significantly change the speed of a spacecraft without expending fuel. They can save significant amounts of propellant, so they are a prevalent technique to save fuel.

Some notable missions using the slingshot effect

Luna 3

The gravity assist manoeuvre was first used in 1959 when Luna 3 photographed the far side of Earth's Moon.

Voyager 1

 Voyager 1 is a space probe that NASA launched on September 5, 1977. Part of the Voyager program to study the outer Solar System, Voyager 1 was launched 16 days after its twin, Voyager 2. It gained the energy to escape the Sun's gravity completely by performing slingshot manoeuvres around Jupiter and Saturn.
Voyager 1 path

Path of Voyager 1

Voyager 2

Voyager 2 is a space probe launched by NASA on August 20, 1977, to study the outer planets. A part of the Voyager program, it was launched 16 days before its twin, Voyager 1, on a trajectory that took longer to reach Jupiter and Saturn but enabled further encounters with Uranus and Neptune. It remains the only spacecraft to have visited either of these two ice giant planets, much less both.

Voyager 1 and 2 path

Path of Voyager 1 and Voyager 2

Did you find some helpful content from our video or article and now looking for its code, model, or application? You can purchase the specific Title, if available, and instantly get the download link.

Thank you for reading this blog. Do share this blog if you found it helpful. If you have any queries, post them in the comments or contact us by emailing your questions to [email protected]. Follow us on LinkedIn Facebook, and Subscribe to our YouTube Channel. If you find any bug or error on this or any other page on our website, please inform us & we will correct it.

If you are looking for free help, you can post your comment below & wait for any community member to respond, which is not guaranteed. You can book Expert Help, a paid service, and get assistance in your requirement. If your timeline allows, we recommend you book the Research Assistance plan. If you want to get trained in MATLAB or Simulink, you may join one of our training modules. 

If you are ready for the paid service, share your requirement with necessary attachments & inform us about any Service preference along with the timeline. Once evaluated, we will revert to you with more details and the next suggested step.

Education is our future. MATLAB is our feature. Happy MATLABing!

About the author 


I have done my bachelor degree in electronics from University of Delhi. I like to tinker with the hardware to understand how it actually works.

{"email":"Email address invalid","url":"Website address invalid","required":"Required field missing"}

Connect with MATLAB Helper ®

Follow: YouTube Channel, LinkedIn Company, Facebook Page, Instagram Page

Join Community of MATLAB Enthusiasts: Facebook Group, Telegram, LinkedIn Group

Use Website Chat or WhatsApp at +91-8104622179

Watch our Latest Video

Meet Industrial Experts & Ask your Questions

Industrial Interaction MATLAB Helper