On Monday, Elon Musk’s SpaceX accomplished something most people in the rocket industry thought was almost impossible: For the first time ever, a rocket stage that delivered a payload to orbit turned around and returned to Earth, landing safely on its tail.

Getting a rocket off the ground is difficult enough, but the science is well understood and the physics are fairly basic. The reverse of that, though, is challenging. Landing a tall, skinny craft safely is an entirely different problem.

Leaving Earth

First, a primer on the easy part. To get into orbit, a rocket must overcome both gravity and drag. Designing a rocket to be good at that, unfortunately, makes landing it again hard.

The basic rocket physics are the same for a NASA rocket or a model rocket launched by a 9-year-old. The center of mass of a rocket (the point within the rocket around which all the mass is evenly distributed) has to be lined up with the center of thrust and the thrust vector. If not, the rocket will pinwheel instead of flying straight.

Rocket designers also have to think of the center of lift, which is the point where the sum total of all lift generated by parts — wings, control surfaces, and aerodynamic fuselage parts — balances out. It’s easy to think of it, actually, as a center of drag. As a rocket launches, the center of drag will move in a way to keep it directly behind the center of mass. A rocket flying in that configuration will be stable.

But as a rocket burns fuel, the center of mass will shift. If the center of mass moves backwards behind the center of drag, a rocket that was stable will become unstable. A lift vehicle that’s done its job is likely very close to being in this unstable configuration, due to all the propellant being expelled in launch.

Coming Home

Getting to orbit is hard enough. But landing a rocket on its tail is harder, because with almost dry tanks, the rocket is much more unstable than when it launched. The December 21 SpaceX landing wasn’t the company’s first attempt at this: They’ve tried and failed on two previous occasions.

[youtube https://www.youtube.com/watch?v=BhMSzC1crr0]

Both previous attempts to land the rocket were made on a drone barge out to sea. This was the first attempt on dry land, which had some advantages. Dry land doesn’t lurch around, and the newly built landing pad (LZ-1) at the Cape is a lot bigger. (Although, to SpaceX’s credit, they nailed the landing right in the middle of the pad.)

[youtube https://www.youtube.com/watch?v=ZCBE8ocOkAQ]

There’s a lot about the newly upgraded Falcon 9 that makes it uniquely capable of landing after launching. Most rockets need all their available fuel to get their payload into orbit. But the Falcon 9 was built with reusability in mind, and an almost 30% margin in fuel, allowing it to deliver the SpaceX Dragon capsule, or another payload like the 11 ORBCOMM satellites lofted to orbit on Monday, and still have enough fuel to return the first stage.

The extra fuel is needed to brake the first stage. After second stage separation and ignition has occurred, and whilst still hypersonic, the first stage engines are relit, braking and turning the stage back towards the landing site in a “boostback” burn. Later during reentry another burn is made, this time using just three of the nine main thrust engines. Finally, a “terminal” burn uses a single engine to slow the rocket to a soft touchdown.

But it’s not just extra fuel that’s needed. The Falcon 9 also has small, foldable, heat-resistant wings called grid fins. These are needed to steer the stage as it falls, tail-first, from the edge of space through the atmosphere. The fins put the drag behind the downward vector of the rocket, keeping the engine pointed into the flight vector, where just minutes prior, every law of physics was making the rocket fly in the exact opposite configuration.

The first stage also has cold-gas thrusters located towards the top of the rocket which are used to flip the rocket around so that the main engines can be relit and perform the boostback burn. Finally the stage is equipped with landing legs which deploy as it touches down.

All of these systems are (and need to be) totally automated — reacting and adjusting their behaviors based on real-time data from onboard sensors. Things happen far too fast, and the rocket is far too twitchy, for a human to operate it. It’s a job best left to a computer.

The reason the rocket is difficult to control in landing configuration has a lot to do with the centers of mass and drag that we talked about earlier. The Falcon 9 needs to be tall and thin so that it can be an efficient launch vehicle, but that exact configuration makes it a beast to control as it comes back down.

While the cold-gas thrusters are used to rotate the rocket before the boostback burn, the Falcon 9 uses its gimbaled main engines to provide the breaking thrust and (almost all) of the rotational (angular) thrust needed to steer and land the stage back on the ground. In other words, all the torque to turn the rocket is applied at one end of the rocket, without any balancing thrust at the other end. Just try balancing a broom handle on your fingertip, head-side up, to see how hard a problem this is.

It’s possible, but because you’re providing a force at one end, it is very unstable and corrections need to be made continuously. And since the rocket engine providing these corrections (to keep the stage upright and stable) is also being used to brake the falling first stage towards landing, and also provide horizontal vectoring, doing so is a hard real-time computation problem.

If the rocket tips too far and the center of mass moves out beyond the edge of the tail of the rocket, unless it’s immediately pushed back in the opposite direction, the rocket stage will become unrecoverable. A shorter, squatter rocket would be easier to control for landing, but much harder to get into orbit in the first place due to aerodynamic drag, not to mention being less stable on the ascent.

In sum, the SpaceX tail landing is a triumph not just of rocket design, but of software. It’s just not easy to balance a moving, unstable stick on its tail all the way down to a safe landing at a very specific location.

But it’s not the first

This isn’t the first time a rocket has landed vertically. After the first successful landing of the Blue Origin suborbital New Shepard vehicle in West Texas towards the end of last month, Blue Orbital founder Jeff Bezos took to Twitter, posting footage of the launch and landing of the vehicle.

The rarest of beasts – a used rocket. Controlled landing not easy, but done right, can look easy. Check out video: https://t.co/9OypFoxZk3 — Jeff Bezos (@JeffBezos) November 24, 2015

Graciously left unsaid was any mention of the failure of SpaceX to land its Falcon 9 — the five ocean water test descents, and the two failed test landings on the drone ship. Nonetheless this led to some acrimonious words between the two billionaires.

Congrats to Jeff Bezos and the BO team for achieving VTOL on their booster — Elon Musk (@elonmusk) November 24, 2015

It is, however, important to clear up the difference between "space" and "orbit", as described well by https://t.co/7PD42m37fZ — Elon Musk (@elonmusk) November 24, 2015

Ouch. However it really is the “flip” and boostback burn executed by Musk’s Falcon 9 that makes the landing a unique accomplishment. Getting to space requires speeds of around Mach 3, but getting to orbit requires speeds of around Mach 30, where the required energy is proportional to the square of the speed (E ∝ v²). What SpaceX accomplished with the Falcon 9 is a lot tricker: breaking from orbital speeds to return the stage to the ground with rocket intact has never been done before.

Musk went on to point out that SpaceX had been flying sub-orbital test flights with their Falcon 9-R — code named “Grasshopper” — since 2013.

Jeff maybe unaware SpaceX suborbital VTOL flight began 2013. Orbital water landing 2014. Orbital land landing next. https://t.co/S6WMRnEFY5 — Elon Musk (@elonmusk) November 24, 2015

However after the Falcon 9’s successful landing on Monday, Bezos couldn’t help taking one last dig at Musk.

Congrats @SpaceX on landing Falcon's suborbital booster stage. Welcome to the club! — Jeff Bezos (@JeffBezos) December 22, 2015

I don’t know how seriously Bezos and Musk are taking things, but personally I think trash-talking billionaires in a space race is exactly what we need. It’s certainly a whole lot more fun than the last space race, where two nuclear powers faced off over a bunch of ICBMs.

Its Final Voyage

The returned Falcon 9 first stage is currently still sitting on the landing pad awaiting transport to the processing facility.

[youtube https://www.youtube.com/watch?v=IvWBf1IjzrY]

Whilst in the future the returned Falcon 9 first stages will be refuelled and reflown — slashing SpaceX’s operational costs, as just 3% of the cost of building and launching it goes in spent fuel — it has been confirmed that this Falcon 9 at least won’t be reflown.

Following an unsuccessful CRS-7 launch, SpaceX’s Dragon is expected to return to flight in February with CRS-8. The debut of the SpaceX Falcon Heavy, involving a ballet dance of three Falcon 9 first stage cores returning to the Cape, is scheduled for the middle of the year.