quot;) > plt.loglog(ns, es[0]*(ns[0]/ns)**4.0, ":", color="0.6", label="$O(h^4)quot;) > plt.xlabel("n"); plt.ylabel("absolute error (s)"); plt.legend(); plt.show() > ``` > *Look for:* both curves straight on log-log axes and parallel to their reference slopes. > [!example]- MATLAB > > **Step 1: define the helper, then warm up on the hand numbers.** The helper reports the largest difference; every check runs through it. > ```matlab > same = @(name, X, Y) fprintf('%s: max difference %.1e\n', name, max(abs(X - Y), [], 'all')); > GM = 398600; % km^3/s^2 (Earth) > r_of = @(th, a, e) a*(1 - e^2) ./ (1 + e*cos(th)); > h_of = @(a, e) sqrt(GM*a*(1 - e^2)); > vals = 1 ./ (1 + 0.5*cos([0 pi/2 pi])).^2; > same('integrand values equal 4/9, 1, 4 (e = 0.5)', vals, [4/9 1 4]) > fprintf('Earth: perihelion %.2f aphelion %.2f\n', 149.6*(1 - 0.017), 149.6*(1 + 0.017)) > same('comet r_max/r_min at e = 0.9 equals 19', (1 + 0.9)/(1 - 0.9), 19) > a_iss = 6371 + 408; e_iss = 0; % ISS: a = 6779 km, circular > T_iss = 2*pi*sqrt(a_iss^3/GM); % Kepler III > fprintf('ISS: T = %.1f quarter = %.3f h = %.1f\n', T_iss, T_iss/4, h_of(a_iss, e_iss)) > ``` > *Look for:* $147.06/152.14$; ISS $T=5554.7$ s, $T/4=1388.672$ s, $h=51981.8$ km²/s. > > **Step 2: define the orbit and see it.** > ```matlab > a_m = 26560; e_m = 0.74; % Molniya orbit > th = linspace(0, 2*pi, 800); r = r_of(th, a_m, e_m); > plot(r.*cos(th), r.*sin(th)); hold on; plot(0, 0, 'o'); axis equal; title('Molniya orbit') > fprintf('%.1f %.1f\n', r_of(0, a_m, e_m), r_of(pi, a_m, e_m)) % 6905.6 46214.4 > ``` > *Look for:* the division must be elementwise (`./`); Earth at the focus, visibly lopsided. > > **Step 3: trapezoid rule, verified on the circular orbit.** > ```matlab > n = 100; t1 = 0; t2 = pi/2; > th = linspace(t1, t2, n+1); dth = (t2 - t1)/n; > y = r_of(th, a_iss, e_iss).^2 / h_of(a_iss, e_iss); > t_num = dth*(0.5*y(1) + sum(y(2:end-1)) + 0.5*y(end)); > fprintf('%.3f %.3f\n', t_num, T_iss/4) > same('circular quarter orbit at machine precision', t_num, T_iss/4) > ``` > *Look for:* machine-level error ($\sim10^{-13}$), not merely small. > > **Step 4: Simpson's rule and the convergence study.** > ```matlab > ecc = 2*atan(sqrt((1 - e_m)/(1 + e_m))*tan(pi/4)); % eccentric anomaly at theta = pi/2 > t_star = sqrt(a_m^3/GM)*(ecc - e_m*sin(ecc)); % exact: 1645.4287 s > for n = [10 20 40 80 160 320] > th = linspace(0, pi/2, n+1); dth = (pi/2)/n; > y = r_of(th, a_m, e_m).^2 / h_of(a_m, e_m); > t_tr = dth*(0.5*y(1) + sum(y(2:end-1)) + 0.5*y(end)); > t_si = dth/3*(y(1) + 4*sum(y(2:2:end-1)) + 2*sum(y(3:2:end-2)) + y(end)); > fprintf('%4d %.3e %.3e\n', n, abs(t_tr - t_star), abs(t_si - t_star)); > end > T_m = 2*pi*sqrt(a_m^3/GM); % full period, 43077.8 s = 11.966 h > for n = [16 32 64] % the periodic surprise (see the note below) > th = linspace(0, 2*pi, n+1); dth = 2*pi/n; > y = r_of(th, a_m, e_m).^2 / h_of(a_m, e_m); > fprintf('%3d %.1e\n', n, abs(dth*(0.5*y(1) + sum(y(2:end-1)) + 0.5*y(end)) - T_m)); > end > ``` > *Look for:* the odd-index (weight $4$) and even-index (weight $2$) slices are 1-based here, unlike Python; errors at $n=320$: $6.2\times10^{-3}$ and $5.5\times10^{-8}$ s; full-orbit errors collapse. > > **Step 5: plot the convergence.** > ```matlab > ns = [10 20 40 80 160 320]; et = zeros(size(ns)); es = et; > for i = 1:numel(ns) % reuse the Step 4 loop body > n = ns(i); th = linspace(0, pi/2, n+1); dth = (pi/2)/n; > y = r_of(th, a_m, e_m).^2 / h_of(a_m, e_m); > et(i) = abs(dth*(0.5*y(1) + sum(y(2:end-1)) + 0.5*y(end)) - t_star); > es(i) = abs(dth/3*(y(1) + 4*sum(y(2:2:end-1)) + 2*sum(y(3:2:end-2)) + y(end)) - t_star); > end > figure; loglog(ns, et, 'o-'); hold on; loglog(ns, es, 's-') > loglog(ns, et(1)*(ns(1)./ns).^2, '--', 'Color', [.6 .6 .6]) > loglog(ns, es(1)*(ns(1)./ns).^4, ':', 'Color', [.6 .6 .6]) > xlabel('n'); ylabel('absolute error (s)') > legend('trapezoid', 'Simpson', 'O(h^2)', 'O(h^4)') > ``` > *Look for:* straight parallel lines on log-log axes. > [!example]- R > > **Step 1: define the helper, then warm up on the hand numbers.** The helper reports the largest difference; every check runs through it. > ```r > same <- function(name, X, Y) cat(sprintf("%s: max difference %.1e\n", name, max(abs(X - Y)))) > GM <- 398600 # km^3/s^2 (Earth) > r_of <- function(th, a, e) a*(1 - e^2) / (1 + e*cos(th)) > h_of <- function(a, e) sqrt(GM*a*(1 - e^2)) > vals <- 1 / (1 + 0.5*cos(c(0, pi/2, pi)))^2 > same("integrand values equal 4/9, 1, 4 (e = 0.5)", vals, c(4/9, 1, 4)) > cat("Earth: perihelion", 149.6*(1 - 0.017), " aphelion", 149.6*(1 + 0.017), "\n") > same("comet r_max/r_min at e = 0.9 equals 19", (1 + 0.9)/(1 - 0.9), 19) > a_iss <- 6371 + 408; e_iss <- 0 # ISS: a = 6779 km, circular > T_iss <- 2*pi*sqrt(a_iss^3/GM) # Kepler III > cat("ISS: T =", T_iss, " quarter =", T_iss/4, " h =", h_of(a_iss, e_iss), "\n") > ``` > *Look for:* $147.06/152.14$; ISS $T=5554.7$ s, $T/4=1388.672$ s, $h=51981.8$ km²/s. > > **Step 2: define the orbit and see it.** > ```r > a_m <- 26560; e_m <- 0.74 # Molniya orbit > th <- seq(0, 2*pi, length.out = 800); r <- r_of(th, a_m, e_m) > plot(r*cos(th), r*sin(th), type = "l", asp = 1, main = "Molniya orbit") > points(0, 0, pch = 19) > cat(r_of(0, a_m, e_m), r_of(pi, a_m, e_m), "\n") # 6905.6 46214.4 > ``` > *Look for:* Earth at the focus, visibly lopsided ellipse. > > **Step 3: trapezoid rule, verified on the circular orbit.** > ```r > transit_trap <- function(t1, t2, a, e, n) { > th <- seq(t1, t2, length.out = n+1); dth <- (t2 - t1)/n > y <- r_of(th, a, e)^2 / h_of(a, e) > dth*(0.5*y[1] + sum(y[2:n]) + 0.5*y[n+1]) > } > t_num <- transit_trap(0, pi/2, a_iss, e_iss, 100) > cat(t_num, T_iss/4, "\n") # 1388.672 1388.672 > same("circular quarter orbit at machine precision", t_num, T_iss/4) > ``` > *Look for:* machine-level error ($\sim10^{-13}$), not merely small. > > **Step 4: Simpson's rule and the convergence study.** > ```r > transit_simp <- function(t1, t2, a, e, n) { # n must be even > th <- seq(t1, t2, length.out = n+1); dth <- (t2 - t1)/n > y <- r_of(th, a, e)^2 / h_of(a, e) > dth/3*(y[1] + 4*sum(y[seq(2, n, 2)]) + 2*sum(y[seq(3, n-1, 2)]) + y[n+1]) > } > ecc <- 2*atan(sqrt((1 - e_m)/(1 + e_m))*tan(pi/4)) # eccentric anomaly at theta = pi/2 > t_star <- sqrt(a_m^3/GM)*(ecc - e_m*sin(ecc)) # exact: 1645.4287 s > for (n in c(10, 20, 40, 80, 160, 320)) > cat(n, abs(transit_trap(0, pi/2, a_m, e_m, n) - t_star), > abs(transit_simp(0, pi/2, a_m, e_m, n) - t_star), "\n") > T_m <- 2*pi*sqrt(a_m^3/GM) # full period, 43077.8 s = 11.966 h > for (n in c(16, 32, 64)) # the periodic surprise (see the note below) > cat(n, abs(transit_trap(0, 2*pi, a_m, e_m, n) - T_m), "\n") > ``` > *Look for:* the weight-4 and weight-2 index slices are 1-based here, unlike Python; errors at $n=320$: $6.2\times10^{-3}$ and $5.5\times10^{-8}$ s; full-orbit errors collapse. > > **Step 5: plot the convergence.** > ```r > ns <- c(10, 20, 40, 80, 160, 320) > et <- sapply(ns, function(n) abs(transit_trap(0, pi/2, a_m, e_m, n) - t_star)) > es <- sapply(ns, function(n) abs(transit_simp(0, pi/2, a_m, e_m, n) - t_star)) > plot(ns, et, log = "xy", type = "b", pch = 19, xlab = "n", ylab = "absolute error (s)", > ylim = range(c(et, es))) > lines(ns, es, type = "b", pch = 15, col = "navy") > lines(ns, et[1]*(ns[1]/ns)^2, lty = 2, col = "gray") > lines(ns, es[1]*(ns[1]/ns)^4, lty = 3, col = "gray") > legend("bottomleft", c("trapezoid", "Simpson", "O(h^2)", "O(h^4)"), > lty = c(1, 1, 2, 3), pch = c(19, 15, NA, NA), col = c("black", "navy", "gray", "gray")) > ``` > *Look for:* straight parallel lines on log-log axes. > [!example]- Mathematica (numerical only) > > **Step 1: define the helper, then warm up on the hand numbers.** The helper reports the largest difference; every check runs through it. (`E`, `N`, `D` are protected names, so use `ec`, `gm`, and friends.) > ```wolfram > same[name_, x_, y_] := Print[name, ": max difference ", Max@Abs[x - y]]; > gm = 398600.; (* km^3/s^2; numerical only *) > rOf[th_, a_, ec_] := a (1 - ec^2)/(1 + ec Cos[th]); > hOf[a_, ec_] := Sqrt[gm a (1 - ec^2)]; > vals = 1/(1 + 0.5 Cos[#])^2 & /@ {0., N[Pi/2], N[Pi]}; > same["integrand values equal 4/9, 1, 4 (e = 0.5)", vals, {4./9, 1., 4.}] > Print["Earth: perihelion ", 149.6 (1 - 0.017), " aphelion ", 149.6 (1 + 0.017)] > same["comet r_max/r_min at e = 0.9 equals 19", (1 + 0.9)/(1 - 0.9), 19.] > aIss = 6371. + 408.; eIss = 0.; (* ISS: a = 6779 km, circular *) > tIss = 2 Pi Sqrt[aIss^3/gm]; (* Kepler III *) > Print["ISS: T = ", tIss, " quarter = ", tIss/4, " h = ", hOf[aIss, eIss]] > ``` > *Look for:* $147.06/152.14$; ISS $T=5554.7$ s, $T/4=1388.67$ s, $h=51981.8$ km²/s. > > **Step 2: define the orbit and see it.** > ```wolfram > am = 26560.; em = 0.74; (* Molniya orbit *) > ParametricPlot[rOf[th, am, em] {Cos[th], Sin[th]}, {th, 0, 2 Pi}, > Epilog -> {PointSize[.02], Point[{0, 0}]}, PlotLabel -> "Molniya orbit"] > Print[{rOf[0., am, em], rOf[N[Pi], am, em]}] (* {6905.6, 46214.4} *) > ``` > *Look for:* Earth at the focus, visibly lopsided ellipse. > > **Step 3: trapezoid rule, verified on the circular orbit.** > ```wolfram > transitTrap[t1_, t2_, a_, ec_, n_] := Module[{th, dth, y}, > th = Subdivide[N[t1], N[t2], n]; dth = (t2 - t1)/n; > y = rOf[#, a, ec]^2/hOf[a, ec] & /@ th; > dth (0.5 First[y] + Total[y[[2 ;; -2]]] + 0.5 Last[y])] > tNum = transitTrap[0, Pi/2, aIss, eIss, 100]; > Print[{tNum, tIss/4}] (* 1388.67, 1388.67 *) > same["circular quarter orbit at machine precision", tNum, tIss/4] > ``` > *Look for:* machine-level error ($\sim10^{-13}$), not merely small. > > **Step 4: Simpson's rule and the convergence study.** > ```wolfram > transitSimp[t1_, t2_, a_, ec_, n_] := Module[{th, dth, y}, (* n must be even *) > th = Subdivide[N[t1], N[t2], n]; dth = (t2 - t1)/n; > y = rOf[#, a, ec]^2/hOf[a, ec] & /@ th; > dth/3 (First[y] + 4 Total[y[[2 ;; -2 ;; 2]]] + 2 Total[y[[3 ;; -3 ;; 2]]] + Last[y])] > ecc = N[2 ArcTan[Sqrt[(1 - em)/(1 + em)] Tan[Pi/4]]]; (* eccentric anomaly *) > tStar = Sqrt[am^3/gm] (ecc - em Sin[ecc]); (* exact: 1645.4287 s *) > Do[Print[{n, Abs[transitTrap[0, Pi/2, am, em, n] - tStar], > Abs[transitSimp[0, Pi/2, am, em, n] - tStar]}], {n, {10, 20, 40, 80, 160, 320}}] > tm = 2 Pi Sqrt[am^3/gm]; (* full period, 11.966 h *) > Do[Print[{n, Abs[transitTrap[0, 2 Pi, am, em, n] - tm]}], {n, {16, 32, 64}}] > ``` > *Look for:* errors at $n=320$: $6.2\times10^{-3}$ and $5.5\times10^{-8}$ s; full-orbit errors collapse ($2.2$, $9\times10^{-6}$, $7\times10^{-12}$ s). > > **Step 5: plot the convergence.** > ```wolfram > ns = {10, 20, 40, 80, 160, 320}; > errT = Table[{n, Abs[transitTrap[0, Pi/2, am, em, n] - tStar]}, {n, ns}]; > errS = Table[{n, Abs[transitSimp[0, Pi/2, am, em, n] - tStar]}, {n, ns}]; > ListLogLogPlot[{errT, errS}, Joined -> True, PlotMarkers -> Automatic, > AxesLabel -> {"n", "error (s)"}, PlotLegends -> {"trapezoid", "Simpson"}] > ``` > *Look for:* straight parallel lines on log-log axes. What the guided run should produce:  > [!warning] Verify against ground truth (required) > Record these checked numbers; "it ran" is not verification. > - Warm-up: integrand $\tfrac49, 1, 4$ at $e=0.5$ (helper at $0$); Earth perihelion/aphelion $147.06/152.14$ million km; comet ratio $19$; ISS $T=5554.7$ s, $T/4=1388.672$ s, $h=51{,}981.8$ km²/s. > - Molniya geometry: $r(0)=6905.6$ km, $r(\pi)=46{,}214.4$ km. > - Circular quarter orbit (ISS): trapezoid $=1388.672$ s $=T/4$ exactly (error $\sim10^{-13}$, machine level). > - Molniya quarter arc: exact $t^\*=1645.4287$ s from Kepler's equation; at $n=320$ the trapezoid error is $6.2\times10^{-3}$ s and the Simpson error $5.5\times10^{-8}$ s. > - Measured orders: error ratios per doubling of $n$ are $4.00$ (trapezoid) and $16.0$ (Simpson), i.e., orders $2.00$ and $4.00$. > - Full Molniya period: $T=2\pi\sqrt{a^3/GM}=11.966$ h, and your full-orbit quadrature must reproduce it. > [!note] A surprise worth seeing: the trapezoid rule on a full orbit > Integrate the full orbit $[0,2\pi]$ with the plain trapezoid rule and compare to $T=11.966$ h: the error is $2.2$ s at $n=16$, $9\times10^{-6}$ s at $n=32$, and $7\times10^{-12}$ s at $n=64$, collapsing far faster than $O(h^2)$. The integrand is smooth and periodic, and for periodic integrands over a full period the trapezoid rule converges spectacularly (the [Euler-Maclaurin](https://en.wikipedia.org/wiki/Euler%E2%80%93Maclaurin_formula) correction terms cancel). The $O(h^2)$ story is for arcs with genuine endpoints, which is why the convergence study above uses a quarter arc. ### Generalization: the Molniya orbit, where Kepler's second law bites (Step 6) [Molniya orbits](https://en.wikipedia.org/wiki/Molniya_orbit) ($a=26{,}560$ km, $e=0.74$, $T\approx12$ h) are used by communications satellites serving high latitudes precisely because the satellite crawls near apogee. Quantify it: compute the transit time for the same $60°$ arc centered at perigee and at apogee. **Scenario A (equal arcs, unequal times).** *Prediction (before running):* the transit-time ratio should exceed the speed ratio. The satellite at apogee is both slower and farther out (the same $d\theta$ subtends a longer path), so the two factors compound. > [!example]- Step 6 code, Python (reference) > > **Step 6: perigee versus apogee dwell.** The same $60°$ arc, timed at both ends of the orbit; speeds from $v=h/r$. > ```python > arc = np.pi/3 > t_fast = transit_simp(-arc/2, arc/2, a_m, e_m, 1000) > t_slow = transit_simp(np.pi - arc/2, np.pi + arc/2, a_m, e_m, 1000) > print(t_fast/60, t_slow/60, t_slow/t_fast) # 12.51 435.40 34.80 > h_m = h_of(a_m, e_m) > print(h_m/r_of(0, a_m, e_m), h_m/r_of(np.pi, a_m, e_m)) # speeds 10.02, 1.50 km/s > same("speed ratio equals (1+e)/(1-e)", > (h_m/r_of(0, a_m, e_m))/(h_m/r_of(np.pi, a_m, e_m)), (1 + e_m)/(1 - e_m)) > ``` > *Look for:* the same $60°$ arc takes $12.51$ minutes at perigee and $435.40$ minutes ($7.26$ h, well over half the $12$ h period) at apogee, a factor of $34.80$; speeds $10.02$ and $1.50$ km/s with ratio exactly $(1+e)/(1-e)=6.69$ (conservation of angular momentum, $v=h/r$). > [!example]- Step 6 code, MATLAB > > **Step 6: perigee versus apogee dwell.** > ```matlab > arc = pi/3; n = 1000; h_m = h_of(a_m, e_m); > lims = [-arc/2, arc/2; pi-arc/2, pi+arc/2]; % perigee arc; apogee arc > t_arc = zeros(2, 1); > for j = 1:2 > th = linspace(lims(j,1), lims(j,2), n+1); dth = (lims(j,2) - lims(j,1))/n; > y = r_of(th, a_m, e_m).^2 / h_m; > t_arc(j) = dth/3*(y(1) + 4*sum(y(2:2:end-1)) + 2*sum(y(3:2:end-2)) + y(end)); > end > fprintf('%.2f %.2f %.2f\n', t_arc(1)/60, t_arc(2)/60, t_arc(2)/t_arc(1)) % 12.51 435.40 34.80 > fprintf('%.2f %.2f\n', h_m/r_of(0, a_m, e_m), h_m/r_of(pi, a_m, e_m)) % 10.02 1.50 km/s > same('speed ratio equals (1+e)/(1-e)', ... > (h_m/r_of(0, a_m, e_m))/(h_m/r_of(pi, a_m, e_m)), (1 + e_m)/(1 - e_m)) > ``` > *Look for:* the same numbers as the Python reference. > [!example]- Step 6 code, R > > **Step 6: perigee versus apogee dwell.** > ```r > arc <- pi/3 > t_fast <- transit_simp(-arc/2, arc/2, a_m, e_m, 1000) > t_slow <- transit_simp(pi - arc/2, pi + arc/2, a_m, e_m, 1000) > cat(t_fast/60, t_slow/60, t_slow/t_fast, "\n") # 12.51 435.40 34.80 > h_m <- h_of(a_m, e_m) > cat(h_m/r_of(0, a_m, e_m), h_m/r_of(pi, a_m, e_m), "\n") # 10.02 1.50 km/s > same("speed ratio equals (1+e)/(1-e)", > (h_m/r_of(0, a_m, e_m))/(h_m/r_of(pi, a_m, e_m)), (1 + e_m)/(1 - e_m)) > ``` > *Look for:* the same numbers as the Python reference. > [!example]- Step 6 code, Mathematica (numerical only) > > **Step 6: perigee versus apogee dwell.** > ```wolfram > arc = Pi/3.; > tFast = transitSimp[-arc/2, arc/2, am, em, 1000]; > tSlow = transitSimp[Pi - arc/2, Pi + arc/2, am, em, 1000]; > Print[{tFast/60, tSlow/60, tSlow/tFast}] (* {12.51, 435.40, 34.80} *) > hm = hOf[am, em]; > Print[{hm/rOf[0., am, em], hm/rOf[N[Pi], am, em]}] (* {10.02, 1.50} km/s *) > same["speed ratio equals (1+e)/(1-e)", > (hm/rOf[0., am, em])/(hm/rOf[N[Pi], am, em]), (1 + em)/(1 - em)] > ``` > *Look for:* the same numbers as the Python reference. **Scenario B (eccentricity drives the cost of accuracy).** Fix the quarter arc $[0,\pi/2]$ and re-run the Step 4 convergence study for $e=0,\ 0.3,\ 0.6,\ 0.9$ (exact values from Kepler's equation each time). Find the $n$ each eccentricity needs for a $10^{-3}$ s error. *Prediction:* higher $e$ concentrates the integrand's variation near perigee, so the constant in the $O(h^2)$/$O(h^4)$ error grows with $e$ and the required $n$ climbs; the order itself should not change. > [!warning] Verify the generalization (required) > - The $60°$ arcs: $12.51$ min at perigee, $435.40$ min at apogee, ratio $34.80$ (Simpson at $n=1000$ matches the Kepler-exact values to $\sim10^{-9}$). > - Speeds $10.02$ and $1.50$ km/s; their ratio must equal $(1+e)/(1-e)=6.6923$ through the helper. > - Scenario B: the measured orders stay $2.00$ and $4.00$ at every $e$; only the constants (and hence the required $n$) grow. ### Your orbits: three eccentricity personalities Now run the study on three real orbits you choose yourself, picked in advance to have three different eccentricity personalities. Look up each orbit's $a$ and $e$ (cite your source), use the right central body ($GM_{\text{Earth}}=398{,}600$ km³/s²; $GM_{\text{Sun}}=1.327\times10^{11}$ km³/s²), and read the difficulty dial $\bigl(\tfrac{1+e}{1-e}\bigr)^2$ *before* running anything: the order of operations matters every time, predict from the dial first, then compute. 1. **Orbit A, near-circular ($e\le0.05$).** A GPS satellite or a LEO orbit. Prediction to test: the integrand is nearly flat, tiny $n$ already reaches tight tolerances, and the perigee/apogee dwell ratio is close to $1$. (A nice pairing: GPS satellites sit at nearly the Molniya $a\approx26{,}560$ km, so they share the $12$ h period; everything that differs from your Molniya runs is eccentricity.) 2. **Orbit B, working eccentric ($0.2\le e\le0.7$).** A geostationary transfer orbit, a Tundra orbit, or a Molniya cousin. Prediction to test: this is the regime where Simpson's extra order visibly pays; state the expected dwell ratio from $e$ before timing the arcs. 3. **Orbit C, extreme ($e\ge0.9$).** A comet ([Halley](https://en.wikipedia.org/wiki/Halley%27s_comet), $e\approx0.967$) or a sungrazer. Prediction to test: the dial reads in the thousands, the required $n$ for a fixed tolerance climbs dramatically, and the dwell ratio becomes astronomical; check whether the *orders* (not the constants) survive. For each orbit, report: the dial value; a quarter-arc transit time against its Kepler-equation exact value (through the helper); the $n$ each rule needs for a $10^{-3}$ s error; and the $60°$ perigee/apogee dwell ratio. Close with a cross-orbit comparison: rank the three by the cost of accurate quadrature and defend the ranking from the convergence numbers and the dial, not from the pictures. #### Student task loop for implementation, analysis and reflection 1. **Predict** the difficulty ranking and dwell ratios from $e$ and the dial, before running. 2. **Implement** the workflow (Steps 2 to 5) on the orbit. 3. **Compare** the transit times against the Kepler-exact values and the required $n$ against your prediction. 4. **Interpret** what the numbers mean for the physical orbit and for the numerical method. ## Reflection Framework Address these (2-3 focused questions per category, no more): ### Convergence and cost - Your convergence data give straight lines on log-log axes. What do the slopes mean, and why does Simpson's line fall so much faster? - When is Simpson's extra bookkeeping worth it over the trapezoid rule, and when is it overkill? ### Geometry and physics - How do your perigee/apogee transit times express Kepler's second law without ever mentioning area? - Why does a Molniya satellite's ground station see it hang in the sky for hours per orbit? ### Mathematical insights - The integrand's max/min ratio $\bigl(\tfrac{1+e}{1-e}\bigr)^2$ acts like a difficulty dial (a conditioning statement for the quadrature problem). How did it show up in Scenario B and across your three orbits? - The full-orbit trapezoid result beat its own error bound by orders of magnitude. What property of the integrand (not the rule) explains that? ## (Optional) Mathematical Extensions These go beyond the project's stated level; attempt them if interested. - **Kepler's equation as root finding:** given $t$, solve $E-e\sin E=t\sqrt{GM/a^3}$ for $E$ with Newton's method, joining this project to the root-finding thread. - **Derive the eccentric-anomaly substitution** that produced the exact $t(\theta)$, and verify it reproduces your ground-truth values. - **Adaptive quadrature:** subdivide only where the integrand varies (near perigee) and compare function-evaluation counts with the uniform grids. - **Periodic superconvergence:** read about the [Euler-Maclaurin formula](https://en.wikipedia.org/wiki/Euler%E2%80%93Maclaurin_formula) and explain the full-orbit trapezoid result quantitatively. ## (Optional) Real-World Context ### Applications - **[International Space Station operations](https://en.wikipedia.org/wiki/International_Space_Station):** pass predictions, crew scheduling, and resupply rendezvous all start from transit-time integrals like yours. - **[Molniya communications satellites](https://en.wikipedia.org/wiki/Molniya_orbit):** the apogee dwell you computed is the entire design rationale for high-latitude coverage. - **[GPS](https://en.wikipedia.org/wiki/Global_Positioning_System):** positioning accuracy depends on continuously updated orbital parameters; the underlying propagation is numerical integration. - **[Space debris tracking](https://en.wikipedia.org/wiki/Space_debris):** collision screening propagates thousands of orbits numerically every day. ### Technical challenges - **[Orbit propagation](https://en.wikipedia.org/wiki/Orbit_modeling):** real orbits feel drag, Earth's oblateness, and third bodies; the exact Kepler formula dies, quadrature and ODE integrators survive. - **[Kepler's equation](https://en.wikipedia.org/wiki/Kepler%27s_equation):** even the "exact" route needs numerics in reverse (position from time is transcendental and is solved by root finding, our other course thread). ### Why it matters A Molniya ground station gets roughly $7$ hours of usable dwell from the $60°$ apogee arc you timed, from an orbit that laps Earth in $12$; that single number, computed by quadrature, is why the constellation works. The same transit integrals, at tighter tolerances, schedule every ISS resupply docking. <!-- ============================================================================ AUTHORING CHECKLIST (internal, delete before publishing to students) - [x] Front-matter filled; points/stages metadata only; NO grading content in the body. - [x] Four-beat arc present: symbolic start -> mirror warm-up (Step 1 hand numbers + Step 3 circular machine-precision check) -> guided run (convergence study) + generalization (Molniya dwell, Step 6; eccentricity dial, Scenario B) -> own-orbits finale with personalities (A near-circular / B working eccentric / C extreme). - [x] Su25/v0.2 derivations retained in full (polar area element -> areal velocity -> dt = r^2/h dtheta -> boxed transit integral; circular collapse to Kepler III; Kepler-equation ground-truth note); NO math cut. The Intro's **Idea.** paragraph moved to open the Mathematical Background per v0.5. - [x] Factual claims re-verified in the sandbox (2026-07-11, one run: code/orbital/orbital.py): integrand 4/9, 1, 4 (helper diff 0); perihelion/aphelion 147.06/152.14 (3.46% swing above perihelion); comet ratio 19; ISS T = 5554.7 s (92.58 min), quarter 1388.672 s, h = 51981.8; circular trap error 2.3e-13; Molniya r(0) = 6905.6, r(pi) = 46214.4; t* = 1645.4287 s; trap/Simpson errors at n = 320: 6.200e-3 / 5.548e-8 s, per-doubling ratios 4.00 / 16.00 (orders 2.00 / 4.00); full period 43077.8 s = 11.966 h; full-orbit superconvergence 2.2 / 9.0e-6 / 7.3e-12 s at n = 16/32/64; 60-deg arcs 12.51 / 435.40 min, ratio 34.80; speeds 10.02 / 1.50 km/s, ratio 6.6923 = (1+e)/(1-e) (helper diff 0). All match the v0.2 values (verified 2026-07-10); no corrections needed. v0.2's Su25 CORRECTIONS log kept below. - [x] Language-first callouts (Python/MATLAB/R/Mathematica), Steps 1-5 in each plus Step 6 in four callouts in the generalization section, per-step Look-for lines, same() helper defined in Step 1 of every language; Python run-verified in the sandbox. - [x] Workflow stated ONCE as the [!abstract] callout with real LaTeX; the v0.2 fenced Algorithm/Require/Ensure block REMOVED (algpseudocode lives in the Overleaf write-ups; students practice algorithm style in the Pseudocode Template at Milestone 1). - [x] All published numbers from ONE verified run; handout callouts, Verification Table, and code README generated from the same printout. - [x] Figures: Media/orbital_convergence.png regenerated from the verified run (identical content to the pilot's); Media/orbital_geometry.png (pilot illustration, parameters unchanged) kept as the Introduction figure. No datasets; nothing to download, stated explicitly. - [x] Companions built from their templates; code/orbital/ complete with README; Assignments wired (handout + companions; no data line, no datasets). - [x] Wiki links generous; no em dashes; optional markers parenthesized; section order ends Reflection -> (Optional) Extensions -> (Optional) Real-World Context. - [x] Archived the previous version before structural edits: projects/archive/MATH307Su26 - Orbital Mechanics and Numerical Integration_20260711-221458.md. RETROFIT LOG (v0.2 -> v0.5.1, 2026-07-11) - Mathematics and verified numbers KEPT unchanged; this was a structural retrofit. - Per-step four-language callouts -> language-first callouts (one per language, all steps inside), with a NEW Step 1 warm-up defining the same() verification helper and reproducing every hand warm-up number before any orbit is drawn. Old Steps 1-4 became Steps 2-5; the full-orbit superconvergence numbers moved from prose-only into Step 4 code in all four languages (every published number is now code-generated). - Fenced algorithm block -> [!abstract] workflow callout (numbered list, real LaTeX). - ALL stage/grading content removed: the "Four stages, four points" paragraph, the Stages & Points section + table, the four per-stage [!tip] callouts, and Reusable Templates (that system lives on the Assignments page and in forms/; front-matter points/stages are metadata). - Analysis Framework -> Reflection Framework (categories kept: Convergence and cost / Geometry and physics / Mathematical insights); the dial question extended to cover the finale orbits. - Exploration section -> Generalization (Step 6): Scenario A code moved into four per-language callouts with the speed-ratio identity run through the helper; Scenario B kept as the student-run study (no published numbers, deliberately); NEW "Verify the generalization" callout added from the run. - NEW own-orbits finale (the fourth beat, per the arc settled in the Multivariate Taylor retrofit): three real orbits with eccentricity personalities (near-circular / working eccentric / extreme), the difficulty dial read before computing, per-orbit Kepler-exact verification, n-for-tolerance cost, dwell ratio, cross-orbit ranking defended from numbers. GPS/Molniya same-a pairing suggested as a teaching hook. Students look up (a, e) with cited sources; GM for Earth and Sun supplied. - Section order: Real-World Context moved to CLOSE the handout, after (Optional) Mathematical Extensions; both carry parenthesized (Optional) markers per template v0.5.1. Real-World content itself unchanged (already Applications / Technical challenges / Why it matters). - "Exploration task" renamed "Application task"; Project Description gains the four-pass arc paragraph and the companions sentence; Key deliverable rewritten for the finale. - est_time 6-9 -> 7-10 hours (the finale adds three own orbits). - Handout Step 5 plotting now shows the figure (plt.show()); the run-verified scripts in code/orbital/ save language-suffixed files instead (Media/ writes removed from student code). KEPT FROM v0.2: CORRECTIONS from Su25 (logged at port time, 2026-07-10) - (1) Earth radius fixed 6330 -> 6371 km (ISS a 6738 -> 6779, T 91.7 -> 92.6 min); (2) the convergence study moved from the circular orbit (constant integrand, trap exact, no visible order) to the Molniya quarter arc with a Kepler-equation exact value; (3) "the integral has no elementary solution" reframed honestly (closed form exists via eccentric anomaly; the INVERSE problem is transcendental); (4) full-orbit periodic superconvergence surfaced as a Note instead of silently contradicting the O(h^2) story; (5) video 5-7 min -> 5. - [ ] Reviewer pass on retrofit rev 1 (Scott). ============================================================================ -->