Fourier Series Approximation of a Square Wave
Von dieser Animation inspiriert?
1. Overview
- Purpose: Visually demonstrate how the Fourier series of a square wave converges as more oddâharmonic sine terms are added, highlighting the Gibbs phenomenon near the discontinuities.
- Scene: A single Manim
Scene(e.g.,FourierSquareWaveScene). - Total Duration: ~25âŻseconds (well under the 30âŻs limit).
2. Mathematical Elements
- Target function (ideal square wave, period ):
- Fourier series (odd harmonics only):
where is the number of odd terms included (i.e., the partialâsum index). - Individual sine component for the term:
3. Visual Elements
| Element | Description | Color / Style |
|---|---|---|
| Coordinate axes | Horizontal axis from to ; vertical axis from to . Tick marks at multiples of . | Light gray axes, black tick labels (optional, small). |
| Ideal square wave (reference) | Thin dashed line showing the exact square wave (height ). | Dark gray, stroke width 2, dash pattern. |
| Partial sum curve | Smooth curve representing . Updated after each new term. | Solid line, primary color (e.g., deep blue), stroke width 4. |
| Current sine component | The newly added term highlighted while it is being introduced. | Distinct bright accent (e.g., orange), stroke width 3, appears briefly then fades into the background color of the partial sum. |
| Number of terms display | Small counter in the upperâright corner showing "N = X" where X = current number of odd terms. | White text on a semiâtransparent dark rectangle (opacityâŻ0.7) for readability. |
| Title | Centerâtop title: "Fourier Series Approximation of a Square Wave". | Bold white text on a semiâtransparent dark rectangle background. |
4. Animation Sequence & Timing
| Phase | Action | Duration | Details |
|---|---|---|---|
| 0 â 2âŻs | Fadeâin axes, title, and reference square wave. | 2âŻs | Axes and title slide in from the top; reference wave draws with a short dashâstroke animation. |
| 2 â 4âŻs | Introduce first term (k=0, N=1). | 2âŻs | The sine component draws in bright orange over 1âŻs, then smoothly morphs (color transition) into the partialâsum blue curve. Counter updates to "N = 1". |
| 4 â 6âŻs | Add second odd term (k=1, N=2). | 2âŻs | New orange sine draws, simultaneously the existing blue partial sum morphs to the new sum . Counter to "N = 2". |
| 6 â 8âŻs | Add third odd term (k=2, N=3). | 2âŻs | Same pattern. |
| 8 â 10âŻs | Add fourth odd term (k=3, N=4). | 2âŻs | |
| 10 â 12âŻs | Add fifth odd term (k=4, N=5). | 2âŻs | |
| 12 â 14âŻs | Add sixth odd term (k=5, N=6). | 2âŻs | |
| 14 â 16âŻs | Add seventh odd term (k=6, N=7). | 2âŻs | |
| 16 â 18âŻs | Add eighth odd term (k=7, N=8). | 2âŻs | |
| 18 â 20âŻs | Add ninth odd term (k=8, N=9). | 2âŻs | |
| 20 â 22âŻs | Pause on final partial sum (N=9) to let viewer observe Gibbs overshoot. | 2âŻs | Slight slowâmotion zoom (1.05Ă) on the discontinuities for emphasis (camera pan). |
| 22 â 24âŻs | Fadeâout all elements except title, then fadeâout title. | 2âŻs | Clean exit. |
Total: 24âŻseconds (well within limit).
Transition Details
- Sine component entry: Use
Createâstyle drawing for the orange curve over 1âŻs. - Partial sum update: Apply a
Transformfrom the previous blue curve to the new blue curve, synchronized with the orange component fading to the blue color (crossâfade). Duration 1âŻs. - Counter update: Simple
ReplacementTransformof the number text. - Zoom on Gibbs region: At 20âŻs, a subtle camera
scaleto 1.05 centered on for 2âŻs, then return to original view.
5. Camera & Perspective
- Default 2âD orthographic view.
- Zoom segment (20â22âŻs) as described above to highlight overshoot.
- No rotation or 3âD perspective needed.
6. Styling Guidelines
- Use a clean, sansâserif font (e.g.,
OpenSans) for all text. - All colors chosen to be colorâblind friendly: deep blue, orange, dark gray, white.
- Ensure the opaque background rectangle for the counter and title provides at least 80âŻ% contrast with the text.
- Keep line widths consistent (axes 2, reference wave 2, partial sum 4, sine component 3).
7. Final Remarks
- The animation progresses smoothly from one partial sum to the next, making the convergence and Gibbs phenomenon visually intuitive.
- All elements fit within a single Manim
Sceneclass, respecting the duration constraint.
Erstellt von
Beschreibung
The animation builds the Fourier series of a square wave by adding successive odd-harmonic sine terms. A dashed reference square wave is shown, and each new sine component appears in orange before merging into the blue partial-sum curve. A counter displays the number of terms. The view zooms near the discontinuities to highlight the Gibbs overshoot as the series converges up to nine terms.
Erstellt am
Feb 1, 2026, 05:10 AM
Dauer
0:28
Tags
fourier-seriessquare-wavegibbs-phenomenon