Cory, here's a different way of thinking about gravity assists that may help:

First is my short answer for readers in a hurry:

What is really going on is a giant game of pool, with fast-moving planets acting as massive cue balls that impart some of their energy when they whack into tiny spacecraft. Since you can't bounce a spacecraft directly off the surface of a planet, it instead is steered to rebound smoothly off the immense virtual trampoline that gravity creates behind the planet. This field slows down and reverses the relative backward motion of a spacecraft to give a net powerful forward thrust (or bounce) as the spacecraft loops around in a U-shaped path behind the planet.

Next is my original, more story-style long answer:

Imagine a planet like Venus as a giant, perfectly elastic (bouncy) rubber ball, and your spacecraft as a particularly tough steel ball. Next, drop your steel ball spacecraft from space in such a way that it will hit the side of Venus that is facing forward in its orbit around the Sun.

The spacecraft will speed up as it falls towards the surface of Venus, but after it bounces — perfectly and without any loss of energy in this imaginary scenario — it will similarly slow down as the same gravity resists its departure. Just as with an elastic ball that at first speeds up when dropped and then slows down after bouncing on the floor, there is no net free "gravity energy" from the interaction.

But wait a second... there is another factor!

Because the spacecraft was dropped in front of the orbital path of Venus, the planet will be moving *towards* the satellite at tremendous speed when the bounce happens at the surface.

Venus thus acts like an incredibly fast, unimaginably massive cue ball, imparting a huge boost in velocity to the spacecraft when the two hit. This is a real increase in speed and energy that has nothing to do with the transient faster-then-slower speed change due to gravity.

And just as a cue ball slows down when it transfers impact energy to another ball, there is no free energy lunch here either: Venus slows down when it speeds up the spacecraft. It's just that its massive size makes the decrease in the orbital speed of Venus immeasurably small in comparison.

By now you probably see where I'm heading with this idea: If only there were a real way to bounce a spacecraft off of a planet that is moving quickly around the Sun, you could speed it up tremendously by playing what amounts to a gigantic interplanetary game of space pool.

The shots in this game of pool would be very tricky to set up, and a single shot might take years to complete. But look at the benefits!

Even if you start out with a relatively slow (and thus for space travel, cheap) spacecraft launch, a good sequence of whacks by planetary (or moon!) cue balls would eventually get your spacecraft moving so fast that you could send it right out of the solar system.

But of course, you can't *really* bounce spacecraft off of planets in a perfectly elastic and energy conserving fashion, can you?

Actually... yes, you can, by using gravity!

Imagine again that you have placed a relatively slow-moving spacecraft somewhere in front of the orbital path of Venus. But this time instead of aiming it towards the *front* of Venus, where any real spacecraft would just burn up, you aim it a bit to the side so that it will pass just *behind* Venus.

If you aim it close enough and at just right angle, the gravity of Venus will snatch the spacecraft around into a U-shaped path. Venus won't capture it completely, but it can change its direction of motion by some large angle that can approach 180 degrees.

Now think about that. The spacecraft first moves towards the fast-approaching planet, interacts powerfully with it via gravity, and ends up moving in the opposite direction. If you look only at the start and end of the event, it looks just as if the spacecraft has bounced off of the planet!

And energetically speaking, that is exactly what happens in such events. Instead of storing the kinetic energy of the incoming spacecraft in crudely compressed matter (the rubber ball analogy), the gravity of Venus does all the needed conversions between kinetic and potential energy for you. As an added huge benefit, the gravitational version of a rebound works in a smooth, gentle fashion that permits even delicate spacecraft to survive the process.

Incidentally, it's worth noticing that the phrase "gravity assisted" is really referring only to the *elastic bounce* part of a larger, more interesting collision event.

The real game that is afoot is planetary pool, with the planets acting as hugely powerful cue balls that if used rightly can impart huge increases in speed to spacecraft passing near them. It is a tricky game that requires patience and phenomenal precision, but it is one that space agencies around the world have by now learned to use very well indeed.

By the sounds of it you have made a mistake with the units. In fact, you should not be using SI units at all in your simulation; astronomical values in SI units vary by such huge orders of magnitude that they are often a source of floating point errors that can destroy trajectories.

You should instead use the astronomical system of units. Specifically, express your masses in solar masses, your lengths in the astronomical unit, and time in the mean solar day.

Your value of $G$ will then be the square of the Gaussian gravitational constant, i.e.

$$ G=k^2=0.0002959122083\,\mathrm{AU}^3\mathrm{D}^{-2}\mathrm{M}_\odot^{-1} $$

You can get position and velocity data for the planets, their moons, comets, and hundreds of thousands of asteroids, etc, from JPL HORIZONS. You need to connect to their servers via telnet and request the data.

Alternatively, as a starting point, if you know the distance $r$ and mass $m$ of a planet, then its orbital speed should be

$$ v = \sqrt{\frac{GM}{r}} $$

where $M=1\,\mathrm{M}_\odot$. If we ignore eccentricity then the direction should be tangential to the orbit (e.g. position it at $(r,0)$ and give it a velocity $(0,v)$).

## Best Answer

If you are in a circular orbit what you need is a Hohmann transfer, from Wikipedia:

It works like this assuming the planet is in a circular orbit.

Then the amount of delta v needed to go from the green orbit to the yellow orbit is.

where units are

Using an online calculator I deduce that the delta v you need is 25.07 km/s

This is independent of the mass of the planet.

Ok, let's start over with a different approach, what is the velocity exactly. Lets just use our trusted elliptical orbits.

Then using equations from this link you can calculate the speed at any point of a eclipse with,

$$ v^2 = \mu\left(\frac{2}{r} - \frac{1}{a}\right) $$

which leads to 44.31 km/s at perihelion.