Draw and Fourier
About this app
Draw a periodic curve with the mouse and watch the Fourier series rebuild it coarse-to-fine in animation — partial sums and spectrum live.
The idea
Any reasonably well-behaved periodic function can be written as a sum of sine and cosine waves. The Fourier coefficients aₖ and bₖ come from integrating the function against cos(kx) and sin(kx) over one period. The magnitude cₖ = √(aₖ² + bₖ²) tells how strongly the k-th harmonic is present; together the cₖ form the spectrum. The approximation starts with the fundamental and gets finer with every additional harmonic. At jumps an overshoot of about 9 % remains, the Gibbs phenomenon.
What the app shows
You draw a curve along the x-axis with mouse or finger. When you let go, the app computes the Fourier coefficients numerically. An auto-animation plays the approximation from N = 1 upwards, and the slider lets you choose N from 1 to 30 yourself. Individual terms can be shown as ghost curves. Panels show a₀, the RMS error, the largest coefficients |cₖ|, the spectrum for k = 0 to 15 and the formula of the current partial sum.
Try it yourself
Draw a smooth wave and see how few harmonics give a good fit. Then draw a curve with a vertical jump: even at N = 30 a spike stays at the jump. Compare the spectra of both curves. For smooth shapes the bars fall off quickly, while jumps and corners keep high harmonics clearly visible.
Frequently asked questions
- How do you calculate Fourier coefficients?
- For a 2π-periodic function, aₖ = (1/π)·∫ f(x)·cos(kx) dx and bₖ = (1/π)·∫ f(x)·sin(kx) dx, each over one period. For drawn or measured curves the integrals are computed numerically, for example with a sum over many sample points.
- What does a Fourier spectrum show?
- For each harmonic k the spectrum shows the strength cₖ = √(aₖ² + bₖ²) with which it occurs in the function. Smooth functions have a quickly decaying spectrum; functions with jumps or corners contain many high frequencies.
- Can every curve be written as a Fourier series?
- Every periodic function that is piecewise continuous and piecewise smooth is represented by its Fourier series; at jumps the series converges to the average of the left and right limits. In practice one approximates with finitely many terms.
- How do I use the app?
- Hold the mouse button or finger down and draw along the x-axis. After you let go, the analysis and animation start; the slider sets the number of harmonics, and “Redraw” starts over.
Subject: Fourier analysis
More from Fourier analysis
- Ein Radio aus Mathematik: Koeffizienten herausfiltern
- Euler-Zwillinge: Kosinus und Sinus aus e^{iφ}
- Formel-Verwandler: von der reellen zur komplexen Fourier-Reihe
- Fourier epicycles (3D)
- Fourier Synthesis
- Fourier Series — 5 Functions
- Gezupfte Saite: Wo man zupft, bestimmt den Klang
- Gibbs-Phänomen: wo die Reihe stolpert
A VisuApp by heyprof: interactive, free in your browser, no sign-up. What is a VisuApp? · All apps