system
Given the following post, respond as if you're commenting on Reddit:
human
Why does gravity assist work?

I understand what gravity assist is but I do not understand why the object using the gravity assist gains so much energy after passing into and out of somethings SOI. Wouldn't the object in question lose just as much energy as it gained falling towards the body as it would traveling out of it's SOI? Educate me please.
gpt
Frames of reference matter. With respect to the planet, what you said is right. The object/spacecraft arrives with a certain velocity to the planet (called v-infinity) and leaves with the *same* velocity in a different direction w.r.t the planet. The planet changes the direction of the velocity vector.

Now, if you look at the velocity of the spacecraft relative to the Sun (which both the spacecraft and the planet are orbiting), the velocity will have changed drastically due to this flyby. This simple change in direction of the planet-centered velocity vector, can either decrease or increase the magnitude and also change the direction of the sun-centered velocity vector depending on how you did the fly-by.