N-body equations of motion (heliocentric ecliptic J2000)
> d²r/dt² = -GM☉ r/r³ + Σ GMₚ [(rₚ-r)/|rₚ-r|³ - rₚ/|rₚ|³] + a_GR + a_Yarko
> Direct + indirect terms for each perturber rₚ. V3.0 perturber list (26 bodies):
Major planets (8): Mercury, Venus, Earth (proper, not EMB), Mars, Jupiter, Saturn, Uranus, Neptune
Moon (1): separated from Earth-Moon barycentre using low-precision Brown/Meeus lunar series (~1 arcmin position accuracy, ~10 km on Moon)
Big-16 main-belt asteroids: Ceres, Pallas, Vesta, Hygiea, Davida, Interamnia, Europa, Sylvia, Cybele, Euphrosyne, Eunomia, Juno, Psyche, Thisbe, Doris, Patientia. Together ~50% of total MBA mass.
> Schwarzschild GR: a = (GM☉/c²r³)·[(4GM☉/r - v²)·r + 4(r·v)·v]
> Yarkovsky thermal drag: a = A2·(r₀/r)²·v̂ (A2 = -2.901×10⁻¹⁴ AU/d² for Apophis)
Earth/Moon split (new in V3.0)
> Old V2.0 used a single point mass at the Earth-Moon barycentre with combined GM. This conflates two bodies separated by ~384,400 km — fine far from Earth, but during the 2029 close pass at 38,000 km from Earth's centre the Moon's individual pull and offset position become resolvable.
> r_Earth(t) = r_EMB(t) - μ_M · d_geo(t), where μ_M = m_Moon/(m_Earth+m_Moon) = 1/82.3 = 0.01215
> r_Moon(t) = r_EMB(t) + (1-μ_M) · d_geo(t)
> d_geo(t) is the geocentric Moon vector from a truncated Meeus lunar series (top ~13 longitude terms, 8 latitude terms, 11 distance terms). Position error vs full ELP-2000 is ~10 arcsec ≈ ~20 km on the Moon — negligible for Apophis perturbation.
Asteroid perturber model (new in V3.0)
> Each MBA propagates on a fixed Keplerian orbit with constant osculating elements (a, e, i, Ω, ω, M₀ at J2000). Their orbits are stable enough over the 15-yr integration span (2017–2032) that this introduces <0.1″ position error per asteroid — well below the perturbation-resolution threshold.
> Per-asteroid rotation matrices are precomputed once at startup; each acceleration call needs only one Kepler solve per asteroid.
> GMs from IAU-recommended masses; total Big-16 mass ≈ 1.7×10⁻⁹ M☉ ≈ 47% of total main-belt mass. Ceres alone is ~28%.
Integrator (unchanged from V2.0)
> Dormand-Prince 5(4) embedded Runge-Kutta, 7-stage FSAL, adaptive step with PI controller (k_i=0.4/p, k_p=0.7/p, p=5)
> Tolerance abs/rel = 1×10⁻¹¹; typical step size 0.5-2 days, contracts near close encounters
> State cache stored at every accepted step; Hermite cubic interpolation for arbitrary JD lookups
What this is NOT
> Not DE441. The JPL DE441 ephemeris is a multi-GB binary file of Chebyshev coefficients distributed by NAIF, accessed via SPICE. It is not deployable as a static browser asset. V3.0 uses Standish (1992) approximate Keplerian elements for the planets — same form as V2.0, just extended to all 8 planets. Planet position errors vs DE441 are ~arcseconds (1800–2050 epoch range), translating to ~10⁻⁸ AU errors in their pull on Apophis: well below the dominant integration uncertainties.
> Not the full DE441 perturber list. JPL Horizons uses ~340 perturbing bodies (8 planets + Pluto + Moon + 343 asteroids in the small-body integration). V3.0 stops at the Big-16 because (a) cumulative MBA mass beyond #16 is <25% of the Big-16 total, and (b) browser performance becomes a real concern past ~30 perturbers.
Expected accuracy at 2029 closest approach
> V2.0 (6 perturbers, EMB-only): ~10,000 km vs JPL Horizons (factor ~100 better than pure Kepler)
> V3.0 (26 perturbers, separated Moon, +Uranus/Neptune, +Big-16 MBAs): expected ~1,000–3,000 km vs JPL Horizons (factor ~3–10 improvement over V2.0)
> Dominant remaining errors: (1) Standish vs DE441 planet positions; (2) approximate Moon theory; (3) MBAs beyond Big-16; (4) simplified PPN gravity (we include only the dominant Sun term, not Jupiter or other bodies)
✓ Live diagnostics: integration step count, Sun-only round-trip self-test, and per-perturber acceleration shown above. The self-test integrates Sun-only Keplerian dynamics forward 5 years then backward to the start; round-trip position error directly measures integrator quality (typically < 1 km at tol=1e-11). Real perturbed dynamics are not energy-conserving — close encounters with Earth and Venus continually exchange energy with Apophis.
⚠ For mission-grade precision use REBOUND/IAS15 with the full DE441 ephemeris and asteroid perturbation files. After 2029, Apophis transitions Aten → Apollo class (a: 0.92 → 1.10 AU).