16.4 Capstone: Drum & Membrane Mode Synthesizer ended by pointing at a problem with the opposite character. A drum is linear and damped, so the integrator’s errors die out and a modal sum is exact. An orbit is nonlinear and conservative: nothing damps, every error accumulates for as long as you integrate, and a method that is accurate and stable in the sense of 4.1 Local Error, Global Error & Order can still make a satellite spiral out of its orbit. This capstone builds an orbital transfer planner around that difficulty. We write down the two-body problem and the three quantities it conserves, use them to measure what four integrators do to a Kepler orbit, compute the classical burns in closed form and check them by flying them, patch two orbits together for a trip from Earth to Mars, recover a transfer from its endpoints with a Lambert solver and with Newton shooting, and finish with a lab where you place maneuver nodes on an orbit and read the energy diagnostics.
Transcript
- The last capstone is a spacecraft under one point mass, in units where mu is 1. Three quantities are conserved along every orbit: the energy, the angular momentum, and the Laplace Runge Lenz vector, which points at periapsis and keeps the ellipse closed. We know their true values, so they are the integrator's report card. A long RK4 run at e equal 0.6 held the energy to 2.9 times 10 to the minus 11 over ten orbits.
- Now four integrators on an e equal 0.5 orbit, 200 steps per orbit. Euler pumps the energy up by 93 percent in ten orbits. RK4 wins at ten orbits, but its energy error grows linearly: 9.9 times 10 to the minus 6, then 9.3 times 10 to the minus 5, then 9.3 times 10 to the minus 4. Yoshida four is symplectic, and its error is 2.017 times 10 to the minus 5 at ten, a hundred and a thousand orbits. Verlet sits flat at 2.689 times 10 to the minus 3.
- Halve the step and Verlet's error falls by 4, Yoshida's by 16, and RK4's by 27 to 30. At equal cost, 1200 force evaluations per orbit over 100 orbits, Yoshida four wins, with an energy error of 1.27 times 10 to the minus 6. But a bounded energy is not a bounded position. Yoshida's phase error still grows linearly: 3.31 times 10 to the minus 3, then 3.31 times 10 to the minus 2, then 0.326.
- At eccentricity 0.9 a fixed Verlet step of 420 per orbit is wrong by 0.6132 of its energy within a few orbits. Make the step depend on r to the three halves and it looks fine at ten orbits, 2.402 times 10 to the minus 3, then drifts: 1.042 times 10 to the minus 2, then 8.894 times 10 to the minus 2 at a thousand. The time symmetric rule of Hut, Makino and McMillan stays flat at 1.485 times 10 to the minus 3, for about four times the force evaluations.
- An impulsive burn changes the velocity at a fixed position, so every transfer is vis-viva arithmetic: v squared is 2 over r minus 1 over a. The Hohmann ellipse from radius 1 to radius 4 has semi-major axis 2.5 and eccentricity 0.6. The burns are 0.2649111 and 0.1837722, a total of 0.4486833 of the circular speed, in 12.41824 time units. Flown with Verlet at step 0.01, the final orbit has eccentricity 1.10 times 10 to the minus 4.
- Three burns can beat two. In the limit of an infinite apoapsis the total is root 2 minus 1 times 1 plus 1 over root R. Bisection finds where it crosses Hohmann: R star is 11.93876552. At R equal 20 with r b equal 60 the total is 0.5207391 against 0.5347314, a saving of 2.6 percent, but the flight takes 1323.94 time units against 106.889. That is a mission decision, not a numerical one.
- Patched conics turns a three-body trip into a chain of two-body problems. About the Sun it is a Hohmann ellipse, with an excess speed of 2.944689 kilometres per second leaving the Earth. The textbook burn from a 6778 kilometre orbit is 3.569119 kilometres per second, and capture at Mars costs 2.079937. The flight takes 258.8658 days, in which Mars moves 135.66 degrees, so it must lead the Earth by 44.3442 degrees. Windows repeat every synodic period, 779.949 days, about 26 months.
- But fly the burn. Leaving the sphere of influence, 924647 kilometres out, the spacecraft still has 3.087614 kilometres per second, not 2.944689, because the speed at infinity is not the speed at the patch. The orbit overshoots Mars by 0.035 astronomical units. Correct the burn so the speed at the sphere of influence is v infinity: 3.530693 kilometres per second. The aphelion is 1.524818 against Mars at 1.523679, a miss of 0.0011. Under a tenth of a percent, once the potential is respected.
- The inverse question is Lambert's problem: given two positions and a flight time, find the velocity. Shooting treats it as root finding with Newton's method, and the miss falls 0.4686222502, 0.02925064, 1.1451 times 10 to the minus 4, 2.0175 times 10 to the minus 9: quadratic convergence. But it converges to the answer of its propagator. RK4 at step 0.05 is wrong by 3.375 times 10 to the minus 8, Verlet at 0.01 by 1.375 times 10 to the minus 5. The universal variable solver needs no guess and is exact to about 10 to the minus 14.
- Honest limits. A point mass has no oblateness, no drag and no third bodies. Impulsive means infinitely strong. The planet constants and the step rule are from memory, and the Lambert solver is single revolution and prograde. This is a planning sketch with verified arithmetic. And that is the end of the course: sixteen modules and five capstones, and one habit. A simulation passes if it conserves what should be conserved, converges at the order it claims, and agrees with an independent calculation. Everything beyond is the same ideas with different words.
What we are building
A spacecraft far from every other body, under the pull of a single point mass, moves according to the Kepler problem of 12.7 Orbital Mechanics,
Everything in this capstone uses canonical units: , and the start orbit is a circle of radius . Then the circular speed is , the period of a circular orbit is , and an orbit of semi-major axis has period . A velocity change (a delta-v) is quoted as a fraction of the circular speed of the start orbit. To turn the lab’s numbers into kilometres and seconds, we pick the start orbit to be a circle of radius km about the Earth (an altitude of about km on a radius of km, the radius being from memory) with km/s (the standard value, from memory). That gives a velocity unit of km/s, a time unit of s, and a time-unit period of minutes. Nothing in the numerical results depends on this choice; it is a label.
Every result below states the units, the integrator and the step. Each number was produced twice: once by the lab’s own functions run under node, and once by a separate Python program that reimplements the steppers from scratch in plain floating point, uses scipy’s DOP853 integrator at relative tolerance as an exact orbit, and uses scipy’s brentq, minimize_scalar and fsolve for the root finding. The two agreed to a relative or better, except in the places I say. The things that are from memory are marked: the physical constants for the Sun, Mars and the planetary orbits, the Hut-Makino-McMillan time-symmetric step rule, and the regularised formulations that I name without implementing.
Six steps build the lab, and then the lab itself:
- the two-body problem, its three invariants and units;
- four integrators compared on a Kepler orbit, and the step-size problem at eccentricity ;
- impulsive maneuvers: Hohmann, bi-elliptic, plane change;
- patched conics, Earth to Mars;
- Lambert’s problem and shooting;
- the planner.
Step 1: the two-body problem and what it conserves
With and the state in the orbital plane, three quantities are constant along every solution. They are the specific energy, angular momentum, and the Laplace-Runge-Lenz (LRL) vector,
The energy is conserved because the force is the gradient of , and the angular momentum because the force is central, as in 14.7 N-Body Simulation. The LRL vector is the unusual one, a hidden symmetry of the inverse-square law. It points from the focus toward periapsis, its length is the eccentricity, and its conservation is the reason the orbit is a closed ellipse that does not precess. The three are not independent: , which you can check from the definitions. The orbital elements follow:
Also useful is the vis-viva equation , which is the definition of rearranged and is the engine of every burn calculation in step 3.
These are the integrator’s report card. Conservation is the one thing we know the true answer to, so a numerical orbit that violates it is wrong by exactly that much, and the violation is cheap to measure. The first cell runs a long RK4 reference orbit with (units , steps per orbit for orbits) and prints how well the invariants hold. In that run , and , and the largest drift of over the ten orbits was .
Now you write the function that every later step leans on. It takes a state and returns the invariants and the orbital elements.
Step 2: four integrators on a Kepler orbit
The methods, in order of what they cost per step (the number of force evaluations, since gravity is the expensive part in a many-body code):
- Euler, one evaluation, first order. It is in the lab for contrast. It heats the orbit.
- RK4, four evaluations, fourth order (4.3 Runge–Kutta Methods & Butcher Tableaux). Accurate for a given step, but not symplectic.
- Velocity Verlet, one evaluation per step (the second force is reused as the first of the next step), second order and symplectic. In kick-drift-kick form: , , , where is the acceleration.
- Yoshida 4, three evaluations, fourth order and symplectic. It is three Verlet substeps with weights , and again, so that the weights sum to and the second-order error terms cancel. One of the substeps runs backward in time, which is what the negative weight means.
A symplectic method (4.7 Energy & Symplectic Integrators) exactly conserves a nearby Hamiltonian, the original plus a small correction that is a power series in . The energy then does not drift but oscillates, with a bounded amplitude of order for a method of order , over times that are exponentially long in (from memory, backward error analysis). The orbit is a faithful ellipse of a slightly different problem. RK4 is not symplectic, so it has no such guarantee, and it dissipates a tiny amount at every step in a way that adds up.
All measurements below start at periapsis of the orbit with and (period , units ), use a fixed step of unless stated, and compare with the exact orbit. The cell after this paragraph runs all four and prints the largest relative energy error over ten orbits and the position error after ten whole orbits, which is the distance between where the spacecraft is and where it began, because after whole periods the exact answer is the starting point. That position error is dominated by the phase: the orbit has the right shape and the wrong clock.
The results, as the cell prints them (max over the run of , and the position error after orbits):
| method | max energy error | position error at 10 orbits |
|---|---|---|
| Euler | 0.9345 | 1.0688 |
| RK4 | 9.935e-6 | 9.40e-4 |
| Verlet | 2.689e-3 | 0.4291 |
| Yoshida 4 | 2.017e-5 | 3.31e-3 |
Euler is useless: in ten orbits it has pumped the energy up by . The more interesting comparison is between RK4 and the symplectic pair. At this step RK4 wins on the ten-orbit numbers, and a reader who stopped here would conclude that RK4 is the right tool. Stretch the run and look at the angular momentum and energy over more orbits (the same step, per orbit, from the lab’s functions, checked against an independent Python code):
| method | max energy error at 10 / 100 / 1000 orbits | position error at 10 / 100 / 1000 orbits |
|---|---|---|
| RK4 | 9.935e-6 / 9.329e-5 / 9.275e-4 | 9.40e-4 / 0.0773 / 1.777 |
| Verlet | 2.689e-3 at all three | 0.4291 / 1.949 / 1.160 |
| Yoshida 4 | 2.017e-5 at all three | 3.31e-3 / 3.31e-2 / 0.3257 |
Read it column by column. The RK4 energy error grows linearly with the number of orbits: ten times the orbits, ten times the error. Verlet’s and Yoshida’s maximum energy error is the same at ten and at a thousand orbits, which is what bounded means. The angular momentum tells the same story: Verlet and Yoshida hold at about , rounding level, because angular momentum is conserved exactly by these methods for a central force, while RK4’s drifts ( at ten orbits) and Euler’s changes by .
The position error is where honesty is needed, because it does not stay bounded for any of them. Yoshida’s phase error grows linearly and cleanly: , then , then , which is a factor of ten per factor of ten in orbits until it begins to wrap. Verlet’s has already wrapped by orbits: an error of is comparable to the orbit’s diameter, so the spacecraft is somewhere else on the ellipse and the number at orbits tells us nothing beyond “not where it should be”. RK4’s phase error grows by times for ten times the orbits and saturates at by a thousand orbits. A symplectic method gives you the right ellipse and the wrong place on it, and the wrong place gets worse linearly in time. If you need to know where the spacecraft is after a thousand orbits, you need a small step or a high order, or an analytic propagator, which is the idea of step 5.
Order and cost
How the energy error scales with the step, from to steps per orbit (max relative energy error over orbits at ):
| steps per orbit | RK4 | Verlet | Yoshida 4 |
|---|---|---|---|
| 100 | 2.986e-4 | 1.0845e-2 | 3.132e-4 |
| 200 | 9.935e-6 | 2.689e-3 | 2.017e-5 |
| 400 | 3.458e-7 | 6.710e-4 | 1.269e-6 |
| 800 | 1.300e-8 | 1.677e-4 | 7.947e-8 |
Each row halves the step. Verlet’s error falls by , , : second order, as it should. Yoshida’s falls by , , : fourth order. RK4’s falls by , , , an observed order between and , which is better than fourth. My explanation, which I derived and did not check anywhere else, is that RK4’s energy error on an oscillator is a dissipation term whose leading coefficient is of order per step, so it is per orbit, and the measured ratios of about to are between and . The first thing to note is that this is a property of the energy error and not the order of the method, which is four.
The second thing is cost. Fix a budget of force evaluations per orbit (Verlet steps, Yoshida , RK4 ) and run orbits at :
| method (steps per orbit) | max energy error | position error at 100 orbits |
|---|---|---|
| Verlet (1200) | 7.451e-5 | 0.1225 |
| RK4 (300) | 1.237e-5 | 1.033e-2 |
| Yoshida 4 (400) | 1.269e-6 | 2.083e-3 |
At equal cost Yoshida wins on both measures here, by a factor of ten in energy over RK4 and a factor of five in position, and the cheap, low-order Verlet loses despite having the best energy behaviour in principle. Over a thousand orbits RK4’s linearly growing error would cross Yoshida’s bounded one by a wide margin, so the ranking would only get more lopsided. For one orbit with a loose tolerance RK4 is fine. For a planner that propagates years of flight, you want a symplectic method of high order.
Now implement the Verlet step and the energy-error measurement yourself.
The eccentric orbit
Everything above used . The case that breaks fixed steps is a high eccentricity, because the spacecraft moves fast and curves hard near periapsis and slowly elsewhere, and a step fine enough for periapsis wastes work at apoapsis. Take and , periapsis (a point-mass test: that is inside the Earth if the unit is the Earth’s radius, and I am using it only to stress the integrator). The orbit is the same energy as before; what changed is that the speed at periapsis is in units of the circular speed.
At a fixed Verlet step of per orbit, the worst relative energy error is at both and orbits, so the orbit is wrong by more than half its energy within a couple of revolutions. (At orbits the node program gave and the independent numpy program : a badly resolved orbit is sensitive to rounding, so I quote only the first two numbers and say “about ”.) RK4 at the same steps does worse: at orbits and at , which means the energy has run away entirely. Refining Verlet helps at the expected second-order rate: at steps per orbit and at , for ten orbits. To get a bounded error of with a fixed step you need roughly steps per orbit (by interpolating those two), and almost all of them are wasted far from periapsis.
The remedy is a step that depends on where the spacecraft is, for example , proportional to the local orbital period scale, which is small at periapsis and large at apoapsis. There is a trap. A symplectic method has its guarantees only for a fixed step. If is chosen from the state at the start of the step, the map from one state to the next is no longer symplectic and no longer reversible, and the energy error is no longer bounded. The lab implements both versions (the Verlet stepper with , from the same periapsis state):
| step rule | max energy error at 10 / 100 / 1000 orbits | steps per orbit | force evaluations per orbit |
|---|---|---|---|
| naive: | 2.402e-3 / 1.042e-2 / 8.894e-2 | 422 / 416 / 394 | about 840 |
| time-symmetric | 1.485e-3 at all three | 425 / 420 / 419 | about 3300 |
The naive rule looks as good as the fixed step at ten orbits (and it is hundreds of times better than the fixed step at about the same number of steps), and then it drifts: times more error at a hundred orbits and times at a thousand. The time-symmetric rule is bounded, as promised. It is the rule of Hut, Makino and McMillan (from memory): choose the step so that the step as measured from the end of the step is the same as the step measured from the start, that is with , and find by a short fixed-point iteration. The step is then a function of both ends, which makes it reversible, and the reversible symmetric scheme keeps the energy bounded again. The honest part is the cost, which I measured: the iteration uses about four times as many force evaluations as the naive rule ( against per orbit; the two versions of the count agree to four digits and differ in the fifth, so quote “about ”). Even so, it is more than twice as efficient as the fixed step that would be needed for the same energy error ( steps).
Two other remedies exist and I did not build them, so they are from memory. A Sundman transformation changes the independent variable from time to a fictitious time with so that a fixed step in is a variable step in , and the Kustaanheimo-Stiefel regularisation goes further and removes the singularity entirely, which also makes collision orbits integrable. Adaptive RK45 (4.4 Adaptive Step Size & RK45) controls the local error and so handles the step choice automatically, but it is not symplectic and will show the linear energy drift of RK4 for long runs.
Step 3: impulsive maneuvers
An impulsive burn changes the velocity in zero time, so the position is unchanged across it. This is a good model when the burn lasts a small fraction of the orbit, and it is wrong for a low-thrust ion engine (see the limits section). With it, every transfer reduces to vis-viva arithmetic.
Hohmann
To go from a circle of radius to a circle of radius in the same plane, Hohmann’s transfer is the ellipse that touches both, with periapsis , apoapsis and semi-major axis . The first burn is prograde at radius , the second prograde at radius :
For : , , total of the circular speed, flight time time units, transfer eccentricity . For the course’s LEO to GEO case, the start radius km and the target km (), the same formulas give and km/s, a total of km/s, in time units, or hours. That agrees with the m/s and s of 12.7 Orbital Mechanics, as it should, since this is the same calculation (the km figure is from memory).
Is the formula right once the spacecraft is flown by an integrator? The check is to fly it. Take , burn prograde at , integrate until the radial velocity changes sign (apoapsis), burn again, and look at the resulting orbit. Using Verlet at , the second burn fires at the first step boundary after apoapsis at , at a radius of , and the final orbit has and (circular is ), with a maximum energy error of and a position error against the exact two-body flight of . Reducing the step by ten to gives , , , energy error and position error : the energy and position errors fell by exactly a hundred (second order), while the final eccentricity did not fall at all. The reason is that the burn fires at the step boundary, not at the true apoapsis, so the burn direction and time are off by up to a step, and that small error does not shrink at second order. RK4 at does better on every number: , energy error , position error , and , whose residual is again the detection of the apoapsis. The exact answer, from DOP853 and a root-finding on the sign change, is a burn at and a radius of . The lab uses the step boundary and tells you so.
Bi-elliptic
A bi-elliptic transfer takes three burns: go out on an ellipse to a far apoapsis , burn there to raise the periapsis to , and burn at to circularise. Vis-viva gives each burn, with and :
Why can three burns beat two? Far from the attractor the speed is tiny, so a change of speed there is cheap, and it changes the periapsis a lot. In the limit the second burn costs nothing, the first is the escape burn and the third is the arrival burn , so the total is exactly
which falls monotonically with and tends to , while the Hohmann total tends to from above after peaking near (the maximum of Hohmann’s ; the numerical optimum is in the node code and in scipy, so I quote ). The two curves cross at one point. Setting them equal and solving by bisection gives the crossover
and the independent solution with brentq agrees to . For below it Hohmann is cheaper no matter what is, and above it a large enough wins. The classic quotation is (from memory), and the computation gives it. The cell below does both the flying check and the bisection.
The table compares the transfers for a few radius ratios (total in units of the start circular speed; flight times in periods of the start orbit, that is units of time units):
| R | Hohmann | Hohmann flight | bi-elliptic, rb to infinity | bi-elliptic, rb = 100 | rb = 100 flight |
|---|---|---|---|---|---|
| 10 | 0.5297875 | 6.449 | 0.5451994 | 0.5459369 | 383.38 |
| 12 | 0.5341799 | 8.286 | 0.5337867 | 0.5364974 | 388.97 |
| 15 | 0.5362182 | 11.314 | 0.5211630 | 0.5265023 | 397.44 |
| 20 | 0.5347314 | 17.012 | 0.5068345 | 0.5159265 | 411.81 |
| 50 | 0.5136958 | 64.384 | 0.4727922 | 0.4966508 | 504.19 |
Three features of it are worth saying aloud. First, at no bi-elliptic transfer wins: Hohmann is against for the limit and for . Second, at , just above , the limit case wins by and a bi-elliptic with does not: for you need before the three-burn transfer beats Hohmann, and for the threshold is . Third, the savings are real but small and come with a flight time of hundreds of orbits. At with the total is against Hohmann’s , a saving of , and the flight time is time units ( start-orbit periods) against Hohmann’s . Flying this plan with Verlet at gives burn 2 at and burn 3 at , with a final eccentricity of and . Whether a saving is worth a factor of twelve in time depends on what you are carrying; that is a mission decision and not a numerical one.
I did not find the best for each . A golden-section search for it goes to the boundary of the search range, because the total is not unimodal in on a wide range (it is worse than Hohmann at the small end for ), so the table gives the limit and the sample and the thresholds, which are reliable.
Plane change
To change the orbital plane by an angle at the point where the orbits cross, rotate the velocity vector without changing its length. The velocity change has magnitude , which is proportional to the speed, so the cheapest place to do it is where the speed is lowest: the apoapsis. A degree change at the circular speed costs exactly (a full circular speed), since .
For a launch at degrees latitude (the inclination of the orbit one gets by launching due east from there; the latitude is from memory) into a GEO transfer, the numbers in km/s are these. A pure plane change at LEO speed costs ; at GEO speed, ; but if you change the plane at the apogee of the transfer ellipse while burning to circularise, the combined burn is a single vector difference with magnitude and costs km/s (the apogee speed is km/s). Circularising first and then changing the plane at GEO speed costs km/s in total, so the combined burn saves km/s over the separate ones. The point is not the number but the principle: put the plane change in the burn that is already happening, and at the highest altitude.
For a hand version of the same idea at and a degree plane change, see the problems at the end.
Step 4: patched conics, Earth to Mars
A transfer between planets involves three bodies in principle, and the patched-conic approximation reduces it to a chain of two-body problems. The spacecraft follows a hyperbola about Earth until it leaves the Earth’s sphere of influence, then an ellipse about the Sun that takes it to Mars’s orbit, then a hyperbola about Mars. The approximations are: the planets move on circular, coplanar orbits about the Sun; each leg is a pure two-body orbit about one body; and the handoff between legs happens instantaneously at the sphere of influence, with a simple velocity addition. This is a good first design tool and a poor final one: the whole point of the calculation below is to see where it is wrong.
The constants, in km and s: AU km, km/s, km/s, Mars’s orbital radius AU, and a Mars capture orbit of radius km ( km planet radius plus km altitude). All of those are from memory and I did not look them up, and the quoted results inherit any error in them.
The heliocentric part is a Hohmann transfer between the Earth’s orbit ( km/s circular speed) and Mars’s ( km/s). The transfer ellipse has km. The speed at its perihelion is km/s and at aphelion km/s, so the excess speeds are
The flight time is half the transfer period: days. Mars moves in that time, while the spacecraft sweeps , so at departure Mars must lead the Earth by degrees. Earth and Mars return to the same relative position after a synodic period, days, so launch windows are about months apart. These are closed forms; the cell below computes all of them.
The departure burn from a circular parking orbit. The hyperbola has excess speed at infinity, and energy conservation gives the speed at the parking radius as , so
For km and km/s this is km/s, and the capture burn into the km circular orbit about Mars is km/s.
The patch and where it leaks
Take the departure burn seriously and fly it. The Earth’s sphere of influence has radius with the planet’s orbital radius ( is the usual exponent, from memory), which is km for Earth and km for Mars. The patch: integrate the Earth hyperbola out to , take the exit velocity relative to Earth, add the Earth’s heliocentric velocity, and fly the result about the Sun. The question is what orbit that gives, which the cell below computes analytically with the exit speed from energy conservation and the exit direction from the angular momentum.
With the textbook burn km/s the spacecraft leaves the sphere of influence after hours at a speed of km/s, not . The heliocentric orbit has perihelion AU and aphelion AU, which overshoots Mars’s AU by AU, about million km. The reason is that is the speed at infinite distance, and the spacecraft leaves the Earth’s sphere of influence while it is still deep in the potential: its speed there satisfies and the extra term is not zero. So the burn computed for infinity gives too much speed at the patch. Correct the burn so the speed at the sphere of influence is ,
which gives km/s, km/s less, and the exit takes hours at km/s. The resulting aphelion is AU, a miss of AU ( km) in the radius at which Mars’s orbit is crossed, and the heliocentric flight time to aphelion is days against the ideal . The textbook burn’s own flight time to aphelion was days. So the conic patch is good to under a tenth of a percent in aphelion once the burn accounts for the sphere of influence, and to about two percent if it does not. What is still missing in the corrected version is the gravity of the Earth beyond the sphere of influence, the Sun’s pull during the 79 hours of escape, and the finite size of the sphere of influence, which is why the corrected aphelion is not exactly Mars’s radius.
Step 5: Lambert’s problem and shooting
The planner so far has been forward: choose a burn, predict where it ends. The inverse question is the one a mission designer asks. Given the position now and the position at a time later, what velocity at gets you there? That is Lambert’s problem, and it is a two-point boundary value problem: the equations of motion with a position specified at each of two times instead of a position and a velocity at one time, the shape of 8.1 Two-Point Boundary Value Problems.
There are two ways to solve it, and they differ in what they assume about the propagator.
Shooting treats it as root finding. Let be the position reached after time from the state , minus . Solve for the two unknowns by Newton’s method with a finite-difference Jacobian. Each Newton step costs three flights (one at the current guess, one for each of the two columns of the Jacobian), and the flight can be done by any integrator. That is the strength of shooting: it works for any dynamics, including perturbations that no formula covers. The weakness is that it needs a starting guess in the basin of convergence, and each flight costs a full integration.
The universal-variable solver uses the fact that the two-body problem has an exact solution. The unknown is a single scalar (the universal variable, positive for ellipses, negative for hyperbolas and zero for parabolas), and the time of flight is an explicit function of it through the Stumpff functions
and the geometry and . The time of flight is and it is monotonic in on the branch we care about, so a bracketed bisection or Newton on finds the root with no initial guess. The velocities then come from the Lagrange coefficients, , and : . This version handles a single revolution counter-clockwise; the multi-revolution and clockwise branches need more care and the lab does not implement them.
Three tests establish that both are right. (i) Fly the state for : it ends at with velocity , a transfer angle of . Hand , and to the Lambert solver and it returns to about ( in the node code, in Python). (ii) A transfer angle above is harder, because changes sign: the state flown for sweeps and is recovered to about (node) and (Python). (iii) An independent fsolve shooting with DOP853 as the propagator recovers to .
Shooting with the exact propagator takes four Newton iterations from the circular-speed guess for the first test, with the miss distance falling as
That is quadratic convergence: each miss is about the square of the previous one, times a constant. (After the fourth step the printed residuals are rounding noise and not worth quoting.) The finite-difference Jacobian cost nothing in convergence order here. And what does the choice of propagator do to the answer? Shooting with an RK4 propagator at step recovers to , at step to , and a Verlet propagator at gives ; all took four iterations. This is the point to remember: Newton converges to the solution of the discretised problem, so the answer is wrong by exactly what the propagator is wrong by, however fast Newton converges. For a planner, the universal-variable propagator is exact and fast, and the lab uses it as its reference. Shooting is for the problems that have no exact propagator.
Now write the shooting loop with the RK4 propagator provided.
Rendezvous: when to go
Lambert also answers the rendezvous question: the target is on its own circular orbit and will be at a known place at a known time. For a circular start orbit of radius , a target on a circle of radius , and a target lead angle at the moment of departure, the total (departure plus arrival matching) is a function of the flight time . The Hohmann phasing angle is the lead that makes the Hohmann transfer land on the target: for . At exactly that lead the best total is at , which is Hohmann itself. If the target is rad ahead the best total is at (a faster, slightly costlier transfer), and rad behind gives at . At an offset of rad the best total is at , which is more than Hohmann. A launch window is therefore not a point but a flat-bottomed valley in the plane of lead angle and time, whose width is a design choice: waiting for the perfect phasing saves , and a cheaper schedule costs it. In the lab’s Lambert mode the diagnostic strip plots this total against the time of flight and marks the minimum.
Step 6: the planner
The sim holds all of this in one place. The big panel shows the orbit in the plane, with the central body at the origin. In maneuver mode, a plan is a list of up to three nodes, each placed at the start, at the next apoapsis or at the next periapsis, with a prograde and a radial component of that you set with sliders. The presets fill them in: Hohmann (two nodes from ), bi-elliptic (three nodes from and ), a circular start or an eccentric one, and a free plan. Turn “fly the plan” on and the lab integrates the whole plan with the integrator you chose, at the step you chose, applying each node at the first step boundary after the event it is tied to. Turn on “osculating orbit” and it draws the instantaneous ellipse, which is what the spacecraft would follow if all burns stopped now. The strip below the orbit plots the energy error and the position error against an exact universal-variable flight from the last burn, on a log scale against time, so you can see the Verlet energy error oscillate and the RK4 error climb. The readout reports the total , the elements of the orbit after each burn, and a warning if the integrator has diverged. In Lambert mode you set the radius ratio, the target lead angle and the time of flight, and the lab solves Lambert’s problem and shows the transfer, with the buttons “Hohmann phasing” (set the lead to ) and “best time of flight” (the minimum of the total over time). The lab also runs Newton shooting with your chosen integrator and reports how far it lands from the Lambert answer. At the Hohmann phasing the transfer angle is , where the shooting Jacobian is nearly singular and the Verlet shooting does not converge ( steps, residual in my run); the lab says so. That is a real limitation of shooting, and the reason Lambert is the lab’s primary method.
Three things to try. First, load the Hohmann preset at and compare Verlet at with Euler: the final orbit with Euler is an ellipse, not a circle, and its energy diagnostic climbs from the first step. Second, load the eccentric preset, which starts on the orbit, raise the step until Verlet loses the orbit (at it escapes along a hyperbola in the first revolution), then try Yoshida, and watch the energy error and where it peaks (at periapsis). Third, set the bi-elliptic preset with and and read off its and its flight time, then switch to Hohmann and compare: that is the table from step 3, and you can read the crossover by moving to and .
The same lab opened on the eccentric orbit, where the integrator choice matters most:
And in Lambert mode, for the rendezvous of step 5:
Honest limits
- A point mass is not a planet. There are no perturbations: no oblateness (the term, which makes a low orbit’s plane and periapsis rotate by degrees per day, from memory), no atmospheric drag (which dominates below a few hundred kilometres), no solar radiation pressure, no Moon or Sun acting on an Earth orbit. A real LEO to GEO transfer is accurate to perhaps a few percent in with this model and no better, and over weeks the plane and the apsides drift away from the predictions. I cannot give a number for that error from anything I ran here.
- Impulsive means infinitely strong. A real burn takes minutes, during which the spacecraft moves and gravity acts, and the finite-burn loss for a chemical stage is typically a few percent (from memory). A low-thrust engine does not fit this model at all.
- Patched conics is an approximation of a three-body problem. I measured one consequence: skipping the sphere-of-influence correction in the departure burn misses Mars by AU, and with it AU, but neither number says how a real mission fares, because the circular coplanar planets and the instant patch are both wrong. Mars’s orbit has an eccentricity of about and an inclination of about degrees (both from memory), which makes the differ from window to window (I did not compute by how much). The trajectory of a real mission is found by a many-body integration that the patched conic only seeds.
- No third-body effects. Lagrange points, halo orbits, gravity assists and low-energy transfers are three-body phenomena, and the conserved quantities of this lesson do not survive a third body: the LRL vector is not conserved, and neither is the energy of the pair. 7.10 Chaos & the Lorenz System is the right reminder of how fast small differences grow in a chaotic system, and the many-body gravity of 14.7 N-Body Simulation is where chaos shows up in this subject.
- The lab’s Lambert solver is single revolution and prograde. It does not handle multiple revolutions or retrograde orbits.
- The time-symmetric step is from memory. The rule I quote is a form of the Hut, Makino and McMillan rule as I remember it. I implemented it as described above and verified that the energy stays bounded, but I did not check it against the paper.
- The regularised formulations are not built. Sundman time and the Kustaanheimo-Stiefel variables are from memory only.
- The UI has not been reviewed in a browser by a person. I ran it under a headless browser and viewed screenshots; I did not interact with it for long.
Concept checks
Problems
Take circular orbits of radius and with . (a) Find the semi-major axis of the transfer ellipse and the speeds on it at radius and radius . (b) Find the two burns and the flight time. (c) Check the apoapsis speed against angular momentum conservation, .
Show worked solution
(a) . Vis-viva gives and .
(b) The circular speeds are and , so and , total . The flight is half a period: .
(c) and . They agree, which is the Kepler second law at the two apsides. The numbers match the ones the flown plan reproduced in step 3 (Verlet at put the final eccentricity at , the part of the error the burn timing contributes).
(a) Show that, as , the bi-elliptic transfer between circles of radius and costs . (b) Evaluate it at , and and compare with the Hohmann totals , and . (c) At the two totals differ by only . Explain why a finite does not win there.
Show worked solution
(a) As both ellipses have apoapsis speed tending to zero, so . The first burn is from the circular speed to the speed on a very long ellipse with periapsis , which tends to the parabolic speed , so . The third burn is from the speed on the second very long ellipse at radius , , down to the circular speed : . The sum is the stated formula.
(b) : . : . : . All three are below the Hohmann values, by , and , and they match the table in step 3.
(c) At the limit is against Hohmann’s . A finite pays something for not being infinite, and at the total is , which is over the limit and so worse than Hohmann. The saving of is eaten unless is at least .
At the apoapsis of the Hohmann transfer (speed ) we want to end on the circular orbit of radius (speed ) and also turn the orbit plane by . (a) Find the cost of circularising and changing the plane in one burn. (b) Find the cost of changing the plane first at the transfer’s apoapsis speed and then circularising, and of circularising first and then changing the plane. (c) Which is cheaper, and why?
Show worked solution
(a) The burn is the vector difference of the two velocities, which differ in length and direction by : .
(b) A plane change at speed costs . At the transfer speed that is , and the circularisation is the plain Hohmann , a total of . If we circularise first and change plane at the circular speed , the plane change is and the total is .
(c) The combined burn at is cheapest, and the circularise-first order the most expensive. Changing plane at the slow transfer speed is cheaper than at the circular speed, but doing both in one burn is cheaper than either because the two velocity changes are not along the same direction: the vector sum is shorter than the sum of the lengths, by the triangle inequality, with the saving over the cheaper separate order. This is the reason the real GEO insertion burn is combined with the plane change, as in step 3.
(a) Compute the synodic period of Earth and Mars from the two orbital periods and days. (b) The Hohmann flight takes days. Find the lead angle of Mars at departure, in degrees.
Show worked solution
(a) The relative angular rate is per day, so the synodic period is days, about years.
(b) Mars’s mean motion is degrees per day, and in days it advances . The spacecraft sweeps in the same time, so Mars must be ahead of Earth at departure, which matches the value from the closed forms in step 4.
Where the course ends
This is the last lesson, and it is worth saying what the sixteen modules have and have not given you, without pretending the lab above is a mission-planning tool. The lab is a small, checked model, and the checks are the part of it I would defend.
The capstones each took one thread of the course to the end. 16.1 Capstone: 2D Virtual Wind Tunnel and 16.2 Capstone: 6-DOF Flight Simulator with Autopilot were about fluids and flight as simulation problems, 16.3 Capstone: Reaction–Diffusion Pattern Lab about a nonlinear PDE, 16.4 Capstone: Drum & Membrane Mode Synthesizer about an eigenproblem, and this one about conservation. A pattern in all of them is that the result is only as good as its verification: a simulation passes if it conserves what should be conserved, converges at the order it claims, and agrees with an independent calculation where one exists. The most useful habit the course can leave is that, more than any formula in it.
Looking back at what this particular lesson used: the linear algebra of the first module for the Jacobian and the Newton step; the vector calculus of the second for central forces and conserved quantities; first-order and second-order ODEs for the energy method and the oscillator; the numerical methods module for the order and stability analysis of RK4 and the symplectic methods that carry this lesson; the systems and dynamical-systems module for the idea that a conservative flow keeps phase-space volume; the boundary value problems module for shooting; and the fluid, flight and physics modules for the ties to simulation that the callouts make. The Laplace transform, the Fourier series and the classical PDEs of the middle of the course are the ones this lesson used least, and a planner has no use for them. That is a statement about this application and not about the subject.
What the course did not cover, and what you would need next for orbits in particular: perturbation theory and the averaging methods that give the secular effect of and drag; the circular restricted three-body problem and its Lagrange points; low-thrust trajectory optimisation, which is an optimal control problem and a boundary value problem together; and high-precision ephemerides, where the planets are not on circles. For differential equations in general: stochastic differential equations, delay equations, differential-algebraic equations, bifurcation theory beyond the first examples, finite elements and spectral methods in depth, and turbulence modelling. All are built from the same ideas, with different words, and the lessons you have now are the vocabulary for reading them.
Key Takeaways
- The Kepler problem in canonical units () conserves , and the LRL vector, with . They are the test suite for any integrator: measure the drift.
- Symplectic methods (Verlet, Yoshida 4) keep the energy error bounded (Yoshida at , and orbits, , steps per orbit) while RK4 drifts linearly ( to ). A bounded energy error is not a bounded position error: the phase error still grows linearly.
- Measured orders: Verlet error ratio per halving of the step, Yoshida , RK4 about to . At an equal cost of force evaluations per orbit over orbits, Yoshida 4 had the smallest errors ( in energy).
- An orbit of breaks a fixed step ( energy error for Verlet at steps per orbit). A state-dependent step drifts ( at orbits) unless it is made time-symmetric, which bounds it at for about four times the evaluations.
- Vis-viva gives every impulsive burn. Hohmann at costs (units of the circular speed) in time units; the bi-elliptic transfer beats it only above , by up to in the limit, at a cost of hundreds of orbits of flight time. A plane change costs , so combine it with an existing burn at the highest altitude.
- Patched conics for Earth to Mars gives km/s from a km orbit, a lead angle of and a window every days. The textbook burn ignores the potential at the sphere of influence and misses Mars by AU, and km/s brings the miss to AU.
- Lambert’s problem has an exact universal-variable solution with no initial guess ( in ); Newton shooting converges quadratically but only to the answer of its propagator ( for RK4 at , for Verlet at ).
- The model has no perturbations, no finite burns and no third bodies, and its patched-conic constants are from memory. It is a planning sketch with verified arithmetic, not a trajectory design tool.