P01.06 · Lesson 06 of 18

Parametric Curves & Polar Coordinates

A curve is a function of one parameter; choose the parameter that makes the physics simple.

computational Time unmeasured

Build it Plot a conic orbit from r(θ)

Learning outcomes
  1. Derive the polar equation of a conic, its periapsis and apoapsis, and the formulas for arc length, swept area and slope of a curve given in polar or parametric form.
  2. Implement and test a conic-orbit module: radius, derivative, Cartesian points, Simpson integration of area and arc length, time of flight from Kepler's second law, and speed from the parametric derivatives.
  3. Measure, by computational experiment, how the time an orbit spends near apoapsis grows with eccentricity and how fast Simpson's rule converges.
  4. Decide, from a stated tolerance, how many panels an arc-length or time-of-flight integral needs.
Prerequisites

P01.01–P01.04 (derivatives, chain rule, integrals, substitution), P00.03 (NumPy), P00.04 (Matplotlib). Skill check: you can differentiate sin⁡θ/(1+ecos⁡θ)\sin\theta/(1 + e\cos\theta) with the quotient rule and you know ∫dθ=θ\int \mathrm{d}\theta = \theta and ∫cos⁡θ dθ=sin⁡θ\int \cos\theta\,\mathrm{d}\theta = \sin\theta.

Engineering question

Given the periapsis and apoapsis of a transfer orbit, what is its shape, how fast does the spacecraft move at every point, how long does it take from periapsis to apoapsis, and how do we know those numbers are right?

Full lesson specification (11 more items)
Assumptions and limits

Two bodies only; the central body is a point mass (or spherically symmetric); the spacecraft's mass is negligible; no drag, no thrust, no third body, no oblateness. Then the path is exactly a conic with the attracting centre at one focus. The model fails when the periapsis dips into the atmosphere (below about 150 km for Earth), when Earth's equatorial bulge (J2J_2) rotates the orbit by a fraction of a degree per day, and when the Moon or Sun pull on a high apoapsis.

Analytical work

Conic in polar form; periapsis, apoapsis, semi-major axis; dr/dθ\mathrm{d}r/\mathrm{d}\theta; area and arc length in polar coordinates; velocity components and speed from the parametric derivatives; Kepler's second and third laws from the area formula; a hand calculation for a geostationary transfer orbit.

Computational deliverable

starter/main.py: conic_radius, conic_radius_derivative, true_anomaly_limit, polar_to_cartesian, periapsis_apoapsis, semi_major_axis, conic_from_apsides, orbit_points, simpson, polar_arc_length, sector_area, specific_angular_momentum, time_of_flight, orbital_period, orbital_speed, vis_viva_speed, flight_path_angle, ellipse_parametric, arc_length_convergence. Tests prove: the circle and parabola limits, symmetry about the apse line, the asymptote of an open conic, the full swept area equals πab\pi ab, the perimeter equals 4aE(e2)4aE(e^2) from SciPy, the parametric ellipse lies on the polar conic, the speed from the parametric derivatives equals the vis-viva speed, the swept-area time of one revolution equals Kepler's third-law period, and Simpson converges at fourth order.

Practical activity

computational experiment: sweep the eccentricity and measure the fraction of the period spent in the apoapsis half of the orbit; measure Simpson's convergence for arc length and time of flight and pick a panel count for a 1 s tolerance.

Equipment

None. A computer with the environment from P00.01.

Safety

None beyond normal computer use.

Evidence

Completed main.py, passing tests, conic_orbits.png, the hand calculation for the transfer orbit with its comparison to the code, the eccentricity-sweep table and the convergence table.

Assessment

assessments/phase-01/grading-rubric.md; competencies 1–4. Pass: the area and arc-length formulas derived with every step named; all public tests pass; the hand calculation agrees with the code to four significant figures; the convergence experiment reports an observed order with a number.

References

@openstax-calculus-volume-2 §7.1 "Parametric Equations" and §7.2 "Calculus of Parametric Curves" (required-free); @openstax-calculus-volume-2 §7.3 "Polar Coordinates" and §7.4 "Area and Arc Length in Polar Coordinates" (required-free); @openstax-calculus-volume-2 §7.5 "Conic Sections" (required-free); @openstax-calculus-volume-3 Chapter 1 repeats the same material as §1.1–1.5 (supplementary-free).

Extensions

★ Solve Kepler's equation M=E−esin⁡EM = E - e\sin E with Newton's method (P01.02) and compare the true anomaly at t=T/4t = T/4 with the swept-area integral. ★ Add the J2J_2 secular rates and show how many days it takes the transfer orbit's perigee to drift by 1°.

Time

unmeasured

1. The engineering problem

A communications satellite is launched into a circular parking orbit 300 km above the Earth and must reach the geostationary radius of 42 164 km. The cheapest way is a transfer ellipse whose periapsis (closest point to the Earth's centre) touches the parking orbit and whose apoapsis (farthest point) touches the geostationary circle. Before the mission team can size the engine burns and plan the tracking passes they need the shape of that ellipse, the speed at both ends, the time from periapsis to apoapsis, and the direction of the velocity at every point. Get the coast time wrong by a minute and the circularisation burn fires in the wrong place; get the flight-path angle wrong and the burn points in the wrong direction.

The mathematics is a single curve described two ways. In polar coordinates (r,θ)(r, \theta) with the Earth's centre at the origin, the orbit is r=p/(1+ecos⁡θ)r = p/(1 + e\cos\theta), one equation with two numbers. In parametric form the same curve is x(t),y(t)x(t), y(t), position as a function of time, which is what a tracking station sees. This lesson is about moving between those descriptions and doing calculus in each: slopes, arc length, swept area, speed. The payoff is Kepler's second law, which falls out of the polar area formula in two lines and gives the time of flight.

Success criteria, written before we start: the code reproduces the periapsis and apoapsis exactly; the swept area of a full revolution equals πab\pi ab to one part in 10810^8; the time of one revolution computed by integrating the swept area equals 2πa3/μ2\pi\sqrt{a^3/\mu} to the same precision; the speed computed from the parametric derivatives equals the energy-based vis-viva speed at every point; and the arc-length integral converges at fourth order so that 64 panels give the perimeter of the transfer ellipse to better than 1 m.

2. Understand and derive

2.1 Polar coordinates and the conic

A point in the plane is (x,y)(x, y) or, equally, (r,θ)(r, \theta) with x=rcos⁡θx = r\cos\theta, y=rsin⁡θy = r\sin\theta, r=x2+y2r = \sqrt{x^2 + y^2} and θ=atan2⁡(y,x)\theta = \operatorname{atan2}(y, x) (@openstax-calculus-volume-2 §7.3). A curve in polar form is r=f(θ)r = f(\theta): one function of one variable. In orbital mechanics θ\theta is called the true anomaly and is measured from the periapsis direction.

A conic section is the set of points whose distance to a fixed point (the focus) is ee times its distance to a fixed line (the directrix), with e≥0e \ge 0 the eccentricity (§7.5). Put the focus at the origin and the directrix at x=−dx = -d (to the left of the focus): the distance to the focus is rr, the distance to the directrix is d+rcos⁡θd + r\cos\theta, and the definition r=e (d+rcos⁡θ)r = e\,(d + r\cos\theta) solves to

r(θ)=p1+ecos⁡θ,p=e d[m].(1)r(\theta) = \frac{p}{1 + e\cos\theta}, \qquad p = e\,d \quad [\mathrm{m}]. \tag{1}

The constant pp is the semi-latus rectum, the radius at θ=±90°\theta = \pm 90° (cos⁡θ=0\cos\theta = 0 gives r=pr = p regardless of ee), which is why the figure in part 3 draws all four conics with the same pp: they all pass through the same two points above and below the focus.

Focus–directrix construction: the focus F (Earth’s centre) at the origin, the directrix the vertical line x = −d, and a point P = (r, θ) at distance r from F at polar angle θ; the horizontal distance from P to the directrix is d + r cos θ.
Figure 1. The focus–directrix definition. A conic is the set of points P whose distance r to the focus is e times their distance d + r cos θ to the directrix.

The shape depends on ee alone (@openstax-calculus-volume-2 §7.5):

ee curve 1+ecos⁡θ1 + e\cos\theta range of θ\theta
0 circle, r=pr = p always 1 all
0<e<10 < e < 1 ellipse always >0> 0 all; the curve closes
1 parabola →0\to 0 as θ→±π\theta \to \pm\pi −π<θ<π-\pi < \theta < \pi
>1> 1 hyperbola (one branch) =0= 0 at cos⁡θ∞=−1/e\cos\theta_\infty = -1/e $

For e≥1e \ge 1 the denominator reaches zero and r→∞r \to \infty: those are the asymptotes, the directions a flyby spacecraft arrives from and departs to. Our code refuses to evaluate (1) at or beyond them rather than returning infinities that would poison a plot.

2.2 Apsides and axes

Assumption 1 (periapsis at θ=0\theta = 0): we measure θ\theta from the point of closest approach. The denominator of (1) is largest at θ=0\theta = 0 and smallest at θ=π\theta = \pi, so for an ellipse

rp=p1+e(periapsis),ra=p1−e(apoapsis).(2)r_p = \frac{p}{1 + e} \quad (\text{periapsis}), \qquad r_a = \frac{p}{1 - e} \quad (\text{apoapsis}). \tag{2}

Adding them gives the major axis 2a=rp+ra2a = r_p + r_a, hence a=p/(1−e2)a = p/(1 - e^2); subtracting gives ra−rp=2aer_a - r_p = 2ae, so the centre of the ellipse sits a distance aeae from the focus. Inverting (2) is how a mission planner starts: from the two radii,

e=ra−rpra+rp,p=rp(1+e).(3)e = \frac{r_a - r_p}{r_a + r_p}, \qquad p = r_p(1 + e). \tag{3}

The semi-minor axis is b=a1−e2b = a\sqrt{1 - e^2} (set x=−aex = -ae in the Cartesian ellipse equation; or see §7.5). For the transfer orbit, rp=6378.1+300=6678.1r_p = 6378.1 + 300 = 6678.1 km and ra=42 164.0r_a = 42\,164.0 km:

e=(42 164.0−6678.1)/(42 164.0+6678.1)=35 485.9/48 842.1=0.72654e = (42\,164.0 - 6678.1)/(42\,164.0 + 6678.1) = 35\,485.9/48\,842.1 = 0.72654; p=6678.1×1.72654=11 530.1p = 6678.1 \times 1.72654 = 11\,530.1 km; a=24 421.1a = 24\,421.1 km; b=24 421.11−0.726542=16 780.3b = 24\,421.1\sqrt{1 - 0.72654^2} = 16\,780.3 km. The centre of the ellipse is ae=17 742.9ae = 17\,742.9 km from the Earth's centre: more than two Earth radii on the far side of the planet. Keep that picture: a transfer ellipse is nothing like a circle with the Earth in the middle.

2.3 The slope of a polar curve: the flight-path angle

A polar curve is a parametric curve with parameter θ\theta: x(θ)=r(θ)cos⁡θx(\theta) = r(\theta)\cos\theta, y(θ)=r(θ)sin⁡θy(\theta) = r(\theta)\sin\theta. By the chain rule (@openstax-calculus-volume-2 §7.2),

dydx=dy/dθdx/dθ=r′sin⁡θ+rcos⁡θr′cos⁡θ−rsin⁡θ,r′=drdθ.(4)\frac{\mathrm{d}y}{\mathrm{d}x} = \frac{\mathrm{d}y/\mathrm{d}\theta}{\mathrm{d}x/\mathrm{d}\theta} = \frac{r'\sin\theta + r\cos\theta}{r'\cos\theta - r\sin\theta}, \qquad r' = \frac{\mathrm{d}r}{\mathrm{d}\theta}. \tag{4}

Differentiating (1) with the quotient rule (the numerator is constant, so only the denominator contributes):

r′(θ)=p esin⁡θ(1+ecos⁡θ)2=r2esin⁡θp.(5)r'(\theta) = \frac{p\,e\sin\theta}{(1 + e\cos\theta)^2} = \frac{r^2 e\sin\theta}{p}. \tag{5}

Units: metres per radian. r′=0r' = 0 at θ=0\theta = 0 and θ=π\theta = \pi: the apsides are where the radius stops changing, as the name says. Rather than the slope relative to the xx axis, orbital mechanics uses the flight-path angle γ\gamma, the angle between the velocity and the local horizontal (the direction perpendicular to rr). The velocity's radial component is proportional to r′r' and its horizontal component to rr (one radian of θ\theta moves the point by rr metres sideways), so

tan⁡γ=r′r=esin⁡θ1+ecos⁡θ.(6)\tan\gamma = \frac{r'}{r} = \frac{e\sin\theta}{1 + e\cos\theta}. \tag{6}

γ=0\gamma = 0 at both apsides (the velocity is horizontal there, which is why apsis burns are the efficient ones) and positive from periapsis to apoapsis (climbing). At θ=90°\theta = 90° on the transfer orbit, tan⁡γ=e=0.72654\tan\gamma = e = 0.72654, so γ=36.00°\gamma = 36.00°.

2.4 Area in polar coordinates, and Kepler's second law

Split the region swept by the radius vector between θ0\theta_0 and θ1\theta_1 into thin sectors of angle Δθ\Delta\theta. Each is almost a circular sector of radius r(θ)r(\theta) and area 12r2Δθ\tfrac12 r^2 \Delta\theta (a circular sector of angle Δθ\Delta\theta is the fraction Δθ/2π\Delta\theta/2\pi of a disc of area πr2\pi r^2). Summing and letting Δθ→0\Delta\theta \to 0 (@openstax-calculus-volume-2 §7.4):

A=12∫θ0θ1r(θ)2 dθ.(7)A = \frac12\int_{\theta_0}^{\theta_1} r(\theta)^2\,\mathrm{d}\theta. \tag{7}

Units: m² rad = m² (the radian is dimensionless). For a circle, A=12p2⋅2π=πp2A = \tfrac12 p^2 \cdot 2\pi = \pi p^2. ✓

Now let θ\theta depend on time. The rate at which area is swept is, by the chain rule and the fundamental theorem,

dAdt=12r2 dθdt.(8)\frac{\mathrm{d}A}{\mathrm{d}t} = \frac12 r^2\,\frac{\mathrm{d}\theta}{\mathrm{d}t}. \tag{8}

Assumption 2 (central force): gravity pulls straight toward the focus, so it exerts no torque about it, and the specific angular momentum h=r2 dθ/dth = r^2\,\mathrm{d}\theta/\mathrm{d}t (m²/s) is constant. (This is Newton's law applied to a central force; you will prove it with the cross product in P01.07. Here we take it as given.) Then dA/dt=h/2\mathrm{d}A/\mathrm{d}t = h/2 is constant: equal areas in equal times, Kepler's second law, is nothing more than the polar area formula plus conservation of angular momentum. Consequently the time to move from θ0\theta_0 to θ1\theta_1 is

t01=2h A01=1h∫θ0θ1r2 dθ.(9)t_{01} = \frac{2}{h}\,A_{01} = \frac{1}{h}\int_{\theta_0}^{\theta_1} r^2\,\mathrm{d}\theta. \tag{9}

For a conic, hh and pp are tied together: h=μph = \sqrt{\mu p}, where μ=GM\mu = GM is the central body's gravitational parameter (3.986 004 418×10143.986\,004\,418 \times 10^{14} m³/s² for Earth). You will derive this from Newton's law in Phase 09; in this lesson it is the one fact imported from physics, and we check it rather than derive it: with it, the time for a full revolution is (2/h)πab(2/h)\pi ab, and

T=2πabμp=2πa⋅a1−e2μa(1−e2)=2πa3μ,(10)T = \frac{2\pi ab}{\sqrt{\mu p}} = \frac{2\pi a \cdot a\sqrt{1 - e^2}}{\sqrt{\mu a (1 - e^2)}} = 2\pi\sqrt{\frac{a^3}{\mu}}, \tag{10}

which is Kepler's third law. If the code's area integral and (10) disagree, either the integration or the imported hh is wrong; they agree to 10−910^{-9}, which is one of the tests.

2.5 Arc length in polar and parametric form

For a parametric curve the arc length is ∫(dx/dt)2+(dy/dt)2 dt\int\sqrt{(\mathrm{d}x/\mathrm{d}t)^2 + (\mathrm{d}y/\mathrm{d}t)^2}\,\mathrm{d}t (§7.2): the distance travelled is the integral of the speed. With θ\theta as parameter, dx/dθ=r′cos⁡θ−rsin⁡θ\mathrm{d}x/\mathrm{d}\theta = r'\cos\theta - r\sin\theta and dy/dθ=r′sin⁡θ+rcos⁡θ\mathrm{d}y/\mathrm{d}\theta = r'\sin\theta + r\cos\theta; square and add, and the cross terms cancel (cos⁡2+sin⁡2=1\cos^2 + \sin^2 = 1):

L=∫θ0θ1r2+r′2 dθ.(11)L = \int_{\theta_0}^{\theta_1}\sqrt{r^2 + r'^2}\,\mathrm{d}\theta. \tag{11}

For a circle r′=0r' = 0 and L=2πpL = 2\pi p. ✓ For an ellipse the integral has no elementary antiderivative; it defines the complete elliptic integral of the second kind, and the perimeter is 4aE(e2)4aE(e^2), which SciPy provides as scipy.special.ellipe. That gives us an independent reference to compare our numerical integration against.

2.6 Speed from the parametric derivatives

Position as a function of time is x=rcos⁡θx = r\cos\theta, y=rsin⁡θy = r\sin\theta with r=r(θ(t))r = r(\theta(t)). The velocity components along and across the radius are r˙\dot r and rθ˙r\dot\theta (dot = d/dt\mathrm{d}/\mathrm{d}t). Using θ˙=h/r2\dot\theta = h/r^2 from assumption 2 and (5):

r˙=r′θ˙=r2esin⁡θp⋅hr2=hp esin⁡θ,rθ˙=hr=hp(1+ecos⁡θ).(12)\dot r = r'\dot\theta = \frac{r^2 e\sin\theta}{p}\cdot\frac{h}{r^2} = \frac{h}{p}\,e\sin\theta, \qquad r\dot\theta = \frac{h}{r} = \frac{h}{p}(1 + e\cos\theta). \tag{12}

Both are remarkably simple: the radial speed is a pure sine and the transverse speed a shifted cosine. The speed is the root of the sum of squares:

v=hpe2sin⁡2θ+1+2ecos⁡θ+e2cos⁡2θ=hp1+2ecos⁡θ+e2.(13)v = \frac{h}{p}\sqrt{e^2\sin^2\theta + 1 + 2e\cos\theta + e^2\cos^2\theta} = \frac{h}{p}\sqrt{1 + 2e\cos\theta + e^2}. \tag{13}

At periapsis vp=(h/p)(1+e)=h/rpv_p = (h/p)(1 + e) = h/r_p and at apoapsis va=h/rav_a = h/r_a: with γ=0\gamma = 0 the whole speed is transverse and rv=hr v = h. For the transfer orbit, h=3.986×1014×1.1530×107=6.7793×1010h = \sqrt{3.986 \times 10^{14} \times 1.1530 \times 10^7} = 6.7793 \times 10^{10} m²/s, so vp=6.7793×1010/6.6781×106=10 151v_p = 6.7793 \times 10^{10}/6.6781 \times 10^6 = 10\,151 m/s and va=6.7793×1010/4.2164×107=1608v_a = 6.7793 \times 10^{10}/4.2164 \times 10^7 = 1608 m/s. The spacecraft is six times faster at the bottom of the ellipse than at the top. Sanity check: circular speed in the parking orbit is μ/rp=7726\sqrt{\mu/r_p} = 7726 m/s, so the first burn adds 2425 m/s, the textbook figure for a geostationary transfer injection.

The vis-viva equation v2=μ(2/r−1/a)v^2 = \mu(2/r - 1/a) comes from energy conservation, a completely different route. At θ=90°\theta = 90° it gives v=3.986×1014(2/1.1530×107−1/2.4421×107)=7268v = \sqrt{3.986 \times 10^{14}(2/1.1530 \times 10^7 - 1/2.4421 \times 10^7)} = 7268 m/s, and (13) gives (h/p)1+e2=5879.6×1.2360=7268(h/p)\sqrt{1 + e^2} = 5879.6 \times 1.2360 = 7268 m/s. Two derivations, one number: the parametric calculus and the energy argument agree at every θ\theta, which is a test.

2.7 The ellipse as a parametric curve in its own right

An ellipse can also be written without the focus: centred at the origin, x=acos⁡Ex = a\cos E, y=bsin⁡Ey = b\sin E with the parameter EE (the eccentric anomaly) running from 0 to 2π2\pi. Shift the centre so the focus is at the origin (x→x−aex \to x - ae):

x=a(cos⁡E−e),y=a1−e2 sin⁡E.(14)x = a(\cos E - e), \qquad y = a\sqrt{1 - e^2}\,\sin E. \tag{14}

Every point of (14) satisfies (1) with θ=atan2⁡(y,x)\theta = \operatorname{atan2}(y, x); proving it is Problem 2(d), and the code tests it numerically. The two parameters are different clocks for the same curve: θ\theta makes the radius simple, EE makes the time simple (Kepler's equation M=E−esin⁡EM = E - e\sin E in the extension). Choosing the parameter is choosing which calculation is easy.

2.8 Where the model stops being valid

  • Atmospheric drag. At a 300 km periapsis the air density is about 2×10−112 \times 10^{-11} kg/m³; each pass costs a few metres per second over months, lowering apoapsis. Below 150 km the orbit decays within days.
  • Earth's oblateness (J2J_2). The equatorial bulge makes the orbit plane and the periapsis direction precess; for this transfer orbit at 27° inclination the periapsis drifts about 0.6° per day and the node 0.36° per day. The conic is exact only instant by instant.
  • Third bodies. A 42 164 km apoapsis is a ninth of the way to the Moon; lunar and solar gravity perturb it at the 10−510^{-5} level per orbit, invisible here, decisive over years.
  • Finite burns. We model the transfer as a coast between two impulses; a real burn lasting minutes changes the geometry slightly.

3. Build the computational model

Open starter/main.py. Every function is vectorized over θ\theta with NumPy and raises ValueError on nonsense input, following P00.03.

Step 1: the conic and its derivative

def conic_radius(theta, p, e):
    _check_conic(p, e)                       # p > 0, e >= 0, both finite
    th = np.asarray(theta, dtype=float)
    denom = 1.0 + e * np.cos(th)
    if np.any(denom <= 0.0):
        raise ValueError("theta lies on or beyond the asymptote of an open conic")
    r = p / denom
    return float(r) if r.ndim == 0 else r

def conic_radius_derivative(theta, p, e):
    ...
    return p * e * np.sin(th) / denom**2     # equation (5)

def true_anomaly_limit(e):
    return float(np.pi) if e < 1.0 else float(np.arccos(-1.0 / e))

periapsis_apoapsis, semi_major_axis and conic_from_apsides are equations (2) and (3); polar_to_cartesian and orbit_points turn a θ\theta grid into (x,y)(x, y) arrays for plotting, with orbit_points stopping at 95 % of the asymptote angle for an open conic.

Step 2: composite Simpson's rule

def simpson(f, a, b, n):
    if n < 2 or n % 2:
        raise ValueError("n must be an even integer >= 2")
    x = np.linspace(a, b, n + 1)
    y = np.asarray(f(x), dtype=float)
    h = (b - a) / n
    return float(h / 3.0 * (y[0] + y[-1] + 4.0 * y[1:-1:2].sum() + 2.0 * y[2:-1:2].sum()))

Simpson's rule fits a parabola through each pair of panels; its error is −(b−a)h4f(4)(ξ)/180-(b - a)h^4 f^{(4)}(\xi)/180, so halving hh divides the error by 16 (fourth order). It is exact for cubics, which is the first test. The slice y[1:-1:2] picks the odd-indexed points (weight 4) and y[2:-1:2] the interior even ones (weight 2): no loop, as in P00.03.

Step 3: area, arc length, time

def sector_area(p, e, theta0, theta1, n=400):
    return simpson(lambda th: 0.5 * conic_radius(th, p, e) ** 2, theta0, theta1, n)   # (7)

def polar_arc_length(p, e, theta0, theta1, n=400):
    def integrand(th):
        r = conic_radius(th, p, e)
        return np.sqrt(r**2 + conic_radius_derivative(th, p, e) ** 2)           # (11)
    return simpson(integrand, theta0, theta1, n)

def specific_angular_momentum(p, mu=MU_EARTH):
    return float(np.sqrt(mu * p))

def time_of_flight(p, e, theta0, theta1, mu=MU_EARTH, n=400):
    return 2.0 * sector_area(p, e, theta0, theta1, n) / specific_angular_momentum(p, mu)   # (9)

def orbital_period(p, e, mu=MU_EARTH):
    a = semi_major_axis(p, e)
    return float(2.0 * np.pi * np.sqrt(a**3 / mu))                                   # (10)

Step 4: velocity from the parametric derivatives

def orbital_speed(theta, p, e, mu=MU_EARTH):
    h = specific_angular_momentum(p, mu)
    return h / p * np.sqrt(1.0 + 2.0 * e * np.cos(theta) + e**2)      # (13)

def vis_viva_speed(r, a, mu=MU_EARTH):
    inv_a = 0.0 if np.isinf(a) else 1.0 / a                          # parabola: a = inf
    return np.sqrt(mu * (2.0 / r - inv_a))

def flight_path_angle(theta, e):
    return np.arctan2(e * np.sin(theta), 1.0 + e * np.cos(theta))     # (6)

np.arctan2(y, x) instead of np.arctan(y/x) keeps the sign right in every quadrant and never divides by zero. ellipse_parametric is equation (14) and arc_length_convergence measures the Simpson error over [0,π/2][0, \pi/2] against scipy.integrate.quad at 10−1310^{-13} relative tolerance.

Verify

Run python -m pytest curriculum/phase-01/lesson-06-parametric-and-polar from the repo root. The tests, in order of how much they would hurt if wrong:

  1. Limiting cases. e=0e = 0 gives r=pr = p, r′=0r' = 0, γ=0\gamma = 0 everywhere; e=1e = 1 gives v=2μ/rv = \sqrt{2\mu/r} (escape speed) at every point; e=2e = 2 has its asymptote at 120°120°.
  2. Geometry. r(0)=rpr(0) = r_p, r(π)=rar(\pi) = r_a, r(π/2)=pr(\pi/2) = p; the curve is symmetric about the apse line; the parametric ellipse (14) lies on the polar conic (1) with its centre at −ae-ae.
  3. Integrals against closed forms. Full swept area =πab= \pi ab; perimeter =4aE(e2)= 4aE(e^2); Simpson exact for a cubic and fourth-order on exe^x; arc length ≥\ge chord.
  4. Physics identities. vv from (13) equals vis-viva at 37 angles to 10−1210^{-12}; rpvp=rava=hr_p v_p = r_a v_a = h; a two-point finite difference of (x(t),y(t))(x(t), y(t)) with Δθ=h Δt/r2\Delta\theta = h\,\Delta t/r^2 reproduces the speed to 10−510^{-5}; the area-integral time of one revolution equals (10); T∝a3/2T \propto a^{3/2}.
  5. Interface. Invalid pp, ee, odd panel counts and angles beyond the asymptote raise ValueError; main() writes the figure.

Compare

Two library oracles stand in for an "established tool". scipy.special.ellipe(e**2) gives the perimeter 4aE(e2)=130 553.0944aE(e^2) = 130\,553.094 km for the transfer ellipse; Simpson with 400 panels gives the same to the metre. scipy.integrate.quad adapts its own panels to a requested tolerance and is the reference for the convergence study. Why not just call quad everywhere? Because quad evaluates the integrand one point at a time in Python, which is a thousand times slower than the vectorized Simpson when a trajectory code needs ten thousand times of flight, and because a fixed rule whose error you understand is easier to trust than an adaptive one whose stopping rule you did not write. main() prints both so you can see them agree:

time periapsis -> apoapsis (Simpson, n=400) = 18990.13 s; Kepler III period / 2 = 18990.13 s
full swept area = 1.287399e+15 m^2; pi a b = 1.287399e+15 m^2
perimeter (Simpson) = 130553.094 km; 4 a E(e^2) = 130553.094 km
Simpson arc-length error over [0, pi/2]: n=8: 2.85e+02 n=16: 1.77e+01 n=32: 1.10e+00 n=64: 6.90e-02 n=128: 4.31e-03
observed orders: [4.01 4.   4.   4.  ]

The periapsis-to-apoapsis coast is 18 990 s = 5 h 16 min; half the 10.55 h period, as symmetry demands.

4. Experiment at home, or investigate real data

Mode: computational experiment. No measurement; we study the model's own behaviour.

Experiment A: where does an eccentric orbit spend its time? Split the orbit into the periapsis half (−90°<θ<90°-90° < \theta < 90°) and the apoapsis half. Prediction, written before running: by Kepler's second law the time is proportional to the area swept, and the apoapsis half contains the far, slow part of the ellipse, so its share of the period should rise steeply with ee. The exact fraction for the periapsis half is fp=(arccos⁡e−e1−e2)/πf_p = (\arccos e - e\sqrt{1 - e^2})/\pi (from Kepler's equation; Problem 6 derives it). Run

for ecc in (0.0, 0.1, 0.3, 0.5, 0.7265, 0.9, 0.95):
    tp = time_of_flight(p, ecc, -np.pi/2, np.pi/2)
    print(ecc, tp / orbital_period(p, ecc))

and tabulate against the prediction. Then answer: for the transfer orbit, what fraction of a tracking pass is near perigee?

Experiment B: how many panels? For the transfer orbit, compute time_of_flight(p, e, 0, np.pi, n=n) for n=4,8,…,256n = 4, 8, \dots, 256 and record the error against n=4096n = 4096. Prediction: fourth-order decay, so each doubling of nn gains a factor 16, and a 1 s tolerance on a 19 000 s coast (5×10−55 \times 10^{-5} relative) needs roughly n=16n = 16 to 32. Repeat for a hyperbola with e=1.5e = 1.5 over ∣θ∣<100°|\theta| < 100°, where the integrand grows steeply near the asymptote, and report how many more panels it needs for the same tolerance.

Raw data format: a plain-text table, one row per (e,fpnum,fpexact)(e, f_p^{\text{num}}, f_p^{\text{exact}}) and one per (n,error)(n, \text{error}), kept in your lesson notes.

5. Validate and improve

Put the hand calculation, the code and the independent reference side by side for the transfer orbit:

quantity hand (§2) code independent reference difference
ee 0.72654 0.726542 (3) is exact 0
pp (km) 11 530.1 11 530.08 0
vpv_p (m/s) 10 151 10 151.5 vis-viva 10 151.5 <10−12< 10^{-12} relative
vv at 90° (m/s) 7268 7267.7 vis-viva 7267.7 <10−12< 10^{-12} relative
γ\gamma at 90° 36.00° 36.00° arctan⁡e\arctan e 0
half period (s) 18 990 18 990.13 (Simpson) 18 990.13 (Kepler III) 4×10−104 \times 10^{-10} relative
perimeter (km) 130 553.094 130 553.094 (ellipe) <1< 1 m

Every residual has a cause. The parametric speed and vis-viva agree to rounding because they are algebraically identical once h2=μph^2 = \mu p is substituted: the test checks the implementation, not the physics. The Simpson period agrees with Kepler III to 4×10−104 \times 10^{-10} because the integrand r2r^2 is smooth and periodic over a full revolution; Simpson converges far faster than fourth order on a periodic integrand, and the half-period integral from periapsis to apoapsis shares the property because r2r^2 is even about both end points; you will see it in Experiment B as the error dropping from 0.2 s at n=16n = 16 to 6×10−76 \times 10^{-7} s at n=32n = 32 and hitting rounding by n=64n = 64. Over a partial arc the end points break the periodicity and the honest fourth-order rate appears: the convergence table in main() shows orders 4.01, 4.00, 4.00, 4.00. The hyperbola in Experiment B is slower still near its asymptote, where r2∼1/(1+ecos⁡θ)2r^2 \sim 1/(1 + e\cos\theta)^2 has large derivatives and the fourth-order constant f(4)f^{(4)} is huge; the order is still 4, the constant is not.

What is still unverified when everything agrees: that h=μph = \sqrt{\mu p}. Every number in the time column rests on it, and nothing in this lesson derives it. Agreement between the area integral and Kepler III only proves that the code and the formula share the same hh. The physics check comes in P01.07 (angular momentum from r×v\mathbf r \times \mathbf v) and Phase 09 (the two-body equation of motion).

Improvements worth making: let time_of_flight switch to Kepler's equation for an ellipse (extension), which is exact and needs no panels; return the integration error estimate alongside the value by comparing nn and 2n2n (Richardson's idea, P01.05). Improvements worth not making: extrapolating a hyperbola beyond its asymptote by clamping the denominator; the infinite radius is the physics, not a bug.

6. Defend your work

Submit: the completed starter/main.py with all tests passing; conic_orbits.png; the hand calculation for the transfer orbit with its comparison table; the eccentricity-sweep and panel-count tables with one paragraph each; and a one-page note (sections 1, 2, 5, 6 and 7 of projects/_template/report-template.md) stating what the conic model assumes and where it would mislead a mission planner.

Adversarial self-checks

  • What if the apoapsis doubles? ra=84 328r_a = 84\,328 km gives e=0.853e = 0.853, a=45 503a = 45\,503 km and T∝a3/2T \propto a^{3/2} grows by 2.54×2.54\times to 26.8 h, while rpvp=h=μpr_p v_p = h = \sqrt{\mu p} with p=rp(1+e)p = r_p(1 + e) grows only 3.6 %. Check with the code: the periapsis speed barely changes, the apoapsis speed halves.
  • What if e→0e \to 0? What if e→1e \to 1? At e=0e = 0 every formula must reduce to the circle (constant rr, γ=0\gamma = 0, T=2πr/vT = 2\pi r/v). As e→1−e \to 1^- the apoapsis and the period go to infinity but pp, hh and vpv_p stay finite: the parabola is the limit of ever-longer ellipses, not a different object.
  • Which assumption fails first in the real world? J2J_2: 0.6° per day of perigee drift is measurable on the first day. Drag at 300 km is next, over weeks. The point-mass Moon matters over months.
  • What measurement could falsify the model? Range and range-rate from a tracking station give r(t)r(t) and r˙(t)\dot r(t); the conic predicts r˙=(h/p)esin⁡θ\dot r = (h/p)e\sin\theta, a pure sinusoid in θ\theta. A systematic residual that grows orbit to orbit is a perturbation; one that appears within a single pass is a modelling error.
  • Does the result survive a change in panel count? Halving nn from 400 to 200 must change the half-period by less than 10−610^{-6} s; if it changes by seconds, the integrand is not smooth on your grid (you are too close to an asymptote) or simpson has an indexing slip.
  • Which decision changes if the uncertainty doubled? Suppose rpr_p were known to ±2 km instead of ±1 km. TT changes by ∂T/∂rp=34T/a≈1.17\partial T/\partial r_p = \tfrac34 T/a \approx 1.17 s per km, so ±2.3 s instead of ±1.2 s; the apogee burn window is tens of seconds wide, so nothing changes. If rar_a were uncertain by ±200 km instead of ±100 km, the circularisation burn itself changes by only 0.2 m/s instead of 0.1 m/s (check it with the code), but the resulting orbit's period is off by 32TGEO Δr/r=10\tfrac32 T_{\mathrm{GEO}}\,\Delta r/r = 10 min instead of 5 min per day, i.e. the satellite drifts 2.6° per day in longitude instead of 1.3°. The decision that changes is the size of the station-keeping budget, not the transfer. The tolerance is set by the use, not by the geometry.

Check yourself

  1. In r=p/(1+ecos⁡θ)r = p/(1 + e\cos\theta), what is rr at θ=90°\theta = 90°, and why does it not depend on ee?
  2. An ellipse has ra=3rpr_a = 3r_p. What is its eccentricity?
  3. Write the polar area formula and say in one sentence why Kepler's second law follows from it when r2θ˙r^2\dot\theta is constant.
  4. At which two points of an elliptical orbit is the flight-path angle zero, and what is tan⁡γ\tan\gamma at θ=90°\theta = 90°?
  5. Why does simpson require an even number of panels?
  6. The speed at periapsis of the transfer orbit is 10 151 m/s and rp=6678r_p = 6678 km. Without a calculator, what is the speed at apoapsis, ra=42 164r_a = 42\,164 km, to two figures?
  7. For e=2e = 2, in which directions does the hyperbola go to infinity?
  8. The ellipse x=a(cos⁡E−e)x = a(\cos E - e), y=bsin⁡Ey = b\sin E and the polar form r=p/(1+ecos⁡θ)r = p/(1 + e\cos\theta) describe the same curve. Which parameter, EE or θ\theta, is the angle seen from the Earth's centre?

Problem set

Attempt every problem before opening solutions/. Record what you tried. State units on every numerical answer and say which results are exact and which are numerical (with the panel count used).

Several problems use your personal seed s: the day of the month you were born (1–31). Use μ=3.986 004 418×1014\mu = 3.986\,004\,418 \times 10^{14} m³/s² and RE=6378.137R_E = 6378.137 km.

1. (Warm-up: a low Earth orbit from its apsides)

A satellite's periapsis altitude is 200+10s200 + 10s km and its apoapsis altitude is 1000+100s1000 + 100s km.

Find: (a) ee, pp and aa; (b) the radius at θ=90°\theta = 90°; (c) the period in minutes; (d) the speed at periapsis and at apoapsis; (e) the largest flight-path angle on the orbit and the true anomaly at which it occurs (derive the condition dγ/dθ=0\mathrm{d}\gamma/\mathrm{d}\theta = 0 from equation (6) of the lesson before you compute). Check (a)–(d) with conic_from_apsides, orbital_period and orbital_speed, and (e) with a fine grid of flight_path_angle. Answer form: seven numbers with units, four significant figures, plus the two-line derivation for (e).

2. (Derivation: the conic and its calculus)

(a) Starting from the focus–directrix definition (distance to focus =e×= e \times distance to directrix, directrix at x=−dx = -d), derive r=p/(1+ecos⁡θ)r = p/(1 + e\cos\theta) and identify pp. (b) Derive the polar area formula A=12∫r2 dθA = \tfrac12\int r^2\,\mathrm{d}\theta from a sum of thin sectors, then show that constant r2θ˙r^2\dot\theta implies equal areas in equal times. State where you use that the sector is "almost circular" and why the error vanishes in the limit. (c) From r˙=(h/p)esin⁡θ\dot r = (h/p)e\sin\theta and rθ˙=(h/p)(1+ecos⁡θ)r\dot\theta = (h/p)(1 + e\cos\theta), derive the speed v=(h/p)1+2ecos⁡θ+e2v = (h/p)\sqrt{1 + 2e\cos\theta + e^2} and show that rv=hrv = h exactly at the apsides and nowhere else on an ellipse with e>0e > 0. (d) Show that every point of x=a(cos⁡E−e)x = a(\cos E - e), y=a1−e2sin⁡Ey = a\sqrt{1 - e^2}\sin E satisfies r=p/(1+ecos⁡θ)r = p/(1 + e\cos\theta) with r=x2+y2r = \sqrt{x^2 + y^2} and cos⁡θ=x/r\cos\theta = x/r. (Hint: compute rr first and show r=a(1−ecos⁡E)r = a(1 - e\cos E).)

Answer form: four derivations with each assumption named where it is used.

3. (Unfamiliar scenario: a weaving ground track)

A survey aircraft flies a sinusoidal track over flat ground: x(t)=Vtx(t) = Vt, y(t)=Asin⁡(ωt)y(t) = A\sin(\omega t) with V=60V = 60 m/s, A=50A = 50 m and a weave period of 20 s (ω=2π/20\omega = 2\pi/20 rad/s).

(a) Find the maximum heading deviation from the xx axis (the maximum of arctan⁡(dy/dx)\arctan(\mathrm{d}y/\mathrm{d}x)) and the maximum and minimum ground speed. (b) The curvature of a parametric curve is κ=∣x˙y¨−y˙x¨∣/(x˙2+y˙2)3/2\kappa = |\dot x\ddot y - \dot y\ddot x|/(\dot x^2 + \dot y^2)^{3/2}. Find the minimum turning radius 1/κmax⁡1/\kappa_{\max} and where on the weave it occurs. (c) Find the lateral acceleration at that point and the load factor n=1+(alat/g)2n = \sqrt{1 + (a_{\text{lat}}/g)^2} of a coordinated turn there. (d) Use your simpson to compute the ground distance flown in one weave period and compare it with the straight-line distance VTVT.

Answer form: six numbers with units; say which are exact and which are numerical.

4. (Numerical, uses your code: a hyperbolic flyby)

A spacecraft approaches Earth on a hyperbola with e=1.5e = 1.5 and periapsis altitude 300 km.

(a) Compute pp, aa (negative), the asymptote angle θ∞\theta_\infty and the total turning angle of the velocity, δ=2arcsin⁡(1/e)\delta = 2\arcsin(1/e). (b) Compute the hyperbolic excess speed v∞=μ/(−a)v_\infty = \sqrt{\mu/(-a)} and the periapsis speed, and verify vp2=v∞2+2μ/rpv_p^2 = v_\infty^2 + 2\mu/r_p (energy conservation). (c) With time_of_flight, compute the time from θ=−60°\theta = -60° to +60°+60° for n=16,32,64,128n = 16, 32, 64, 128 and report the observed convergence order. (d) Plot the hyperbola with orbit_points, add the two asymptotes through the centre at x=−aex = -ae (note ae>0ae > 0 for e>1e > 1 and a<0a < 0), and mark periapsis. Save as flyby.png.

Answer form: seven numbers with units, a convergence table with the observed order, one plot.

5. (Judgment: where the conic model stops)

For each of the following say which assumption of the two-body conic fails, estimate the size of the effect with one number, and name one measurable sign in tracking data that it has:

(a) a transfer orbit whose periapsis is at 150 km altitude instead of 300 km (air density at 150 km is roughly 2×10−92 \times 10^{-9} kg/m³, at 300 km roughly 2×10−112 \times 10^{-11} kg/m³); (b) a polar orbit at 800 km altitude flown for a year (Earth's J2=1.083×10−3J_2 = 1.083 \times 10^{-3} makes the orbit plane precess at a rate proportional to J2(RE/p)2cos⁡iJ_2 (R_E/p)^2\cos i); (c) an apoapsis at 200 000 km; (d) a CubeSat deployed from the International Space Station with a 2 m/s separation speed: is its orbit "a different conic" or "the same conic" for mission-planning purposes?

Answer form: four short paragraphs, each with a number and a measurable sign.

6. (Hard: time from the parametric form, Kepler's equation)

The two parameters of §2.7 are linked by cos⁡E=(e+cos⁡θ)/(1+ecos⁡θ)\cos E = (e + \cos\theta)/(1 + e\cos\theta), and the time since periapsis is t=(T/2π)(E−esin⁡E)t = (T/2\pi)(E - e\sin E) (Kepler's equation; take it as given or derive it from dA/dt=h/2\mathrm{d}A/\mathrm{d}t = h/2 with the parametric ellipse).

(a) Show that the fraction of the period spent in the periapsis half of the orbit (−90°<θ<90°-90° < \theta < 90°) is fp=(arccos⁡e−e1−e2)/πf_p = (\arccos e - e\sqrt{1 - e^2})/\pi, and evaluate it for the lesson's transfer orbit (e=0.72654e = 0.72654). Compare with time_of_flight. (b) For the transfer orbit, find the true anomaly at t=T/4t = T/4 by solving Kepler's equation for EE with Newton's method (P01.02) starting from E0=M=π/2E_0 = M = \pi/2; list the iterates to show quadratic convergence; convert to θ\theta with tan⁡(θ/2)=(1+e)/(1−e)tan⁡(E/2)\tan(\theta/2) = \sqrt{(1 + e)/(1 - e)}\tan(E/2). Check by computing time_of_flight(p, e, 0, theta)/T. (c) Explain in two sentences why time_of_flight needs numerical integration while Kepler's equation does not, and which one you would put inside a trajectory code that calls it a million times.

Answer form: one derivation, one fraction, a Newton table, one angle in degrees, two sentences.

Get the code

Clone the repository once, write your code in starter/main.py, then run the tests from the repository root.

pytest curriculum/phase-01/lesson-06-parametric-and-polar

To run the same tests against the reference solution instead:

AEFS_IMPL=solution pytest curriculum/phase-01/lesson-06-parametric-and-polar

Found a mistake? Every page is built from the Markdown in the repository; edit it on GitHub.