Appendix D: Math Refresher — Vectors, Calculus, Differential Equations, and Coordinate Frames
This book assumes you once took calculus and a year of physics, and that both are now a little rusty. That is fine. Spaceflight uses a surprisingly small toolkit of mathematics, over and over, and this appendix collects exactly those tools — no more. It is not a course; it is a place to look up the idea behind an equation you have already met in a chapter, refresh the mechanics, and see why rocket science needs it. Each section ends by pointing to the chapters that lean on it. Read what you need and skip what you remember.
D.1 Vectors
A scalar is a single number with units — mass ($m = 500\ \text{kg}$), speed ($v = 7.6\ \text{km/s}$), temperature. A vector carries a number and a direction: position, velocity, acceleration, force, angular momentum. In space almost everything that matters is a vector, because which way a spacecraft is moving or thrusting is as important as how fast or how hard. We write vectors in bold, $\mathbf{r}$, and their magnitudes (lengths) in italic, $r = \lvert\mathbf{r}\rvert$.
A vector is stored as components along three perpendicular axes, $\mathbf{r} = (r_x, r_y, r_z)$ — but those numbers only mean something once you say which set of axes, which is the whole point of §D.4. The core operations:
| Operation | Formula | What it gives you |
|---|---|---|
| Magnitude | $r = \lvert\mathbf{r}\rvert = \sqrt{r_x^2 + r_y^2 + r_z^2}$ | the length (a scalar) |
| Unit vector | $\hat{\mathbf{r}} = \mathbf{r}/r$ | pure direction, length 1 |
| Sum / difference | $\mathbf{a} \pm \mathbf{b} = (a_x \pm b_x,\ a_y \pm b_y,\ a_z \pm b_z)$ | the resultant (tip-to-tail) |
| Scale | $s\,\mathbf{a} = (s\,a_x,\ s\,a_y,\ s\,a_z)$ | stretch, shrink, or flip |
| Dot product | $\mathbf{a}\cdot\mathbf{b} = a_x b_x + a_y b_y + a_z b_z$ | a scalar — see below |
| Cross product | $\mathbf{a}\times\mathbf{b}$ (a vector) | a vector $\perp$ both — see below |
A unit vector is the workhorse for "direction only." Gravity, for instance, points from the spacecraft straight back toward the planet's center — the direction $-\hat{\mathbf{r}}$ — while its strength is a separate scalar, $\mu/r^2$.
The dot product has a geometric meaning worth memorizing:
$$ \mathbf{a}\cdot\mathbf{b} = ab\cos\theta, $$
where $\theta$ is the angle between the two vectors. It measures how aligned they are. It is largest when they point the same way ($\theta = 0$, $\cos\theta = 1$), zero when they are perpendicular ($\theta = 90^\circ$), and negative when they oppose. Because of this, the dot product is how you extract "the part of one vector along another": the radial speed of a spacecraft — how fast its distance $r$ is actually changing — is the velocity projected onto the outward direction, $\dot r = \mathbf{v}\cdot\hat{\mathbf{r}}$. The same projection turns force-along-a-path into work (§D.2).
The cross product produces a vector, perpendicular to both inputs, with magnitude
$$ \lvert\mathbf{a}\times\mathbf{b}\rvert = ab\sin\theta. $$
Its direction follows the right-hand rule (curl your right hand's fingers from $\mathbf{a}$ toward $\mathbf{b}$; your thumb points along $\mathbf{a}\times\mathbf{b}$). Component-by-component,
$$ \mathbf{a}\times\mathbf{b} = \big(a_y b_z - a_z b_y,\ \ a_z b_x - a_x b_z,\ \ a_x b_y - a_y b_x\big). $$
The single most important cross product in this book is specific angular momentum, $\mathbf{h} = \mathbf{r}\times\mathbf{v}$ (units $\text{km}^2/\text{s}$). It points perpendicular to the orbit plane, and for a spacecraft coasting under gravity alone it never changes — gravity pulls straight along $\mathbf{r}$, so it exerts no twist about the center. That single conserved vector is why orbits are flat, and it is developed fully in Chapter 8.
Worked example. A spacecraft is at $\mathbf{r} = (7000,\ 0,\ 0)\ \text{km}$ moving at $\mathbf{v} = (1,\ 7.5,\ 0)\ \text{km/s}$. Then $r = 7000\ \text{km}$ and $v = \sqrt{1^2 + 7.5^2} = 7.57\ \text{km/s}$.
- Dot product: $\mathbf{r}\cdot\mathbf{v} = (7000)(1) + 0 + 0 = 7000\ \text{km}^2/\text{s}$. The radial speed is $\dot r = (\mathbf{r}\cdot\mathbf{v})/r = 1\ \text{km/s}$ — the craft is climbing outward at 1 km/s. Since $\cos\theta = 7000/(7000\cdot 7.57) = 0.132$, the velocity sits $\theta = 82.4^\circ$ from straight-up, i.e. only $7.6^\circ$ above the local horizontal (its flight-path angle $\gamma$).
- Cross product: $\mathbf{h} = \mathbf{r}\times\mathbf{v} = (0,\ 0,\ 7000\cdot 7.5) = (0,\ 0,\ 52{,}500)\ \text{km}^2/\text{s}$. It points along $+z$, normal to the orbit plane (the $xy$-plane), and notice it captured only the sideways (tangential) 7.5 km/s — the radial 1 km/s contributes nothing to angular momentum. Sanity check: a circular orbit at 7000 km would need $v_{\text{circ}} = \sqrt{\mu/r} = 7.55\ \text{km/s}$ and give $h \approx 52{,}800\ \text{km}^2/\text{s}$, so our slightly-slower tangential speed and small climb rate describe a realistic near-circular orbit just past periapsis. $\blacksquare$
Vectors run through the whole book: forces and momentum as vectors in Chapter 2, the energy and angular momentum of an orbit in Chapter 6, and spacecraft orientation in Chapter 14.
D.2 Calculus
Calculus is the mathematics of change and accumulation, which is precisely what a moving, burning rocket is made of.
A derivative is an instantaneous rate of change — the slope of a curve at a point. The chain that defines all of dynamics is just derivatives stacked on derivatives: velocity is the rate of change of position, and acceleration is the rate of change of velocity,
$$ \mathbf{v} = \frac{d\mathbf{r}}{dt} = \dot{\mathbf{r}}, \qquad \mathbf{a} = \frac{d\mathbf{v}}{dt} = \dot{\mathbf{v}} = \ddot{\mathbf{r}}. $$
The overdot is Newton's shorthand for "derivative with respect to time"; one dot for a rate, two dots for a rate-of-a-rate. Newton's second law then reads $\mathbf{a} = \mathbf{F}/m$, an equation about a derivative — the seed of every trajectory in §D.3.
An integral is the reverse: it accumulates a rate over an interval to give a total. If you know a rocket's thrust $F(t)$ over a burn, the area under that curve is the total impulse it delivered, $I_t = \int F\,dt$; the accumulated velocity change is $\Delta v = \int (F/m)\,dt$. Integration is how you get from "how hard, moment by moment" to "how much, in the end."
The handful of derivative and integral facts the book actually uses:
| Rule | Derivative | Integral |
|---|---|---|
| Power | $\dfrac{d}{dx}x^n = n\,x^{n-1}$ | $\displaystyle\int x^n\,dx = \dfrac{x^{n+1}}{n+1}\ \ (n \neq -1)$ |
| Reciprocal / logarithm | $\dfrac{d}{dx}\ln x = \dfrac{1}{x}$ | $\displaystyle\int \frac{dx}{x} = \ln\lvert x\rvert$ |
| Exponential | $\dfrac{d}{dx}e^{x} = e^{x}$ | $\displaystyle\int e^{x}\,dx = e^{x}$ |
| Sine / cosine | $\dfrac{d}{dx}\sin x = \cos x$ | $\displaystyle\int \cos x\,dx = \sin x$ |
| Chain rule | $\dfrac{d}{dx}f\big(g(x)\big) = f'(g)\,g'(x)$ | (its reverse is $u$-substitution) |
That reciprocal-integral row is the mathematical heart of the whole enterprise. In deriving the rocket equation, Chapter 3 reaches the step $m\,dv = -v_e\,dm$, separates the variables, and integrates:
$$ \int_0^{\Delta v} dv = -v_e \int_{m_0}^{m_f} \frac{dm}{m} \quad\Longrightarrow\quad \Delta v = v_e \ln\!\left(\frac{m_0}{m_f}\right). $$
The logarithm — and with it the exponential tyranny that every design choice in this book answers to — is nothing more mysterious than "the integral of $1/m$." The other integral the book leans on is work: force accumulated along a path, $W = \int \mathbf{F}\cdot d\mathbf{r}$ (note the dot product — only the force component along the motion does work). Setting that equal to the change in kinetic energy gives the work–energy theorem behind the vis-viva equation in Chapter 6, and integrating gravity's inverse-square force from infinity inward gives the gravitational potential energy $-\mu m/r$.
A note on analytic vs. numerical. The results above are analytic — closed-form formulas you can evaluate by hand. They exist because the situations are idealized (constant exhaust velocity; a single spherical gravity source). Add air drag, a thrust that varies, a second gravitating body, or the bulge of a real planet, and the integrals usually have no closed form at all. Then you integrate numerically, adding up tiny steps by computer — the subject of §D.3.
D.3 Differential equations
A differential equation relates an unknown function to its own derivatives. "The acceleration of this spacecraft is set by where it is" is a sentence about a function ($\mathbf{r}(t)$) and its second derivative ($\ddot{\mathbf{r}}$) — a differential equation. Solving one means finding the actual function that satisfies it, which requires initial conditions: where the spacecraft is and how fast it is moving right now. Same equation, different starting state, different orbit.
You have already met the most important one. Combining Newton's second law with his law of gravitation — the acceleration is the gravitational force per unit mass, directed inward — gives the two-body equation of motion, the master equation of orbital mechanics:
$$ \ddot{\mathbf{r}} = -\,\frac{\mu}{r^3}\,\mathbf{r}. $$
Read it piece by piece. The left side is acceleration (a second derivative — so this is a second-order vector ODE). On the right, $\mu = GM$ is the central body's gravitational parameter (Earth: $3.986\times10^{5}\ \text{km}^3/\text{s}^2$); the factor $-\mathbf{r}/r^3 = -\hat{\mathbf{r}}/r^2$ says the pull points inward ($-\hat{\mathbf{r}}$) and weakens as the inverse square of distance ($1/r^2$). That one line, solved analytically, is Kepler's ellipse; it is the foundation of Chapter 8.
The clean solution exists only for two point masses alone in the universe. Add drag, thrust, the Moon's pull, or Earth's oblateness and the closed form vanishes — so real trajectories are almost always integrated numerically. The recipe is always the same. First, flatten the second-order equation into a first-order system by stacking position and velocity into a single six-element state vector $\mathbf{y} = (\mathbf{r}, \mathbf{v})$:
$$ \dot{\mathbf{y}} = \frac{d}{dt}\begin{bmatrix}\mathbf{r}\\ \mathbf{v}\end{bmatrix} = \begin{bmatrix}\mathbf{v}\\ -\,\mu\,\mathbf{r}/r^3\end{bmatrix}. $$
The top three rows are a definition ("position changes at the rate given by velocity"); the bottom three are the physics. A numerical integrator only ever needs this: a function that, given the current state, returns its rate of change.
- Euler's method is the simplest possible integrator: evaluate the slope now, and take a small step $\Delta t$ straight along it, $\mathbf{y}_{n+1} = \mathbf{y}_n + \Delta t\,\dot{\mathbf{y}}_n$. Repeat. It works, but it is only first-order accurate — for an orbit it slowly spirals outward (spuriously gaining energy) unless $\Delta t$ is tiny. It is the right way to understand numerical integration and the wrong way to do it seriously.
- Runge–Kutta (RK4) is the standard workhorse. Instead of trusting the slope at the start of the step, it samples the slope four times — once at the beginning ($k_1$), twice at the midpoint ($k_2$ then $k_3$), once at the end ($k_4$) — and steps with the weighted average $\tfrac{\Delta t}{6}(k_1 + 2k_2 + 2k_3 + k_4)$. That extra bookkeeping buys fourth-order accuracy: halving the step size cuts the error roughly sixteen-fold. The details are not worth memorizing; the idea — look ahead before you leap — is.
In practice you never hand-code these. You hand the derivative function and the initial state to an
adaptive integrator such as scipy.integrate.solve_ivp (introduced in Appendix C), which chooses its own
step sizes to meet a requested tolerance. That single routine is how
Chapter 11,
Chapter 12, and
Chapter 13 propagate real
trajectories that no formula can capture.
D.4 Coordinate frames and rotations
A vector is a physical thing — an arrow in space — but its components $(r_x, r_y, r_z)$ are just its shadows on a particular set of axes. Change the axes and the three numbers change, even though the arrow did not move. So a list of components is meaningless until you name the reference frame it belongs to. Getting frames straight is not pedantry; mixing them up is a classic way to lose a spacecraft.
One distinction dominates: an inertial frame is not accelerating or rotating, and Newton's laws (hence the two-body equation of §D.3) hold in it directly. A frame bolted to the spinning Earth is not inertial, and using it naïvely introduces fictitious forces (centrifugal, Coriolis). The four frames this book uses:
| Frame | Origin | Axes fixed to | Used for |
|---|---|---|---|
| ECI — Earth-Centered Inertial | Earth's center | the stars ($x \to$ vernal equinox, $z \to$ spin axis, $xy$ = equator) | integrating orbits; the frame Newton's laws hold in |
| ECEF — Earth-Centered Earth-Fixed | Earth's center | the rotating Earth ($x \to$ Greenwich meridian) | ground stations, launch sites, latitude/longitude, ground tracks |
| Perifocal (PQW) | central body | one specific orbit ($x \to$ periapsis, $z \to \mathbf{h}$) | the natural frame in which a single orbit's geometry is simplest |
| Body | spacecraft center of mass | the vehicle itself (roll / pitch / yaw) | attitude, and where sensors, antennas, and thrusters point |
ECI and ECEF share an origin and a $z$-axis and differ only by Earth's rotation about that axis: convert between them by rotating through the Earth-rotation angle since a reference epoch. The perifocal frame is where the six orbital elements do their work — they are precisely the recipe for rotating an orbit described simply in its own PQW plane into the shared ECI frame (Chapter 8). The body frame is the subject of attitude control: a spacecraft's attitude is just the orientation of its body frame relative to a reference frame, and pointing a camera or a thruster means commanding that relationship.
Rotating between frames is done with a $3\times3$ rotation matrix (also called a direction-cosine matrix). To re-express a vector's components in a frame turned by angle $\theta$ about a shared $z$-axis, multiply by
$$ R_z(\theta) = \begin{bmatrix} \cos\theta & \sin\theta & 0 \\ -\sin\theta & \cos\theta & 0 \\ 0 & 0 & 1 \end{bmatrix}. $$
For example, a point on the $+x$ axis, $\mathbf{r} = (7000, 0, 0)\ \text{km}$, viewed from a frame rotated $+90^\circ$ about $z$ (so $\cos\theta = 0$, $\sin\theta = 1$), has components $R_z(90^\circ)\,\mathbf{r} = (0,\ -7000,\ 0)\ \text{km}$ — same arrow, new shadows. Rotation matrices have two properties you will use constantly: they are orthonormal (each row is a unit vector, mutually perpendicular), so the inverse rotation is simply the transpose, $R^{-1} = R^{\mathsf{T}}$; and you compose successive rotations by multiplying their matrices (order matters — 3-D rotations do not commute). Full rotations about arbitrary axes chain three such matrices; sign and order conventions are stated explicitly wherever the book uses them.
Rotation matrices are exact but clumsy for a spacecraft tumbling continuously in three dimensions: representing orientation with three angles suffers "gimbal lock" (a lost degree of freedom), and the nine matrix entries carry six redundant constraints. For that reason spacecraft attitude is tracked with quaternions — a compact, singularity-free four-number encoding of a rotation — introduced in Chapter 14 and used by the guidance and control loops of Chapter 27.
Where to go deeper. This appendix is deliberately thin — just enough to read the chapters without stumbling. Each idea is developed with full physical motivation where the book first needs it: vectors and Newton's laws in Chapters 2 and 6, the calculus of the rocket equation in Chapter 3, the two-body differential equation in Chapter 8, and frames and rotations across Chapters 8, 13, 14, and 27. The symbols used here are catalogued in Appendix A; the constants ($\mu$, radii, standard gravity) are in Appendix B; and the Python that turns these formulas into working code is in Appendix C, with the complete
astrotoolspackage in Appendix I.