Epicycles, complex Fourier series and Homer Simpson's orbit

Epicycles, complex Fourier series and Homer Simpson's orbit — Mathologer

Mathologer

AI-assisted summary of Epicycles, complex Fourier series and Homer Simpson's orbit — original source. Check the original for full context.

Source published:

Detailed notes

## Background Published on YouTube on July 6, 2018, by the mathematics channel Mathologer, this video explores the geometry and mechanics of epicycles. Motivated by an internet animation drawing Homer Simpson using nested circles, the presentation provides a crash course on complex Fourier series, corrects common intuitions about the Moon's solar orbit, and provides tools for viewers to generate their own epicycle drawings.

## TL;DR The video investigates how compounded circular motions can trace complex curves, beginning with the straight-line motion of the Tusi couple and debunking the misconception that the Moon's orbit around the Sun contains looping petals. Mathologer traces the historical evolution of epicycles from Ptolemy's and Copernicus's astronomical models to Joseph Fourier's modern harmonic analysis. He demonstrates how any closed continuous path—including Homer Simpson—can be approximated using nested rotating vectors, detailing a practical Mathematica pipeline using the Traveling Salesman Problem to order pixels. Finally, the lesson breaks down the underlying mathematics of complex Fourier series, explaining how Euler's formula and integral orthogonality isolate the exact frequency coefficients required to animate custom paths.

## Atmosphere & style The presentation is energetic, playful, and intellectually demystifying, characterized by Mathologer's signature blend of casual humor, self-deprecating jokes, and visual proofs. It feels like an engaging mathematical detective journey that consistently rewards curiosity, turning what could be intimidating concepts in complex analysis and orbital mechanics into intuitive, tangible geometric animations. The tone balances historical storytelling with practical programming guidance, creating an inspiring, hands-on learning environment.

## Detailed walkthrough ### [00:05](https://www.youtube.com/watch?v=qS4H6PEcCCA&t=5s) The Tusi Couple Warm-Up

Mathologer begins the exploration with a gentle warm-up geometry puzzle involving two circles, where the smaller circle has exactly half the radius of the larger circle. A red dot is marked on the circumference of this smaller inner circle. He asks viewers to imagine what curve the red dot will trace as the smaller circle rolls smoothly around the interior rim of the larger one. Letting viewers ponder for a moment, he reveals the surprising result: the red point moves back and forth in a perfectly straight line along the diameter of the large circle.

He remarks on how counterintuitive it feels to generate straight motion purely out of round objects: “So you can draw a line using circles. Who would have thought.” He introduces this classical mechanical miracle as the Tusi couple, named after the 13th-century Persian astronomer and mathematician Nasir al-Din al-Tusi. This serves as the entry point into the broader theme of the video: combining circular motions, tracing its rich history from early astronomical cosmological models to modern Fourier analysis, and building up to reconstructing the mysterious Homer Simpson orbit.

[01:15](https://www.youtube.com/watch?v=qS4H6PEcCCA&t=75s) The Real Shape of the Moon's Orbit

Turning to celestial mechanics, Mathologer invites viewers to visualize the path the Moon takes as it travels around the Sun. Everyday knowledge provides three basic building blocks: the Earth travels on a roughly circular path around the Sun; the Moon moves on a roughly circular path around the Earth; and there are roughly twelve and a bit lunar months in a calendar year. Starting at a new moon—where the Moon sits directly between the Earth and the Sun—and advancing month by month through eleven more cycles back to the start, common intuition predicts a dramatic flower-like curve featuring twelve distinct outward and inward looping petals.

```mermaid flowchart LR accTitle: Evolution of the Moon's Orbit Representation accDescr: Flowchart illustrating how shrinking the Earth-Moon distance alters the perceived orbital path. A["Initial Intuition:<br/>12 looping petals"] -->|"Shrink orbit distance"| B["Intermediate:<br/>Sharp cusps"] B -->|"Shrink further"| C["Shallow wavy curve"] C -->|"True scale"| D["Convex 12-gon<br/>with rounded corners"] ```

Mathologer immediately shatters this visual intuition: “Right? Wrong! The moon's orbit looks nothing like this.” While factors like elliptical paths, orbital inclination differences, and the non-integer length of the year exist, the fatal flaw in the looping diagram is scale: the physical distance between the Earth and the Moon is dwarfed by the massive radius of the Earth's orbit around the Sun. To show what actually happens, he gradually scales down the Moon's orbital radius: - First, as the orbit shrinks, the wide open loops collapse into sharp cusps. - Shrinking further, the cusps flatten out into shallow, gentle waves. - Finally, at true scale, all indentations vanish completely, leaving a smooth, strictly convex shape resembling a regular 12-gon with rounded corners.

He emphasizes how extraordinary this is: the Earth's Moon is the only known moon in the entire solar system whose orbit around the Sun remains purely convex without loops or waviness. Because of this distinct, planet-like solar trajectory, some astronomers argue that the Earth and Moon are better classified as a double-planet system rather than a standard planet-moon pair.

[03:38](https://www.youtube.com/watch?v=qS4H6PEcCCA&t=218s) From Spirographs to Squarish Orbits

Mathologer transitions from the true Sun-Earth-Moon system to a mathematical playground where speeds and orbital radii can be freely adjusted. He shows that when these parameters vary, a vast catalog of orbital geometries becomes possible. The most extreme baseline case is the rolling-circle setup seen in the Tusi couple, where the moon is a point on the rim of the rolling coin and the planet sits at its center, producing a flat line segment.

He jokes about the famous children's drawing toy that this mechanism evokes: “Starts with an S rhymes with a why-rograph. Well, yes it's a spirograph. Wow, that was bad:)” He explains that every classic spirograph curve is a valid theoretical lunar orbit: - If the point representing the moon is moved into the interior of the rolling circle rather than staying on the rim, it generates perfect ellipses of arbitrary eccentricity. - By setting the rolling circle to one-third the diameter of the larger circle, the resulting curve morphs into an equilateral triangle with softly rounded corners. - Reducing the rolling circle to one-fourth the size yields an almost squarish trajectory.

This leads to the whimsical cosmological realization that somewhere in the universe, an alien moon could conceivably trace an essentially square orbit around its host star.

[05:15](https://www.youtube.com/watch?v=qS4H6PEcCCA&t=315s) Mini-Moons, Epicycles, and the Homer Orbit

Mathologer extends the thought experiment further by asking what happens if a moon has its own "mini-moon." Although astronomers find no evidence of natural sub-satellites within our solar system, mathematicians face no such physical constraints. Nesting mini-moons around mini-moons creates a chain of circular motions. To show how far this concept goes, he showcases a famous animation featuring a chain of nested rotating circles: “Here's a chain of 1,000 nested mini moons at work, each one moving at some constant speed around its maxi moon and the minniest of the moons follows an orbit in the shape of Homer Simpson.” (Though he credits Santiago Ginnobili in the video narration, his show notes clarify that the animation was made by Ramiro Serra and Cristián Carman, and utilized 10,000 epicycles rather than 1,000).

He observes that if a system of rotating arms can draw Homer Simpson, it can essentially trace any closed path: - Any reasonably well-behaved closed curve can be traced by the tip of a multi-tiered moon system. - Not only can the geometric path be matched, but arbitrary kinematic variations can also be reproduced—speeding up along certain arcs, slowing down, or reversing back and forth across the exact same segment. - Achieving an analytically exact reproduction of an arbitrary continuous path generally requires an infinite series of rotating circles, but a finite collection can approximate any curve to whatever tolerance is desired.

[06:54](https://www.youtube.com/watch?v=qS4H6PEcCCA&t=414s) Epicycles Through Astronomical History to Fourier

These compound circular motions are historically known as epicycles, an idea employed by Greek astronomers like Claudius Ptolemy to make sense of the wandering, retrograde motions of the planets observed from Earth. Mathologer points out that modern textbooks often oversimplify the ancient geocentric worldview into a neat set of concentric circular tracks. In reality, Ptolemy's functional model for planets like Mars relied heavily on complex epicycles and offset centers (equants) to yield predictive results.

When Nicolaus Copernicus placed the Sun at the center of the solar system, popular belief held that he eliminated all this geometric messiness. Mathologer refutes this misconception: “However, just like Ptolemy and his greek mates, Copernicus also resorted to epicycle acrobatics to fine-tune orbits of the planets.” Because Copernicus insisted on using uniform circular motions, his heliocentric orbital tracings for planets like Mars wound up being just as convoluted as Ptolemy's system, without offering superior predictive precision.

The true breakthrough came 60-odd years later when Johannes Kepler ditched circles entirely and introduced elliptical orbits with varying speeds. Epicycles ceased to be the dominant model of the cosmos, but their mathematical power survived. At the turn of the 19th century, French mathematician Joseph Fourier published work showing how periodic functions and complex geometric paths could be decomposed into sums of simple circular or sinusoidal harmonics. This founded the modern discipline of Fourier analysis, unlocking applications that reached far beyond astronomy.

[09:35](https://www.youtube.com/watch?v=qS4H6PEcCCA&t=575s) Anderstood’s Mathematica Implementation

Bringing the mathematics into practice, Mathologer sets out to answer how anyone can build their own custom epicycle machinery. Turning to the internet, he points to a post on the Mathematica Stack Exchange by a user posting under the pseudonym Anderstood, who provided detailed code to construct epicycle paths.

Anderstood demonstrated the workflow using an elephant silhouette as a baseline test:

| Step | Process | Mathematical Concept | |:--- |:--- |:--- | | 1. Image Sampling | Extract the perimeter of a silhouette JPEG into discrete points | Boundary extraction | | 2. Complex Encoding | Treat $(x, y)$ coordinates of boundary points as complex numbers $x + iy$ | Complex plane mapping | | 3. Frequency Analysis | Compute epicycle frequencies, radii, and initial phases | Discrete Fourier Transform | | 4. Series Approximation | Sum rotating vectors to regenerate the original continuous silhouette | Complex Fourier Series |

Mathologer shows that while an approximation using only 20 epicycles produces an indistinct, lumpy shape with merely a vague elephantine silhouette, ramping the system up to 100 epicycles yields an unmistakable drawing of an elephant.

After showcasing a demo generated from his own tweaks to the code, Mathologer reviews Anderstood's subsequent attempt to tackle Bart Simpson. While the outline worked well, Anderstood’s published code struggled with internal detail strokes (such as eyes and shirt lines) and suffered from a systemic issue where the centers of the rotating epicycles were improperly positioned during animation. Mathologer explains that he took Anderstood's core framework and adapted it to reverse-engineer the original Homer Simpson animation by grabbing a screenshot from the source video to extract the full drawing coordinate path.

### [12:43](https://www.youtube.com/watch?v=qS4H6PEcCCA&t=763s) Digitizing and Tracing the Homer Outline The speaker explains the technical pipeline for creating an epicycle animation from an image. Starting with a cleaned-up graphic in Photoshop and Illustrator, the image is converted into a low-resolution map of pixels. To transform these static points into a path, the speaker utilizes a "neat trick" within Mathematica: the `FindShortestTour` command. By applying this, the program attempts to solve the Traveling Salesman Problem, forcing the software to create a single, continuous round-trip loop that visits every black pixel in the outline. While the speaker acknowledges this is a "quick and dirty solution" that can introduce minor artifacts, it effectively bridges the gap between a static image and a functional path that can then be fed into an epicycle-generating program.

- The process relies on `FindShortestTour` to order coordinates for the epicycle algorithm. - The speaker notes that better, smoother results are achievable by manually refining the sequence of points that trace the original picture. - A challenge is issued to viewers: create and share original epicycle animations in the comments, with the best submission winning a book authored by the speaker and Marty.

### [14:42](https://www.youtube.com/watch?v=qS4H6PEcCCA&t=882s) The Fourier Crash Course and Euler’s Formula The speaker pivots to the theoretical foundation of these systems, introducing the "magical Fourier machine." This begins with a recap of Euler’s formula, $e^{it} = \cos(t) + i\sin(t)$, which is described as a compact way to parameterize the unit circle in the complex plane. As $t$ ranges from $0$ to $2\pi$, this formula traces the circle counterclockwise. The speaker illustrates how modifying this expression changes the path: using $-t$ reverses the direction to clockwise, multiplying by $2t$ loops the path twice, and multiplying the expression by a complex constant (like $4$ or $1+i$) dictates the circle's radius and its starting/ending position in the complex plane.

- Euler's formula serves as the building block for each individual epicycle. - Multiples of $t$ (e.g., $2t, 3t$) represent different frequencies of circular motion. - The speaker highlights $e^{i\pi} = -1$ as "most mathematicians' favourite identity."

### [17:54](https://www.youtube.com/watch?v=qS4H6PEcCCA&t=1074s) The Magical Fourier Machine The core mechanism of Fourier series is revealed to be the integration of these exponential expressions over the interval $[0, 2\pi]$. The speaker explains that these integrals are always equal to zero, a result rooted in a symmetry argument where every complex number encountered during the rotation is canceled out by its negative counterpart. When applied to a specific shape, the Fourier machine assembles an infinite sum of these epicycles—each represented by a complex coefficient multiplied by a specific frequency of $e^{int}$—to reconstruct the path. By adding these individual circular motions together, the "last moon" in the chain traces the desired outline.

- The system results in a "doubly infinite sum" where every integer frequency appears exactly once. - The term for frequency $0$ is simply a constant (since $e^{0}=1$), which acts as an anchor point for the entire chain of circles. - The speaker remarks on the beauty of this representation: “The Fourier machine rewrites any sufficiently nice periodic function $f(t)$ from the interval $0$ to $2\pi$ to the complex numbers as this sort of two-tailed infinite sum.”

### [21:47](https://www.youtube.com/watch?v=qS4H6PEcCCA&t=1307s) Extracting Coefficients via Algebra Autopilot To isolate a specific coefficient—such as $c_2$—the speaker employs an algebraic maneuver: multiplying the entire infinite sum by $e^{-2it}$. This effectively shifts the exponent of the target term to zero (making it a constant) while leaving all other terms with an exponential factor. Integrating this expression over the interval $[0, 2\pi]$ causes all non-target terms to vanish to zero, leaving only the desired coefficient. This process demonstrates how the "magical machine" calculates the specific size and phase of each epicycle required to trace a given input curve.

- The speaker credits this approach to the utility of the discrete Fourier transform for numerical inputs, noting: “In particular, Anderstood in his Mathematica program uses the so-called discrete Fourier transform.” - The presentation concludes by connecting these abstract epicycles to practical signal processing, suggesting that phenomena like a "square wave" are fundamentally just the imaginary parts of these complex, rotating systems.

```mermaid flowchart LR A["Input: Image/Pixels"] --> B["FindShortestTour (TSP)"] B --> C["Path/Tracing f(t)"] C --> D["Fourier Machine (Integration)"] D --> E["Complex Coefficients"] E --> F["Epicycle Chain"] accTitle: The process of creating an epicycle animation accDescr: A flow showing the conversion of a pixel-based image into a series of epicycles via TSP and Fourier analysis. ```

## Video description NEW (Christmas 2019). Two ways to support Mathologer Mathologer Patreon: https://www.patreon.com/mathologer Mathologer PayPal: paypal.me/mathologer (see the Patreon page for details)

Today’s video was motivated by an amazing animation of a picture of Homer Simpson being drawn using epicycles. This video is about making sense of the mathematics epicycles. Highlights include the surprising shape of the Moon’s orbit around the Sun, instructions on how you can make your own epicycle drawings, and a crash course of complex Fourier series to make sense of it all.

The original Homer epicycle video “Ptolemy and Homer” by Ramiro Serra and Cristián Carman posted on their friend's Santiago Ginnobili's YouTube channel can be found here https://www.youtube.com/watch?v=QVuU2YCwHjw In the video I attribute the animation to Santiago which is a mistake. Also Ramiro told me that unlike what it said in "Ptolemy and Homer" their animation actually involved 10000 and not just 1000 epicycles.

Anderstood’s discussion of how to create epicycle drawings in Mathematica lives here: https://mathematica.stackexchange.com/questions/171755/how-can-i-draw-a-homer-with-epicycloids

Download my tweak of Anderstood’s Mathematica code as a Mathematica notebook here http://www.qedcat.com/misc/homer1.zip and in pdf format here http://www.qedcat.com/misc/homer1.pdf.

The spirograph gif animation is from the Wiki page on spirographs https://en.wikipedia.org/wiki/Spirograph and is due to Michael Frey.

A great interactive version Pierre Guilleminot of the square wave animation that I show at the end of this video lives here https://bl.ocks.org/jinroh/7524988

The GoldPlatedGoof video on Fourier analysis: https://youtu.be/2hfoX51f6sg

Today's t-shirt I got from here: https://www.teepublic.com/t-shirt/2066458-mathflix

The music is "Mysteries" by Dan Lebowitz from the free YouTube music library: https://www.youtube.com/audiolibrary/music

As usual thank you very much to Danil and Marty for their help with this video.

Enjoy!

[Source](https://www.youtube.com/watch?v=qS4H6PEcCCA)

中文简报

本轮、复傅里叶级数与荷马·辛普森的轨道 本视频探讨了复合圆周运动如何勾勒出复杂曲线,从图西双圆的直线运动切入,并澄清了月球绕日轨道包含环状花瓣形轨迹的误解。Mathologer 梳理了本轮从托勒密和哥白尼的天文模型到约瑟夫·傅里叶现代调和分析的历史演变。他演示了如何利用嵌套旋转向量来近似拟合包括荷马·辛普森在内的任意闭合连续路径,并详细介绍了一个利用旅行商问题对像素进行排序的实用 Mathematica 工作流。最后,本课剖析了复傅里叶级数的底层数学原理,解释了欧拉公式与积分正交性如何分离出生成自定义动画路径所需的精确频率系数。 探讨复合圆周运动绘制复杂曲线的机制,并破除关于月球绕日轨道呈环状花瓣形态的误解。 回顾本轮从古代天文学模型到傅里叶分析的演变,并演示使用嵌套旋转向量拟合荷马·辛普森等闭合轮廓。 解析复傅里叶级数的数学原理,说明欧拉公式和积分正交性如何提取自定义路径所需的频率系数。

Reading summary

Mathologer demonstrates how compounding circular motions—originally conceptualized as astronomical epicycles—form the mathematical foundation of complex Fourier series capable of tracing virtually any closed curve, from planetary orbits to intricate silhouettes like Homer Simpson. Orbital Geometry from Lines to Squarish Trajectories (0:05) Combining circular motions produces a wide array of non-circular trajectories. A classical example is the 13th-century Tusi couple, described by Persian astronomer Nasir al-Din al-Tusi, where a circle rolling inside another of twice its radius causes a point on its rim to trace a straight line along the larger circle's diameter. Moving the point inside the rolling circle yields ellipses, while altering diameter ratios generates soft triangles or squarish paths. In celestial mechanics, scaling dictates the perceived geometry of orbits. Although intuitive diagrams depict the Moon tracing twelve looped petals around the Sun each year, the Earth-Moon distance is dwarfed by the Earth-Sun radius. At true scale, the loops and waves disappear completely, leaving a strictly convex twelve-sided polygon with rounded corners. Mathologer highlights that the Moon is the only known satellite in the solar system with a purely convex path around the Sun, prompting some astronomers to characterize the Earth and Moon as a double-planet system. From Astronomical Epicycles to Fourier Analysis (6:54) Compound circular paths, known historically as epicycles, were central to Claudius Ptolemy's geocentric model to account for the retrograde motion of planets like Mars. Contrary to popular belief, Nicolaus Copernicus did not eliminate this complexity; his heliocentric model maintained uniform circular motions and required similar epicyclic adjustments without improving predictive accuracy. The geometric reliance on circles ended when Johannes Kepler established that planets follow elliptical orbits at varying speeds. At the start of the 19th century, Joseph Fourier demonstrated that continuous periodic paths and waveforms can be decomposed into sums of circular harmonics. While physical nature rarely hosts nested natural satellites, mathematicians can link arbitrary numbers of rotating vectors. Mathologer notes an animation by Ramiro Serra and Cristián Carman using 10,000 epicycles to trace Homer Simpson, illustrating that any well-behaved continuous closed path and its kinematic speed variations can be approximated to arbitrary precision by a finite series of rotating arms. Parameterizing Curves with Complex Fourier Series (17:54) The theoretical mechanism relies on Euler’s formula, e^(it) = cos(t) + i sin(t), which parameterizes the unit circle in the complex plane as t runs from 0 to 2π. Integer multiples of t adjust the rotational frequency and direction, while complex coefficients set the radius and starting phase of each rotating vector. A constant term at frequency zero anchors the chain's origin in the complex plane. Fourier analysis expresses a sufficiently well-behaved periodic function as a doubly infinite sum of these rotating terms. To extract an individual coefficient such as c_n, the entire series is multiplied by e^(-int) and integrated over the interval [0, 2π]. Because integrating any non-zero harmonic exponential over a full cycle evaluates to zero due to symmetry cancellations, all terms drop out except for the isolated constant coefficient. Algorithmic Path Tracing and Digital Epicycles (9:35) Translating mathematical epicycles into computer animations requires converting static shapes into continuous ordered coordinates. Drawing on code published on Mathematica Stack Exchange by user Anderstood, Mathologer outlines a pipeline that maps boundary coordinates to complex numbers and applies the Discrete Fourier Transform to determine the necessary frequencies, radii, and phases. To bridge the gap between static image pixels and a parameterized path for tracing Homer Simpson, Mathologer uses Mathematica’s FindShortestTour function. By solving the Traveling Salesman Problem across the extracted boundary pixels, the algorithm forces an unordered set of points into a single continuous loop. While effective as an automated shortcut, Mathologer observes that this technique can introduce minor artifacts, whereas manual path sequencing produces smoother approximations. Fourier series demonstrate that arbitrary two-dimensional closed curves and periodic signals can be fully reconstructed through sums of circular motions. While an infinite series provides an exact analytical reproduction, practical digital implementations rely on the Discrete Fourier Transform and properly ordered coordinate loops to approximate complex targets within an acceptable margin of error.

精炼阅读摘要

数学科普频道 Mathologer 指出,通过复数傅里叶级数将圆周运动叠加(即本轮机制),可以在数学上精确近似任意给定的闭合连续轨迹,这一数学工具不仅贯穿了从托勒密、哥白尼到开普勒的天文学演变史,也使绘制类似“霍默·辛普森轨道”的复杂图形成为可能。 圆周合成与真实天体轨道的直觉偏差 (0:05) 通过两个圆周运动的组合,可以产生出人意料的几何形状。以13世纪波斯天文学家纳西尔丁·图西命名的“图西双圆”(Tusi couple)为例,当一个小圆在半径为其两倍的大圆内滚动时,小圆圆周上的一个红点能够纯粹依靠圆周运动在直径上走出一条完美的直线。在经典万花尺(spirograph)的几何机制中,调整两圆半径比例不仅能生成不同偏心率的椭圆,在滚动圆半径为大圆三分之一或四分之一时,还能绘制出带有圆角的正三角形或近似正方形的闭合曲线。 在真实天体力学中,大众对日地月系统轨道的直观印象往往存在巨大尺度偏差。常识推断月球一年绕地十二圈左右,容易让人误以为月球绕日轨道由十二个向内向外反复翻转的环状花瓣构成。Mathologer 指出,由于地月实际距离远小于地球绕日轨道半径,随比例尺缩小,环状花瓣首先收缩为尖角,随后平滑为浅波浪,最终在真实尺度下完全消失,呈现为一个略带圆角的凸正十二边形。月球也因此成为太阳系中已知唯一绕日轨道保持严格凸起、无环也无波动的卫星,促使部分天文学家提议将其与地球视为双行星系统。 从古代天文学本轮到傅里叶级数 (6:54) 多层圆周运动的嵌套在天文学史上被称为“本轮”(epicycles)。为了解释地球上观测到的行星逆行,古希腊天文学家托勒密构建了依赖本轮与偏心匀速点(equant)的复杂地心说模型以进行定量预测。即便哥白尼提出了日心说,但他因固守匀速圆周运动假设,其火星轨道模型同样依赖大量的本轮微调,不仅几何形态极其繁琐,在预测精度上也并未超越托勒密体系。直到大约60年后,约翰内斯·开普勒用变速椭圆轨道彻底取代纯圆周运动,本轮才从宇宙物理模型中退场。 然而本轮背后的数学机制并没有消亡。19世纪初,法国数学家约瑟夫·傅里叶证明了任意周期函数或复杂几何轨迹均可分解为简单正弦或圆周谐波的无限和,从而创立了现代傅里叶分析。Mathologer 指出,多层级旋转链条不仅能在几何上逼近任意性态良好的闭合曲线,还可以复现沿轨道的任意运动学特征(如局部加速、减速或在相同线段上往返)。例如拉米罗·塞拉与克里斯蒂安·卡尔曼制作的经典演示,便是利用10,000个嵌套本轮的旋转链条,使末端微型卫星精确描摹出辛普森一家中霍默·辛普森(Homer Simpson)的外轮廓。 基于欧拉公式的复数傅里叶数学原理 (14:42) 本轮系统的数学核心是欧拉公式 $e^{it} = \cos(t) + i\sin(t)$,它以紧凑的形式将复平面上的单位圆进行参数化。随着参数 $t$ 在 $[0, 2\pi]$ 区间递增,表达式逆时针绘制出单位圆;通过改变 $t$ 的符号(如 $-t$)可实现顺时针旋转,使用整数倍频(如 $2t, 3t$)可实现多重旋转,而乘以复常数则决定了圆的半径以及起始相位。傅里叶级数将任意充分良好的复周期函数 $f(t)$ 展开为包含正负所有整数频率的“双侧无穷级数”,其中0频项对应一个复常数,充当整个运动链条的旋转锚点。 求解各级本轮半径与初始相位(即复系数)依赖于正交积分。对于任意非零整数 $n$,$e^{int}$ 在 $[0, 2\pi]$ 区间上的积分由于几何对称性相互抵消,结果恒等于0。为了提取特定频率(例如 $c_2$)的系数,可以通过给级数两端同乘 $e^{-2it}$,使目标项的指数归零变为常数,其余项依然保留非零旋转频率。在此基础上计算 $[0, 2\pi]$ 上的定积分,所有非目标项积分全部消失归零,从而孤立并解出目标复系数。这一严密的代数机制为数值信号处理中的离散傅里叶变换(DFT)奠定了理论基础。 从图像像素到本轮链条的工程实现 (9:35) 将静态图像转换为本轮动画需要一系列离散数据处理与算法转换。Mathologer 梳理了 Mathematica Stack Exchange 用户 Anderstood 提供的工程流程:首先通过图像处理提取剪影轮廓的离散像素坐标,并将其映射为复平面上的复数点集 $x + iy$。为了将杂乱的静态离散点转化为单条连续闭合路径,可利用算法求解旅行商问题(如 Mathematica 中的 `FindShortestTour` 命令),以快速确定一条遍历所有边缘像素的巡游回路。 排序后的轮廓路径被输入到离散傅里叶变换中,程序自动计算出每个谐波分量(即子卫星本轮)的旋转速度、半径大小与初始偏角。Mathologer 指出,逼近精度直接受制于保留的本轮数量:以大象剪影为例,仅保留20个本轮时形状模糊扭曲,仅具大象轮廓雏形;当增加至100个本轮时,图形已高度逼真。尽管基于旅行商问题的启发式路径排序可能引入微小的人工走线瑕疵且缺乏对内部细节线的原生支持,但该方法有效打通了从离散图像到傅里叶复系数矩阵的自动化生成通路。 Mathologer 阐明,从古代行星建模到现代复数傅里叶分析,本轮理论完成了从物理实体假设到纯粹数学工具的蜕变。借助离散傅里叶变换与欧拉公式,有限个复数矢量的级联累加能够以任意预设精度逼近现实中的任意闭合形状;日常信号处理中的常见现象(如方波),在数学本质上即是此类复数旋转本轮系统在虚轴方向的投影。

Original transcript

[0:05] Welcome to another Mathologer video. As a gentle intro to what I'll do today. [0:10] Here's a bit of a warm-up exercise. Here two circles the smaller one half the [0:15] radius of the larger one. The red dot marks a point on the circumference of the [0:20] smaller circle. Now imagine that the smaller circle rolls around inside the [0:24] larger one. What curve will be traced by the red dot? Think about it for a second. [0:30] You think you've got it? Well let's see. As you can see the dot traces a [0:35] straight line. Pretty cool, huh? So you can draw a line using circles. Who [0:40] would have thought. This little miracle is called the Tusi couple and is [0:44] named after the 13th century Persian astronomer and mathematician Nasir [0:48] al-din al-Tusi. I probably mucked that one up, right. Okay, so today's video is all about the [0:55] mathematics of combining circular motions and it's rich history, from early [0:59] models of the universe to the modern theory of Fourier analysis. A special [1:06] highlight will be the reconstruction of the mysterious Homer Simpsons orbit [1:09] discovered in 2008. Just wait. Okay let's really get going by considering the [1:15] orbit of our Moon around the Sun. Well we all know that the Earth travels around [1:21] the Sun on a roughly circular orbit, that the Moon travels around the Earth also [1:25] on a roughly circular orbit, and that there are 12 and a bit lunar months in a [1:31] year. Based on these three facts try to picture the orbit of the Moon around the [1:37] Sun. You've got it? Well let's see. In this picture the Moon is between the Sun and [1:44] Earth and so we're dealing with a new moon. [1:47] Fast forward one lunar months and we [1:50] have a new moon again. There are 11 more lunar months left in the year until [1:55] Earth completes its trip around the Sun. So in total we get this very pretty [2:00] picture of the orbit of the moon, with 12 distinctive loops corresponding to the [2:05] twelve months of the year. Right? Wrong! The moon's orbit looks nothing like this. [2:11] Yes, yes we should be using ellipses not circles, the year's not exactly 12 lunar [2:16] months long, the two orbits are not exactly in the [2:18] same plane, and so on. But none of that gets to why our picture is really [2:23] misleading. What has really mucked up our picture is that relatively the [2:29] earth-moon distance is much much, much smaller than we've indicated. Okay [2:34] so let's be honest, stop cheating and shrink our moon's orbit. Shrink, shrink [2:39] shrink and there the loops are gone and have turned into sharp cusps. So is [2:44] that what our orbit looks like? Nope, we have to keep shrinking. As you can see [2:49] the orbit now has shallow waves but we're still not there. Let's keep on [2:53] shrinking. So what we've got finally is a convex curve with no indentations that [3:01] looks like a regular 12-gon with rounded off corners and that really is what the [3:07] orbit of the moon around the Sun looks like, just even more rounded and circle [3:11] like than the curve in our picture. Pretty surprising isn't it. Well it gets [3:15] even more surprising. It turns out that our moon is the only moon in the solar [3:20] system with a convex orbit. The orbits of all the other moons are of the wavy and [3:25] loopy types. In fact because of this planet like orbit some experts consider [3:31] the Earth and the Moon as a double planet and not as a planet moon system. [3:38] Okay, let's now have a closer look at our simplified Sun-Earth-Moon setup. In our [3:44] system the Earth and the Moon circle around at constant speeds but what if we [3:49] vary those speeds (and the radii of the orbits)? What other orbit shapes are possible? For [3:54] a really extreme example, the orbit can be a line segment. Yes that coin rolling [4:00] business that I showed you earlier can also occur in this setting. Here the moon [4:05] is the red point on the rim of the rolling circle and the planet is the [4:10] center of this little circle. But this rolling coin setup also may remind you of [4:17] some very famous toy. Starts with an S rhymes with a why-rograph. Well, yes it's [4:24] a spirograph. Wow, that was bad :) [4:28] All spirograph curves are possible moon orbits and you're all probably aware of [4:34] the amazing variety of such curves. Here are some particularly remarkable ones. [4:39] You get perfect ellipses when you keep the size of the little circle the same [4:43] but move the moon to the inside of the circle. In fact, any shape ellipse can be [4:49] obtained in this way. Now change the rolling circle to be one-third the size [4:55] of the big circle and we get a pretty good approximation of an equilateral [5:00] triangle. Then with the rolling circle one fourth the size of the big circle we [5:06] get a pretty squarish orbit. So, conceivably, there's a moon somewhere in [5:11] the universe that moves around its Sun on an essentially square orbit. That's [5:15] pretty amazing, isn't it? Now what if the moon itself has a mini moon? Astronomers [5:23] seem pretty certain that at least in our solar system there's no such thing. [5:27] But, of course, mathematicians don't have to worry about reality. If we want a [5:32] mini moon of a moon we just create a virtual one. What then is possible in [5:37] terms of orbits of mini moons of moons or mini mini moons of mini moons of [5:41] moons? Well let's have a look at this. Here's a chain of 1,000 nested mini [5:49] moons at work, each one moving at some constant speed around its maxi moon and [5:53] the minniest of the moons follows an orbit in the shape of Homer Simpson. This [5:58] classic animation is the work of Santiago Ginnobili. Now that is really, [6:03] really, really amazing, don't you agree? You'd figure if we get a mini moon to [6:10] travel on a Homer path, then we can get it to do pretty much anything, right? And [6:15] that's true, any reasonably nice closed curve can be [6:18] traced by an orbit of a mini moon. Actually, we can do even more. Any such [6:25] loopy curve can be travelled along in infinitely many ways, slow in some parts [6:30] and fast in others, going back and forth over the same part of the curve, and so [6:34] on. And every one of these travel variations can be replicated by one of [6:38] our moon systems. Usually to get things mathematically spot-on [6:43] you'll need infinitely many moons. But even with finitely many moons you can [6:48] get as close to spot-on as you want. The orbits of moons and mini moons are [6:54] usually called epicycles and epicycle mathematics has been used for millennia [6:58] to describe complicated motions. It dates back to Ptolemy and the other ancient [7:03] Greek astronomers who used epicycles and other tricks to describe the apparently [7:07] crazy motions of the planets as observed from Earth. Most of us picture these old [7:13] geocentric models of the solar system as being very simple like this. So Earth in [7:19] the center with the moon, the planets and the Sun moving around it on concentric [7:24] circles. However every one of the planet circles really stands for a much more [7:29] complicated orbit. For example, Mars's orbit in the Ptolemaic system looks [7:34] something like this. Essentially this is an epicycle orbit [7:39] with a little extra tinkering thrown in to actually make this into a reasonably [7:43] predictive model. Copernicus's revolutionary system supposedly swept [7:49] away much of the complication of the geocentric models by placing the Sun at [7:54] the center of the solar system. This part of the story is also usually illustrated [8:00] with a simple picture of concentric circles. However, just like Ptolemy and [8:05] his greek mates, Copernicus also resorted to epicycle [8:09] acrobatics to fine-tune orbits of the planets. In fact Copernicus's model of [8:15] planetary motion wound up being at least as complicated as the Greeks' geocentric [8:20] systems, and no more accurate. Just to give you an idea, here's a drawing that [8:24] illustrates the motion of Mars according to Copernicus. Without going [8:30] into details, doesn't it look even more complicated [8:33] than the model for Mars in the Ptolemaic system that we looked at before. Well [8:36] does to me :) Of course what was really needed was [8:39] replacing all the circles within circles by fundamentally different geometry: the [8:43] elliptical orbits introduced by Johannes Kepler 60-odd years after Copernicus. [8:48] Anyway epicycle mathematics is ages old, even if it's not the simplest approach [8:55] to studying the heavens. However it was only at the beginning of the 19th [8:59] century that the great French mathematician Joseph Fourier published a [9:03] paper that led to a proper understanding of the possibilities of epicycle [9:08] mathematics and it's incredible usefulness outside astronomy. Today this [9:12] branch of mathematics is called Fourier analysis. For the more technically [9:17] inclined among you I will now show you how you can make your own epicycle [9:20] drawings of whatever takes your fancy and I'll show you how the epicycle [9:25] systems underlying these drawings can be reconstructed using complex Fourier [9:30] series. It gets a little detailed later, so feel free to bail out at any point. [9:35] Okay so down to work on our very important question: how to draw Homer [9:41] Simpson just using epicycles? And how would you naturally go about finding the [9:46] answer to this question? We all know, right? Google Homer and epicycle. If [9:52] you do, you won't be disappointed. It turns out that this exact question was [9:57] recently posted on the Mathematica stackexchange by someone writing under [10:02] the pseudonym Anderstood. Then Anderstood followed up with an answer [10:07] including the Mathematica code and explanations. Really brilliant stuff. [10:11] Let's have a look. As a warm-up Anderstood describes how to use [10:17] epicycles to draw the outline of an elephant. Starting with just a jpeg of a [10:22] silhouette to pin down the curve Anderstood first generates a set of [10:28] roughly equally spaced points along the perimeter of the silhouette. Then he [10:33] interprets the coordinates of these points as complex numbers and uses the [10:37] so called discrete Fourier transform to calculate epicycle approximations of the [10:41] silhouettes in terms of complex Fourier series. Very fancy and very scary words [10:46] but it's all pretty standard stuff. Nothing to panic about yet, promise. The [10:52] blob at the top was drawn using 20 epicycles. Maybe not so impressive though [10:57] if you squint a little it has a vague elephantine feel to it. But the bottom [11:02] picture drawn using 100 epicycles is most definitely an elephant. It all works [11:08] really well and I've gone on to use Anderstood's [11:11] code to generate epicycle approximations to various silhouettes. So have a guess [11:16] what's being drawn here. (music playing) [11:54] Back to Anderstood. After elephanting he tackles Bart Simpson. So he starts with [12:00] the drawing over there and his final output looks like ... wait for it ... this :) So [12:07] really pretty good. Unfortunately the bits of code [12:11] Anderstood provides for also capturing strokes inside the outline don't work [12:16] straight off the page. There's also a bit of a systemic problem with the centers [12:21] of the epicycles in the animations being wrongly placed. Having said that all the [12:26] ingredients are basically there and it wasn't too difficult to adapt Anderstood's [12:30] code and ideas to also reverse-engineer the Homer animation. Just really quick [12:36] here's what I did. So what I did it was I grabbed the screenshot of the original [12:43] video and cleaned it up in Photoshop and Illustrator. Then, again in Photoshop, I [12:48] made a low-res version of this drawing in which the outline is drawn as strings [12:52] of pixels. This is where Mathematica enters the picture for me and you can [12:58] have a close look at what exactly I do by inspecting my Mathematica notebook [13:01] linked in from the description. So using Mathematica I generate a list of the [13:07] coordinates of all the pixels in this picture, all the black ones. Now we [13:13] have to order the list of coordinates such that the corresponding points [13:17] appear in the order in which we want to trace them. Here Anderstood uses a very [13:22] neat trick. He unleashes the command FindShortestTour on the list. What this does [13:28] is it attempts to solve the Traveling Salesman problem for our set of points, [13:32] that is, it tries to create the shortest round trip that comprises all our points [13:37] and puts them into the corresponding order. Here's what this round trip looks [13:42] like. So this is one continuous loop which visits every pixel in our outline [13:49] exactly once. It's a somewhat quick and dirty solution [13:54] which includes some undesirable artefacts but it gets us there in finite [13:58] time which is great. Now from here we can just use exactly the same code as for [14:02] the elephant to generate the animation. Not bad, huh, [14:07] and if you're keen on something smoother, it's just a matter of more accurately [14:12] generating a string of points that indicates more exactly how you want the [14:16] original picture traced. Then you feed in the corresponding coordinates and the [14:21] program does its epicycle magic. Okay here's a challenge for you. [14:27] Get creative and come up with some epicycle animations of your own and link [14:32] them in via a comments below. The contribution I like best wins a copy of [14:36] Marty and my latest book, that one there. Okay, in the rest of the video I'd like [14:42] to really show you how these systems of epicycles are constructed and for that [14:46] let me just give you a crash course in Fourier series. Should be easy, right? Well [14:52] it's actually not bad and it's beautiful stuff. So to begin I have to remind you [14:57] of Euler's formula which has already appeared in about about a thousand [15:01] Mathologer videos. So e to the i t is equal to cos t plus i sine T. Euler's [15:09] formula amounts to a very compact way of tracing or in maths lingo parametrising [15:14] the unit circle in the complex plane. to see what I mean have a look at this [15:18] picture there so the red point on the unit circle is the complex number cost t [15:25] plus i sine t. That's the right side of Euler's formula, right? As we let the angle [15:32] t go from 0 to 2pi, the red point traces out the unit circle but now [15:38] Euler's formula tells us that the red point is also e to the i t. So, for [15:44] example, setting t equal to pi, that is, making a half turn, the red point moves [15:51] to ... -1, of course. So e^i pi =-1, most [15:56] mathematicians favourite identity. And, setting t equal to 0 we get e^0 [16:03] is equal to 1 which of course is no surprise. [16:06] Just to say it again, as we let t go from 0 to 2 pi the red point travels around [16:13] the unit circle once in the counterclockwise direction. Now let's [16:18] write -t instead of t. So e^-it. This [16:25] corresponds to traversing the circle once in the opposite, the clockwise [16:29] direction. And if we write 2t instead of t this corresponds to traversing the [16:37] circle twice in the counterclockwise direction as t goes from 0 to 2 pi. [16:43] And if you write 3, three times, and so on. [16:48] Here's another important observation. Let's multiply our circle exponential by [16:52] 4. What does this correspond to? Think about for a moment.... Easy, right? Here we [16:59] are traversing a circle of radius 4. Another way of expressing this is to say [17:05] that we traverse a circle through the complex number we multiply by, in this [17:09] case the number 4, starting and ending at this number. That sounds complicated [17:16] but what's nice about this way of looking at things is that this stays [17:20] true for all complex numbers, not just real numbers, like 4. So, for example, if [17:24] we multiply by the complex number 1+i we're now traversing the circle [17:30] starting and ending at 1+i. Okay, as we will see in a moment, [17:35] it's expressions of this form: complex number times e^i times some [17:43] integer times t that stand for the different epicycles produced by the [17:48] magical Fourier machine. And what is the source of the magic of the magical Fourier [17:54] machine? It's a very simple property of these exponential expressions. It turns [18:01] out that the integrals of these exponential's from 0 to 2 pi are always [18:06] equal to 0. Whoa, where did that one come from? And how can I possibly claim that this [18:13] is very simple? Well, it is actually easy if you know a little calculus. Basically [18:19] it's a straightforward symmetry argument: any complex number we come across as t [18:23] goes from 0 to 2 pi is canceled out by its negative which we'll also come across. [18:30] Maybe one of you can fill in the details in the comments. [18:34] Otherwise, just take my word for it for the moment. Okay, so now we are ready to [18:41] reveal the inner workings of the magical Fourier machine. Let's say what we want is [18:46] to trace this outline of the letter pi at a constant speed as shown. [18:50] So feeding this to the magical Fourier machine will create a chain of [18:53] infinitely many epicycles whose limit moon will do exactly the tracing we're [18:58] after. Here we go. If we only use the first few epicycles, then the last moon in [19:05] this finite chain will trace an approximation of our pi outline and the [19:09] more epicycles we use the better our approximation will be. For example, just [19:14] using the first four epicycles gives this orbit here. Using six epicycles will give [19:20] this. Here's the output from eight epicycles, and so on. Let's now have a [19:29] close look at the tracing produced by the first four epicycles, this one here. [19:35] Here we go in slow motion. Mathematically what you see here is represented by this [19:41] sum here. There's one term for each of the four circles which I've colour-coded, [19:47] plus the term at the top. So what we have here is a straightforward sum of the [19:54] four individual circular motions. The extra term on top is the complex number [19:59] that represents the black anchor point. [20:03] Now let's have a closer look at the exponent of e in these terms. For the [20:08] blue circle, the exponent is 1 times i t Then -1 i t for the [20:16] purple circle, 2 i t for the orange circle and, finally, [20:22] -2 i t for the red circle. The pattern's obvious next in the infinite [20:27] sum would be 3, -3, 4, -4, and so on, every integer appearing [20:31] exactly once. Except, ... well there is no 0, right? Well, actually, the 0 is [20:37] there, just in disguise. Here it is. e to the power of 0 is 1. So the infinite [20:43] sum that exactly captures the motion we're after is of this form here. [20:48] So we're producing a doubly infinite sum. Nifty if also a little scary, hmm. [20:55] Just to reiterate, the t in everything we're doing ranges from 0 to 2 pi and [21:00] because we're tracing closed curves starting and ending at the same complex [21:04] number the value of the sum is the same at 0 and 2 pi. This means our sums are [21:11] periodic functions from the interval 0 to 2pi to the complex numbers and so [21:17] here's another way of expressing what Fourier's magical machine does. The Fourier [21:23] machine rewrites any sufficiently nice periodic function f(t) from the [21:28] interval 0 to 2pi to the complex numbers as this sort of two-tailed infinite sum. [21:34] That's great but how do we find those infinitely many complex coefficients [21:39] that precisely pin down our epicycles. Well that's where the real magic is [21:47] hidden. Let me show you how you can find one of these coefficients, let's say c_2, [21:51] the coefficient in front of e^2it. Let's zoom in on the three [21:58] terms around this coefficient. To get rid of the e^2it next to the [22:05] c_2 we multiply our equation by e^ -2it. Now let's switch [22:13] to algebra autopilot. (music playing) [22:34] Okay, at this stage every single term of our [22:38] infinite sum except for the one we are focusing on features an exponential [22:42] factor. Now we can use the key integration factor that I mentioned earlier [22:46] to obliterate all the terms except for c_2. Ready for the integral magic? Here we [22:51] go. [22:57] There it is. Remember I told you earlier that all these integrals are [23:01] equal to 0 and so what's left on the right is this. But the green integral is [23:07] just equal to a 2 pi. Dividing through we find an expression that allows us to [23:13] calculate c_2. And, of course, the exact same trick works for all the other [23:17] coefficients as well. And so, on input of a tracing f(t) Fourier's magical machine [23:24] calculates these coefficients, each one exactly specifying one of our epicycles. [23:30] And here I take a bow to professor Fourier. Absolutely amazing stuff. [23:37] Of course I've glossed over a heap of details here, but really only details. [23:42] Maybe some of you in the know can supplement a bit of a discussion of when [23:46] exactly this works and what can go wrong. There's also still the question of how [23:50] you actually use this magic machine in practice. How you use it depends very [23:54] much on how you're tracing, the function f(t) is given to you. If it comes in a [23:59] nice form, you may be able to evaluate all those integrals. On the other hand, if, [24:04] as in the case of our Homer drawing, we are given an approximation of our [24:09] tracing by a sequence of points in this case there are specialised tools that [24:15] take these sequences of points as input and produce very good approximations of [24:19] these integrals. In particular, Anderstood in his Mathematica program uses the so [24:24] called discrete Fourier transform. A different approach is illustrated in a [24:29] very nice video by GoldPlatedGoof. Also very much worth checking out. Okay so all [24:36] under control in terms of epicycle mathematics. But what has all is to do [24:41] with all those real-life applications of Fourier series that you may have heard [24:45] of. Everything :) Just as a bit of a teaser, the animation below illustrates that the [24:52] famous representation of a square wave as a sum of sine functions is really [24:57] nothing but the imaginary part of a very pretty system of epicycles. Hopefully [25:01] I'll eventually get around to dedicating a few more videos to this incredibly [25:05] beautiful circle of ideas. Anyway I hope you enjoyed this video as much as I [25:10] enjoyed making it. And that's it for today.