August 5

Understanding Slingshot Effect using MATLAB


Watch YouTube #shorts linked to this Blog:


Interplanetary space exploration has always been a fascinating field, and one of the key technologies used in it is the "gravitational slingshot" effect, also known as slingshot effect, gravity assist manoeuvre, or swing-by. This effect uses the relative movement and gravity of a planet or other celestial body to alter the path and speed of a spacecraft, thus saving fuel and reducing expenses. But what is the physics behind this effect, and how can we use it to our advantage? In this blog post, we will use MATLAB to understand the Slingshot Effect and its applications in space travel. From mathematical models to simulations, we will delve into the intricacies of this fascinating phenomenon and its potential for future space missions.

What is the slingshot effect?

The slingshot effect, also known as gravity assist, is a maneuver used by interplanetary space probes to gain velocity and change their trajectory. It is achieved by a spacecraft approaching a planet or other celestial body and using its gravity to alter the spacecraft's velocity. This effect can be used to either accelerate or decelerate a spaceship, that is, to increase or decrease its speed and change the direction in which it is headed. It is a powerful tool in space exploration as it allows spacecraft to travel greater distances with less fuel, making it a more cost-effective and efficient method of space travel.

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

Unlock the potential of MATLAB programming with our free online course on MATLAB Fundamentals! Get started now and become a master in manipulating numbers with ease. Prove your expertise by participating in our MATLAB Fundamentals Course Certification Quiz and score 60% or more to book a certificate from MATLAB Helper. Get ready to conquer the world of MATLAB coding!

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: Slingshot Effect
% Website:
% 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

Get instant access to the code, model, or application of the video or article you found helpful! Simply purchase the specific title, if available, and receive the download link right away! #MATLABHelper #CodeMadeEasy

Ready to take your MATLAB skills to the next level? Look no further! At MATLAB Helper, we've got you covered. From free community support to expert help and training, we've got all the resources you need to become a pro in no time. If you have any questions or queries, don't hesitate to reach out to us. Simply post a comment below or send us an email at [email protected].

And don't forget to connect with us on LinkedIn, Facebook, and Subscribe to our YouTube Channel! We're always sharing helpful tips and updates, so you can stay up-to-date on everything related to MATLAB. Plus, if you spot any bugs or errors on our website, just let us know and we'll make sure to fix it ASAP.

Ready to get started? Book your expert help with Research Assistance plan today and get personalized assistance tailored to your needs. Or, if you're looking for more comprehensive training, join one of our training modules and get hands-on experience with the latest techniques and technologies. The choice is yours – start learning and growing with MATLAB Helper today!

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


gravity assist, slingshot effect, slingshot effect in matlab, slingshot effect in space, swing by, swing-by effect

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.

You may also like

Runge-Kutta method in MATLAB

Runge-Kutta method in MATLAB
  • Satyam Singh says:

    Slingshot effect also known as gravitational slingshot or swing by is the use of ralational movement and gravity of of the astronomical object to alter the path and speed of the aircraft.When a spacecraft travelling towords the planet then due to gravitational field it moves around that planet and its velocity varies.
    Slingshot Manoeure is elastic mechanical interaction in which both Momentum and Kinetic Energy remains constant. Spacecraft gain some Kinetic Energy due to this interaction and planet slows down and lose equivalent amout of energy.
    In this we will initialise mass and velocity of both bodies (Planet and Aircraft) and consider that Kinetic and Potential energy will remain constant due to constant momentum. We will take the mass of aircraft negligible w.r.t planet. 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.
    With the help of matlab we will find two graph,In First we can say that Energy gained by Spacecraft is equal to Energy lost by the planet and Second represent that Kinetic Energy remains constant on both bodies.
    Rocket engines are used to change the speed of the spacecraft. However, Rocket thrust takes propellant, propellant has mass to take that amount of mass in the space we need larger requirement for the fuel. Gravity assist manoeuvres can significantly change the speed of a spacecraft without expending fuel.

  • {"email":"Email address invalid","url":"Website address invalid","required":"Required field missing"}
    Subscribe to our newsletter!

    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