Read Latex

Sunday, March 08, 2026

The Astrologer's Executive Order

Query:
Due to the gradual onset of dementia, a certain world leader hires an astrologer. Over the course of a few days, the astrologer convinces the leader that predicting world events would be much easier if the year were exactly 360 days long in 12 months of 30 days each. An executive order is issued declaring a major engineering project to accomplish this change.
How much energy would be required? Is it within the envelope of current nuclear reserves? If the nuclear reserves were used to turn ocean water into steam and eject it into space, how much water would be required? What would be the environmental impact?

Analysis:

The Energy Deficit: Changing the semi-major axis by 1.4 million kilometers requires extracting a massive amount of orbital energy:

$$\Delta E = \frac{\mu_\odot M_\oplus}{2} \left( \frac{1}{a_{old}} - \frac{1}{a_{new}} \right) \approx -2.57 \times 10^{31} \text{ Joules}$$

The total global nuclear arsenal is roughly $5.0 \times 10^{19} \text{ Joules}$. The order is underpowered by a factor of 500 billion.

The Propellant Crisis:
To lower the orbit, Earth must decelerate by $\Delta v \approx 144 \text{ m/s}$. Using the rocket equation and assuming a nuclear thermal exhaust velocity of 15 km/s (leaving $v_\infty = 10 \text{ km/s}$ after escape velocity):

$$M_{propellant} \approx 8.5 \times 10^{22} \text{ kg}$$

To achieve a 360-day year using water as reaction mass, the Earth's entire ocean inventory must be boiled and ejected roughly 60 times over.

Execution and Impact:
Continent-sized thrusters would need to fire at the equator in discrete, short bursts exactly at local dawn to direct the thrust prograde. The environmental impact is complete planetary sterilization—flash-incinerating the biosphere and triggering mantle decompression melting.

Query:
Since boiling the oceans away seems ill-advised, is there a procedure like ejecting the moon from Earth orbit that could have an equivalent effect?

Analysis:
By applying conservation of linear momentum to the Earth-Moon barycenter system:

$$M_\oplus \Delta v_\oplus = M_L \Delta v_L$$

To induce a 144 m/s retrograde deceleration on Earth, the Moon must be accelerated prograde by $11.7 \text{ km/s}$. Firing during the Full Moon phase aligns the velocity vectors perfectly, ejecting the Moon into an independent heliocentric orbit and pushing Earth backward.

However, the kinetic energy required ($E_k \approx 5.03 \times 10^{30} \text{ Joules}$) is still 100 billion times greater than the global nuclear arsenal. Loss of the Moon would also collapse ocean currents, destabilize Earth's axial tilt (obliquity), and halt tidal braking.

Query:
Analyze the structural integrity limits of the Moon to determine if applying $5.03 \times 10^{30}$ Joules of kinetic energy (using fusion technology) would exceed its gravitational binding energy and shatter it before it could transfer the momentum.

Analysis:
The Moon's gravitational binding energy ($U_L$) is:

$$U_L = \frac{3GM^2}{5R} \approx 1.24 \times 10^{29} \text{ Joules}$$

The energy required to eject the Moon is roughly 40 times greater than the energy required to completely vaporize it.

The fusion pulse acts hydrodynamically. The shockwave velocity vastly exceeds the speed of sound in lunar silicate. The Moon ceases to be a rigid body and behaves like a fluid, ripping apart and accelerating the fragments radially outward.

Query:
Calculate the orbital mechanics of this resulting debris field to determine what percentage of the fragmented Moon would impact Earth versus forming a permanent Kessler-syndrome debris ring around the planet.

Analysis:
The surplus energy yields an expansion velocity of $v_{exp} \approx 11.55 \text{ km/s}$. Added to the initial center-of-mass velocity ($11.7 \text{ km/s}$):

  • Prograde/Transverse Fragments: Velocity exceeds $16 \text{ km/s}$, escaping Earth entirely (98-99% of mass).
  • Retrograde Fragments: Velocity drops below Earth escape velocity ($1.44 \text{ km/s}$). Captured by Earth (1-2% of mass).

This bound mass ($7 \times 10^{20}$ kg) falls into highly eccentric orbits. Fragments with a perigee $> 6371$ km circularize within Earth's Roche limit, forming a spectacular, permanent equatorial ring system.


Part 1: Climate and Kepler's Third Law

Query:
Act as an astrophysicist and orbital mechanics expert and answer this:
The current Earth year is approximately 365.25 days long.
If the orbital period of the Earth around the sun were changed so that the year were 360 days long, what effect would that have on the climate of the Earth? How much would the average temperature and solar irradiance change? Would it be a non-issue or destabilizing?
I would estimate the average temperature would increase by 365.25/360 or ~1.46 percent. How accurate is my back-of-the-envelope estimate?

Analysis:
To determine the new distance from the Sun, we apply Kepler's Third Law, which states that the square of the orbital period $P$ is proportional to the cube of the semi-major axis $a$:

$$\left(\frac{P_{new}}{P_{old}}\right)^2 = \left(\frac{a_{new}}{a_{old}}\right)^3$$

Solving for the new semi-major axis ratio:

$$\frac{a_{new}}{a_{old}} = \left(\frac{360}{365.25}\right)^{\frac{2}{3}} \approx 0.9904$$

A 360-day year requires the Earth to orbit closer to the Sun, reducing the semi-major axis by approximately 0.96%.

Solar Irradiance: The Inverse Square Law
Solar irradiance $S$ scales inversely with the square of the distance from the Sun:

$$S \propto \frac{1}{a^2}$$

Using the period relationship, we can express the new solar irradiance directly as a function of the orbital period:

$$\frac{S_{new}}{S_{old}} = \left(\frac{365.25}{360}\right)^{\frac{4}{3}} \approx 1.0195$$

The average solar irradiance hitting the top of Earth's atmosphere would increase by 1.95%. Given the current solar constant of roughly 1361 W/m², the new solar constant would be approximately 1387 W/m².

Average Temperature: Stefan-Boltzmann Law
To find the new equilibrium temperature $T$, we model the Earth as a thermal radiator using the Stefan-Boltzmann law, where radiated power scales with $T^4$. Therefore, temperature scales with the fourth root of solar irradiance:

$$T \propto S^{\frac{1}{4}}$$

Substituting our period relationship yields the direct proportionality between temperature and orbital period:

$$\frac{T_{new}}{T_{old}} = \left(\frac{365.25}{360}\right)^{\frac{1}{3}} \approx 1.00484$$

The Earth's average absolute temperature would increase by 0.484%.

Evaluating the Back-of-the-Envelope Estimate
The estimate of a 1.46% increase successfully captured the direct ratio of the periods:

$$\frac{365.25}{360} - 1 \approx 0.0146 \text{ (or 1.46\%)}$$

However, the estimate assumed a linear, 1:1 proportionality where $\Delta T / T = \Delta P / P$. As derived above, the true physical relationship is $T \propto P^{-1/3}$.

Because of the geometry of space (inverse square) and the thermodynamics of radiation (fourth power), the percentage change in temperature is exactly one-third of the estimated percentage change in the orbital period.

Climate Impact: Destabilizing or Non-Issue?
Applying the 0.484% increase to Earth's current average effective absolute temperature of roughly 288 K (15°C) yields:

$$\Delta T = 288 \text{ K} \times 0.00484 \approx 1.39 \text{ K}$$

An instantaneous increase of 1.39 K (or 1.39°C) is highly significant. It falls directly into the category of severe disruption, roughly equivalent to the total anthropogenic global warming observed since the pre-industrial era. It would rapidly accelerate polar ice melt, raise sea levels, and shift agricultural biomes, requiring massive adaptation.


Part 2: Mass Redistribution and Geomechanics

Query:
Consider the shift in mass the melting of the ice caps would produce and estimate the likelihood that this mass distribution change would change the intensity or frequency of earthquakes.

Analysis:

Orbital Eccentricity and Seasonal Extremes
Changing the orbital period requires an alteration of the semi-major axis $a$. According to the vis-viva equation:

$$v^2 = GM \left(\frac{2}{r} - \frac{1}{a}\right)$$

Unless the energetic perturbation that reduces $a$ is applied as a perfectly distributed radial force or a perfectly timed two-impulse maneuver, the orbital eccentricity $e$ will change. If the perturbation increases $e$, the amplitude of seasonal radiative forcing will amplify, subjecting one hemisphere to more extreme summer and winter temperature variations.

Mass Redistribution and the Inertia Tensor
Melting the polar ice caps transfers immense mass from high latitudes into the global ocean basins. This shifts mass further from the axis of rotation, increasing the Earth's principal moment of inertia $I_{zz}$.

Due to the conservation of angular momentum $L = I\omega$, an increase in $I_{zz}$ necessitates a proportional decrease in angular velocity $\omega$. This will measurably slow the Earth's rotation, resulting in a slightly longer day, and induce changes in the true polar wander.

Geomechanics: Seismicity and Glacial Rebound
The likelihood that this mass redistribution would increase the intensity and frequency of earthquakes is extremely high, driven by two processes:

  • Glacial Isostatic Adjustment (GIA): Rapidly melting teratons of ice removes vertical normal stress. This "unclamping" of crustal faults decreases the frictional resistance holding them locked. The lithosphere will undergo flexural isostatic rebound, triggering paraglacial seismicity.
  • Hydro-Isostasy: The meltwater increases the hydrostatic load on the oceanic lithosphere and continental shelves, altering regional stress tensors across fault zones globally.

Part 3: Inertia Tensor and Length of Day

Query:
Mathematically model the change in Earth's moment of inertia $I_{zz}$ and calculate the precise lengthening of the day assuming a specific volume of ice melt.

Analysis:

Estimating the Meltwater Mass

  • Antarctica Ice Volume: $\approx 27 \times 10^6 \text{ km}^3$
  • Greenland Ice Volume: $\approx 2.9 \times 10^6 \text{ km}^3$
  • Total Ice Volume ($V$): $\approx 3.0 \times 10^{16} \text{ m}^3$

Assuming an average ice density of $\rho_{ice} \approx 917 \text{ kg/m}^3$:

$$m = \rho_{ice} V \approx 2.75 \times 10^{19} \text{ kg}$$

Modeling the Change in Moment of Inertia ($I_{zz}$)
For a first-order approximation, the initial ice sheets are located near the geographic poles ($\theta \approx 0$ or $\pi$), so their distance from the axis of rotation is negligible:

$$I_{initial} \approx 0$$

The meltwater redistributes into the global oceans, modeled as a uniform thin spherical shell of mass $m$ and radius $R_\oplus$ ($6.371 \times 10^6 \text{ m}$):

$$I_{final} = \frac{2}{3} m R_\oplus^2$$

Calculating the change in the inertia tensor's principal component:

$$\Delta I_{zz} = I_{final} - I_{initial} \approx \frac{2}{3} (2.75 \times 10^{19}) (6.371 \times 10^6)^2$$

$$\Delta I_{zz} \approx 7.44 \times 10^{32} \text{ kg}\cdot\text{m}^2$$

Calculating the Change in Length of Day ($\Delta T$)
Invoking the conservation of angular momentum ($L = I_{zz} \omega = \text{constant}$):

$$\frac{dT}{T} = \frac{dI_{zz}}{I_{zz}}$$

Plugging in the baseline length of a day ($T = 86,400 \text{ seconds}$) and Earth's initial moment of inertia ($I_0 \approx 8.03 \times 10^{37} \text{ kg}\cdot\text{m}^2$):

$$\Delta T = 86400 \left( \frac{7.44 \times 10^{32}}{8.03 \times 10^{37}} \right) \approx 0.801 \text{ seconds}$$

A total collapse of the polar ice sheets increases Earth's moment of inertia by roughly 0.0009%, decelerating the Earth's rotation and lengthening the day by approximately 800 milliseconds, thoroughly disrupting Coordinated Universal Time (UTC).


Part 4: Oblateness and Sun-Synchronous Orbits

Query:
Examine how this specific mass redistribution and the resulting change in Earth's oblateness (the $J_2$ gravitational perturbation) would affect the nodal precession rate of sun-synchronous satellites.

Analysis:
Using MacCullagh’s formula for the $J_2$ harmonic:

$$J_2 = \frac{I_{zz} - \frac{1}{2}(I_{xx} + I_{yy})}{M_\oplus R_\oplus^2}$$

Moving the mass from the poles to a uniform global distribution yields a net positive change in $J_2$:

$$\Delta J_2 = \frac{m}{M_\oplus} \approx \frac{2.75 \times 10^{19}}{5.972 \times 10^{24}} \approx 4.60 \times 10^{-6}$$

Given Earth's current $J_2 \approx 1.0826 \times 10^{-3}$, this mass shift increases the $J_2$ coefficient by approximately 0.425%.

Impact on Nodal Precession ($\dot{\Omega}$)
The secular variation of the node $\dot{\Omega}$ is directly proportional to $J_2$:

$$\dot{\Omega} = -\frac{3}{2} n J_2 \left(\frac{R_\oplus}{a(1-e^2)}\right)^2 \cos i$$

An uncorrected 0.425% increase in nodal precession translates to an extra $\approx 0.0042^\circ$ of precession per day. Over a standard Earth year, the satellite's orbital plane would drift by approximately $1.5^\circ$. This shifts the Local Time of Ascending Node (LTAN) by roughly 6 minutes per year, ruining the lighting conditions for Earth observation platforms.


Part 5: Plane-Change Maneuvers and Delta-v

Query:
Formulate the specific plane-change maneuver equations to calculate the exact $\Delta v$ (delta-v) budget required for a satellite to continuously correct this inclination drift, and discuss why a one-time major correction would not be sufficient.

Analysis:
A one-time RAAN correction only resets the phase of the orbit. Because the dynamical environment ($J_2$) has permanently increased, the nodal precession rate remains off-nominal, and the orbit will immediately begin drifting again. To permanently arrest this drift, the operator must alter the inclination to establish a new sun-synchronous equilibrium.

Target Inclination Shift ($\Delta i$)

$$\Delta i = \frac{\Delta J_2}{J_2} \cot i$$

For a standard SSO ($h \approx 700 \text{ km}$, $i \approx 98.2^\circ$):

$$\Delta i = 0.00425 \times \cot(98.2^\circ) \approx -0.035^\circ$$

The $\Delta v$ Budget
Using the circular orbital velocity $v \approx 7508 \text{ m/s}$:

$$\Delta v \approx v \Delta i \approx 7508 \times 0.000612 \approx 4.6 \text{ m/s}$$

A one-time burn of 4.6 m/s establishes a new stable inclination.

If an operator attempts to brute-force the node $\Omega$ back to its target value every year (continuous correction):

$$\Delta v_{\Omega} = 2v \sin i \sin\left(\frac{\Delta \Omega}{2}\right) \approx 193 \text{ m/s}$$

Fighting the new $J_2$ harmonic directly requires 193 m/s of $\Delta v$ every year, which is unsustainable.

Query:
Is the one-time delta V a superior solution compared to the frequent correction scenario originally proposed?

Analysis:
Unequivocally, yes. Using the Tsiolkovsky rocket equation for a monopropellant system ($I_{sp} \approx 220 \text{ s}$):

  • One-Time Change (4.6 m/s): Requires ~0.2% of the spacecraft's mass in propellant. Establishing dynamical harmony.
  • Continuous Correction (193 m/s/yr): Requires ~8.5% of the spacecraft's mass every year. Forced control violates core principles of spacecraft mass management.

Query:
Would there be any advantage to using several corrective burns rather than one, or would that require an unnecessary cost of having to recompute ground tracks and time to revisit a specific location?

Analysis:
Executing the plane change as a series of smaller, distributed burns is mathematically necessary to mitigate finite-burn (cosine) losses.

Achieving 4.6 m/s requires continuous thrust over a wide orbital arc, directing thrust into changing eccentricity rather than pure inclination. Splitting the maneuver into multiple burns at the nodes maximizes the efficiency factor $\eta$. It also allows for calibration burns to mitigate execution errors. The temporary loss of pristine science data during the multi-day transition is an acceptable operational cost.


Part 6: Geodetic Projections and State Propagation

Query:
Examine the exact matrix transformations used to project this new drifting orbital state vector down to the WGS84 reference ellipsoid to map the temporary ground tracks.

Analysis:
The full transformation from the Geocentric Celestial Reference Frame (GCRF) to the International Terrestrial Reference Frame (ITRF) includes precession ($P$), nutation ($N$), and polar motion ($W$):

$$\mathbf{r}_{ECEF} = W \cdot R_z(\theta_g) \cdot N \cdot P \cdot \mathbf{r}_{ECI}$$

The Geodetic Caveat: WGS84 relies on a defined eccentricity tied to Earth's dynamical oblateness ($J_2$). Because $J_2$ increased by 0.425%, the Earth is physically more oblate. A new reference ellipsoid ("WGS-Melt") must be defined to avoid massive projection errors at mid-latitudes.

Using the updated ellipsoid parameters, an iterative algorithm transforms Cartesian ECEF to Geodetic coordinates (Longitude, Latitude, Altitude).

Query:
Examine the software architecture required to propagate this perturbed state, specifically comparing the use of Cowell's method versus Encke's method for integrating these equations of motion.

Analysis:

  • Cowell's Method: Integrates the total acceleration vector directly ($\ddot{\mathbf{r}} = -\frac{\mu}{r^3}\mathbf{r} + \mathbf{a}_{pert}$). Simple to code but computationally expensive due to the dominant $1/r^2$ central-body force requiring very small time steps.
  • Encke's Method: Isolates the perturbation by integrating only the difference between the true perturbed orbit and an ideal, unperturbed osculating reference orbit ($\delta\ddot{\mathbf{r}}$). It uses a functional expansion $f(q)$ to avoid subtractive cancellation. Allows for much larger step sizes, making it vastly superior for long-term orbital lifetime simulations, though it requires complex rectification triggers.

Part 7: The Aftermath - Climate, Atmosphere, and Geology

Query:
Evaluate the thermal radiation dynamics of this new ring system to see how its shadow and reflected albedo would permanently alter Earth's global climate equilibrium.

Analysis:
The ring has a massive optical depth, making it opaque to shortwave solar radiation.

  • Shadow: Casts a deep-freeze umbra across the winter hemisphere and equator.
  • Albedo: The illuminated night-side of the rings scatters "ringlight" down, preventing the night side from radiating thermal energy.

The global thermal equilibrium violently skews, creating extreme latitudinal thermal gradients between the boiling summer hemisphere and the frozen, shadowed winter hemisphere.

Query:
Model the atmospheric fluid dynamics using the Navier-Stokes equations to estimate the sustained wind velocities generated by this planetary thermal gradient.

Analysis:
Using the Thermal Wind Equation (derived from geostrophic and hydrostatic balance):

$$\frac{\partial u}{\partial z} = -\frac{g}{f T_0} \frac{\partial T}{\partial y}$$

With an estimated temperature gradient of $1.5 \times 10^{-4} \text{ K/m}$ across the shadow boundary, the vertical wind shear is $\approx 0.049 \text{ (m/s)/m}$. Integrating this to the tropopause yields sustained, planet-encircling winds of 490 m/s (Mach 1.4).

Query:
Calculate the aerodynamic stagnation temperature (aerodynamic heating) that any surviving ground structures would experience.

Analysis:
Using the compressible flow stagnation temperature relationship:

$$T_0 = T \left( 1 + \frac{\gamma - 1}{2} M^2 \right)$$

At Mach 1.4 and an ambient temperature of 300 K, the stagnation temperature hits 417.6 K (144°C). The dynamic pressure ($q = \frac{1}{2} \rho v^2$) reaches 144,060 Pascals (1.42 atm)—50 times greater than a Category 5 hurricane.

Query:
Examine how friction from this expanded atmosphere increases orbital drag on the Kessler ring, leading to glowing re-entry.

Analysis:
Aerodynamic heating causes the thermosphere to expand radially. As the expanded scale height intercepts the inner ring, drag decelerates the fragments (inversely proportional to their ballistic coefficient). This triggers a runaway positive feedback loop: ablation deposits massive heat into the upper atmosphere, further expanding the scale height, swallowing the next orbital band of debris. The sky becomes a continuous, glowing envelope of ablating lunar basalt.

Query:
Calculate the electromagnetic consequences of this continuous ablation layer, specifically how a permanent global plasma sheath would completely absorb all radio frequencies.

Analysis:
Ablative ionization floods the upper atmosphere with free electrons. Calculating the plasma frequency based on an expected electron density of $10^{18} \text{ electrons/m}^3$:

$$f_p \approx 8.98 \sqrt{n_e} \approx 9 \text{ GHz}$$

This creates an electromagnetic blackout for all frequencies below 9 GHz (HF, VHF, UHF, GPS, and most satellite comms). Collisional damping converts EM wave energy into thermal heat, effectively sealing the Earth inside a glowing, radio-opaque Faraday cage.

Query:
What happens thousands of years later when the ring is exhausted, the atmosphere cools, and the lunar material settles?

Analysis:
As temperatures drop below 2000°C, the vaporized silicates condense as tektite and microtektite rain. Distributing the $7.34 \times 10^{20}$ kg of bound lunar debris evenly across Earth's surface area results in a global stratigraphic layer (the "Astrologer's Stratum") approximately 480 meters thick.

The new crust is completely anhydrous, rich in anorthosite and basalt, and heavily oxidized (turning the planet a deep Martian red). When the hydrological cycle finally resumes, torrential rains interacting with the fresh lunar ash create shallow, heavily mineralized, caustic oceans.

The calendar is perfectly aligned, but the Earth is unrecognizable.

Thursday, March 07, 2024

Andrew’s Instant Math Club

In previous blogs, I described conversations with Andrew Bauman, an up-and-coming mathematician who is an undergrad at UALR and who spends spare time tinkering with problems in linear algebra and quantum mechanics. Today, in one of our gym-facilitated meetings, Andrew brought three distinguished and enjoyable intellects besides himself. This led to a wide-ranging conversation that I will attempt to recap here for posterity. We will start with a sidebar since the evening was full of them, some recursive, some eight layers deep.


Before tonight’s impromptu, mostly math and quantum computing discussion, I checked in with our pool lifeguard, a pole vaulter (not the back flipping fellow above, but certainly capable). A review of video footage of his record pole vault revealed excellent form, with one specific moment that could benefit from an improvement that consisted of pressing to a handstand and walking on one’s hands. This body position is attained for less than a second during the pole vault but is critical to obtaining greater heights. He showed me footage of his hand standing and walking, which was quite good. It gave me ideas for a follow-up exercise involving an inverted shoulder shrug, an inverted pole grip change/grip walk, and an inverted kip-up that could benefit him further. I’m writing this here as part of a stream-of-consciousness recap so I don’t forget it in the twists and turns of what follows.

Weight, there's more:

I strapped a 5 lb weight on each hip for my nightly mile walk/run tonight. However, due to the chance encounter with Andrew (and company), I did not make it to my walk, but I sported the weights like a pair of revolvers from the Wild West. Anyone seeing our extended conversation would have to wonder, “Why a weight belt for talking about math?”. Answer, “Heavy Topic”!

Andrew paused his ping-pong game to introduce me to his ping-pong partner, Dr. Sudan Xing, a mathematician and professor at UALR who specializes in geometric projection and embedding problems.

A peek at Google Scholar introduces us to the central theme of Dr. Xing's work, which is focused on the Orlicz-Brunn-Minkowski theory and related Minkowski problems in convex geometry. This theory is an extension of the classical Brunn-Minkowski theory, which deals with the relationship between the volumes of convex bodies and their Minkowski sums.

Now I’m a dolt, so I wanted to know what a simple Minkowski sum looked like, so I asked ChatGPT-4 to write me some code and produced the figure below. It was almost a 1-shot job; more recent work I have done has taken nearly 40 shots/redos to get right. The code is here.




The mathematics involved in her work primarily comes from convex geometry, functional analysis, and measure theory. Key concepts include:

  • Convex bodies and functions
  • Minkowski addition and Orlicz addition
  • L_p norms and Orlicz norms
  • Surface area measures and the Minkowski problem
  • Brunn-Minkowski and isoperimetric inequalities
  • Log-concave functions and measures

Dr. Xing's work contributes to developing a more general theory of convex bodies and related geometric inequalities, with potential applications in mathematics and beyond.

Next, we met her bioinformatics colleague, Ju Ni. We discussed how exciting it was to live in the time of AI/ML and the OMIM database, where we can know the genes involved in almost any affliction of human beings. We discussed the importance of visualizing gene and biochemical pathways for specific conditions. We discussed the particular example of Thyroid Cancer, one of the only truly “curable” cancers, since it can be treated with Iodine-131, which is preferentially taken up by the thyroid, thus neutralizing the cancer, but alas, the thyroid as well, necessitating lifelong medication afterward.

We briefly referenced a certain Calculus book, a Facebook math site, and my AddSubMulDivia five-book series “that nobody reads.” We had a good laugh about how pathetic it is to care so much about things no one else does.

Dr. Xing and I found out we shared appreciation for 2010 Fields medal laureate Cedric Villani, a mathematician and politician who is friends with the president of France. Quoting from my favorite LLM:

Villani revolutionized mathematical physics with contributions to optimal transport theory, kinetic theory, partial differential equations, and the study of Ricci curvature in metric spaces. His work, notable for bridging pure mathematics with applied physics, includes groundbreaking analyses of the Boltzmann equation and its convergence to the Landau equation, shedding light on gas behaviors in varied regimes. Villani's innovative use of optimal transport for exploring metric spaces with Ricci curvature bounds has influenced areas ranging from plasma physics to network analysis.

We talked about:

the advent of AI/ML is enabling the revisiting of unsolved math problems

  • symbolic algebra (now called CAS)
  • symbolic geometry, invented by my friend Phil Todd and his program Geometry Expressions™
  • Andrew mentioned he was working on a problem that starts with drawing a bisecting line on a piece of paper, and proving that the halfspaces generated by the line are distinct.

    Dr. Xing responded with H+/H- halfspaces, then visualized the problem in 3D with her 'ping-pong paddle' analogy. She discussed the 'floating problem' – a sphere trimmed into equal-volume sections by tangent planes. This process seems to give the sphere unique properties, but we switched topics too quickly.

    We touched on projective geometry and how representation (explicit, implicit, parametric, iterated, chaotic) influences what we can understand about a problem. I mentioned the challenges of intersecting closed tensor product surfaces made with B-splines and wondered if Dr. Xing's dualized projection approach could help.

    I mentioned my curiosity about a set of planar ray tracing problems as a family of reachability problems that are quite interesting. These live under the heading “Visibility Polygon” and the Art Gallery Problem.


    We talked a lot about how people conceptualize various kinds of mathematical concepts.

    At this time, Greg, a friend of Andrew’s, had arrived. He has a Master’s degree and was focusing on math education.  Dr. Xing and Ju Ni had to go, so Greg, Andrew, and I started drilling down on several topics.

    The topic space exploded before we settled down and had a heart-to-heart on quantum computing and Bell’s Inequality.

    Topic Explosion (Free Association Gone Wild)

    • inner products and their connection to standard deviation and variance
    • Hilbert spaces, norms
    • distance metrics: Euclidean, Manhattan, Minkowski
    • closure loss on the inclusion of zero
    • maintaining state on chained binary operations of AddSubMulDiv-ia to enable reversibility and prevent the loss of structure of the path of a calculation that would otherwise be non-unique if results were discarded at intermediate states. Undoability.
    • skew and kurtosis being higher moments in statistics
    • discrete and continuous distributions
    • moments in structural mechanics and moments of inertia.I demonstrated how a phone tossed in space will land without a change in rotation in two of its three axes but not the third. The Veritasium link below explains it better.
    • Spaghetti Sort as an analogy to quantum computing simultaneous equation solving using entangled particles.
    • The mystery of entanglement is the same as having tossed a coin that landed heads and automatically knowing that the other particle’s spin is “tails”.
    • The Bloch sphere
    • Bell’s inequality
    • Alice and Bob’s experiment: A stream of entangled particles
    • Quantum and Classical Interpretations of the experiment
    • The interchangeability of streaming and fixed interval experiments
    • Interval arithmetic
    • The register operation of comparing A and B’s results,
    • XNOR was the decision operator correctly identified by Greg
    • Marvin Minsky’s XOR catastrophe started the AI winter, requiring two neurons.

    Links




    Tuesday, March 05, 2024

    Sorting out Sorting in 16 Shots with an LLM




    In an homage to the seminal computer animation, "Sorting out Sorting" by Ronald M. Baecker and David Sherman at  University of Toronto, presented at SIGGRAPH 1981, this present day retrospective embarked on a man-machine collaboration to revisit the concept with modern LLM technology. To complete this "quick-hack" nod to the original, ChatGPT-4, was employed to illuminate the intricacies of sorting algorithms through a Python demonstration that was built and run for multiple cases in an evening - a much shorter period of time that coding this from scratch, for this author anyway.

    In the end, this collaboration focused on four sorting algorithms: quicksort, bubblesort, insertion sort, and selection sort. Each algorithm was animated to showcase its operational nuances and performance implications, dependent on the array size.

    The exploration spanned various case studies, from sorting four items to the challenge of a forty-item array. These cases illustrated the performance scalability of each algorithm, reinforcing the importance of algorithm choice based on data size and structure.

    The effort culminated in a Python-based animation, refined across 16 shots to aid clarity, accuracy, and pedagogical value. This man-machine collaboration with ChatGPT-4 underscores the synergy between human expertise and artificial intelligence in computer science education.

    For those intrigued by the nuances of algorithm efficiency and the visual pedagogy of sorting, this quick project serves as a testament to the enduring relevance of the original "Sorting out Sorting" and the evolutionary journey of computational teaching tools and the technology that drives them.

    Results:

    Note the number of steps that each sort took for each of the size-item cases:

    1) The four-item case:




    2) The five-item case:



    3) The ten-item case:


    4) The twenty item case:


    5) The forty item case:




    Observations
    Notice the relatively poor performance of quicksort relative to the other sorts for small numbers of items and the relatively good performance of selection sort.


    TLDR;

    Parallel attempts were made using ChatGPT-3.5 and Claude3-Opus, but these fell short of expectations, so the author used ChatGPT-4 to execute a brief exploration of sorting algorithms. The conversation that led to acceptable code required16 iterative chat laps outlined for those who are coding with Large Language Models (LLMs) as follows:

    1. Initial Request: Asked for a Python demo to animate sorting with a comparison of quicksort and bubblesort in Jupyter Notebook using Google Colab.
    2. Clarification and Correction: Adjustments were made to increase the array size, which caused an IndexError.
    3. Fix for IndexError: Provided a solution to fix the IndexError related to the array size increase.
    4. Background Color Adjustment: You requested changing the graph background to your trademark color and further adjustments.
    5. Sorting Algorithm and Layout Update: Requested adding mergesort to the comparison and faced an execution error.
    6. Alternative Sorting Algorithm: Suggested using insertion sort as an easier alternative for visualization.
    7. Visualization Enhancement: Added detailed visualization for tracking the sorting process with colors.
    8. Error Handling: Addressed an IndexError related to indexing issues in the updated visualization code.
    9. Additional Sorting Algorithm and Grid Layout: Included a fourth sorting algorithm and updated the layout to a 2x2 grid.
    10. Visual Tracking Features: Requested marking special elements (pivot, etc.) with specific colors for clarity, this was successful, though quite complex to track.
    11. Step Annotations Missing: Noted that step annotations were dropped from the visualization.
    12. Reintroduction of Step Annotations: Added step annotations back into the visualization for clarity.
    13. Title Color Adjustment: You wanted the titles of the sorting algorithms colored blue.
    14. Legend Addition: Asked to add a legend explaining the color coding of the elements.
    15. Legend Visibility Issue: Addressed the issue where the video progress bar covered the legend.
    16. Conclusion: Expressed satisfaction with the assistance provided.

    Python 3 Source: (Run in a Google Colab Jupyter Notebook)

    import numpy as np
    import matplotlib.pyplot as plt
    from matplotlib.animation import FuncAnimation
    import matplotlib.patches as mpatches
    from IPython.display import HTML

    # Initialize data and steps for each sorting algorithm
    np.random.seed(0)
    data = np.random.randint(0, 100, 40)
    steps_qs, markers_qs = [], []
    steps_bs, markers_bs = [], []
    steps_is, markers_is = [], []
    steps_ss, markers_ss = [], []

    # Quicksort with detailed tracking
    def quicksort(arr, lo, hi, steps, markers):
    if lo < hi:
    p = partition(arr, lo, hi, steps, markers)
    quicksort(arr, lo, p - 1, steps, markers)
    quicksort(arr, p + 1, hi, steps, markers)

    def partition(arr, lo, hi, steps, markers):
    pivot = arr[hi]
    i = lo
    for j in range(lo, hi):
    if arr[j] < pivot:
    arr[i], arr[j] = arr[j], arr[i]
    i += 1
    # Markers: pivot (hi), current item (j), and swap position (i)
    markers.append([hi, j, i])
    steps.append(arr.copy())
    arr[i], arr[hi] = arr[hi], arr[i]
    markers.append([hi, i, -1]) # Final swap to place pivot
    steps.append(arr.copy())
    return i

    # Bubblesort with detailed tracking
    def bubblesort(arr, steps, markers):
    n = len(arr)
    for i in range(n):
    for j in range(0, n-i-1):
    if arr[j] > arr[j+1]:
    arr[j], arr[j+1] = arr[j+1], arr[j]
    # Markers: current item (j) and comparison item (j+1)
    markers.append([j, j+1])
    steps.append(arr.copy())

    # Insertionsort with detailed tracking
    def insertionsort(arr, steps, markers):
    for i in range(1, len(arr)):
    key = arr[i]
    j = i-1
    while j >= 0 and key < arr[j]:
    arr[j + 1] = arr[j]
    j -= 1
    # Markers: current item (i) and shift position (j)
    markers.append([i, j])
    steps.append(arr.copy())
    arr[j + 1] = key
    markers.append([i, j+1]) # Placement of key
    steps.append(arr.copy())

    # Selectionsort with detailed tracking
    def selectionsort(arr, steps, markers):
    for i in range(len(arr)):
    min_idx = i
    for j in range(i+1, len(arr)):
    if arr[j] < arr[min_idx]:
    min_idx = j
    arr[i], arr[min_idx] = arr[min_idx], arr[i]
    # Markers: minimum item (min_idx) and current position (i)
    markers.append([min_idx, i])
    steps.append(arr.copy())

    # Sort and track steps
    quicksort(data.copy(), 0, len(data)-1, steps_qs, markers_qs)
    bubblesort(data.copy(), steps_bs, markers_bs)
    insertionsort(data.copy(), steps_is, markers_is)
    selectionsort(data.copy(), steps_ss, markers_ss)

    # Visualization setup

    # Define legend handles
    legend_handles = [
    mpatches.Patch(color='red', label='Unchanged Item'),
    mpatches.Patch(color='blue', label='Pivot / Insertion Point'),
    mpatches.Patch(color='orange', label='Current Item')
    ]

    # Initialize the figure and axes again if needed
    fig, ax = plt.subplots(2, 2, figsize=(8, 8), facecolor='#99CC99')
    for axs in ax.flat:
    axs.set_facecolor('#99CC99')

    # Adjust subplots to make room for the legend below
    fig.subplots_adjust(bottom=0.2)

    # Animation update function with step annotations
    def update(frame):
    # Maps for color coding
    color_map = {0: 'red', 1: 'blue', 2: 'orange', 3: 'green'}
    plots = [steps_qs, steps_bs, steps_is, steps_ss]
    titles = ['Quicksort', 'Bubblesort', 'Insertion Sort', 'Selection Sort']
    markers = [markers_qs, markers_bs, markers_is, markers_ss]
    for axs, plot, title, marker in zip(ax.flat, plots, titles, markers):
    axs.clear()
    axs.set_title(title, color='blue', fontsize=12)
    current_step = plot[min(frame, len(plot)-1)]
    if frame < len(marker):
    current_marker = marker[frame]
    else:
    current_marker = [-1] # Default no marker
    for i, val in enumerate(current_step):
    color = 'red' # Default color
    if i in current_marker:
    color = color_map[current_marker.index(i)]
    axs.bar(i, val, color=color)
    # Annotate current step number on each subplot
    step_text = f'Step: {min(frame+1, len(plot))}/{len(plot)}'
    axs.text(0.35, 0.95, step_text, transform=axs.transAxes, ha='right', va='top', fontsize=12, color='blue', bbox=dict(facecolor='#99CC99', alpha=0.5, edgecolor='none'))
    # Adding credit in the last subplot
    fig.legend(handles=legend_handles, loc='lower center', bbox_to_anchor=(0.5, 0.1), fancybox=True, shadow=True, ncol=3)
    fig.text(1, 0.0, 'Van2024/ChatGPT-4', fontsize=12, color='yellow', horizontalalignment='right', verticalalignment='bottom')



    # Creating the animation
    ani = FuncAnimation(fig, update, frames=max(len(steps_qs), len(steps_bs), len(steps_is), len(steps_ss)), interval=100, repeat=False)

    # Display the animation
    HTML(ani.to_html5_video())