Skip to main content

Fourier Series Calculator

Calculate Fourier series expansions of periodic functions into sine and cosine components

Category: Mathematics

Fourier Series Calculator Inputs

Enter values to calculate

Enter the Period (2L) value used by the Fourier Series Calculator.

Enter the Number of Terms value used by the Fourier Series Calculator.

Enter the Function Type (square/sawtooth/triangle/pulse) text used by the Fourier Series Calculator.

Enable JavaScript for interactive calculation and step-by-step results.

Fourier Series Calculator Formula

Equation

f(x) = a₀/2 + Σ[aₙcos(nx) + bₙsin(nx)]

Excel Formula

=f(x)=a₀/2+Σ[aₙcos(nx)+bₙsin(nx)]

Variables

  • Period (2L) — Enter the Period (2L) value used by the Fourier Series Calculator.
  • Number of Terms — Enter the Number of Terms value used by the Fourier Series Calculator.
  • Function Type (square/sawtooth/triangle/pulse) — Enter the Function Type (square/sawtooth/triangle/pulse) text used by the Fourier Series Calculator.

How the Fourier Series Calculator Works

Fourier series is one of the most powerful tools in mathematical analysis, allowing us to represent periodic functions as infinite sums of sine and cosine functions. Developed by Joseph Fourier in the early 19th century while studying heat propagation, this representation reveals that any periodic function can be decomposed into simple oscillatory components called harmonics. The fundamental insight is that complex periodic phenomena—whether sound waves, electromagnetic oscillations, or temperature variations—can be analyzed as combinations of simple sinusoidal waves with different frequencies and amplitudes. This decomposition has profound applications in signal processing, communications, quantum mechanics, and virtually every field of engineering and physics where periodic or wave-like behavior occurs.

The core relationship is f(x) = a₀/2 + Σ[aₙcos(nx) + bₙsin(nx)]. Typical inputs include Period (2L), Number of Terms, Function Type (square/sawtooth/triangle/pulse).

Enter your values in the fourier series calculator above, review the step-by-step solution, and compare against the worked examples below so you can see how each input changes the result. This free online mathematics tool is built for homework, design checks, and professional verification.

Fourier Series Calculator Theory & Explanation

Fourier Series Definition

For a periodic function f(x) with period 2L, the Fourier series representation is: f(x) = (a_0)/(2) + Σ_n=1^∞[a_n\cos((nπ x)/(L)) + b_n\sin((nπ x)/(L))] The Fourier coefficients are computed by integration: a_0 = (1)/(L)∫_-L^L f(x)dx, \quad a_n = (1)/(L)∫_-L^L f(x)\cos((nπ x)/(L))dx, \quad b_n = (1)/(L)∫_-L^L f(x)\sin((nπ x)/(L))dx The term a_0/2 represents the average value (DC component), while the terms with n ≥ 1 represent oscillations at frequencies that are integer multiples (harmonics) of the fundamental frequency.

f(x) = (a_0)/(2) + Σ_n=1^∞[a_n\cos((nπ x)/(L)) + b_n\sin((nπ x)/(L))]

Orthogonality of Sine and Cosine

The foundation of Fourier series lies in the orthogonality properties of sine and cosine functions over a period. For integers m and n: ∫_-L^L \cos((mπ x)/(L))\cos((nπ x)/(L))dx = \begincases 0 & m ≠ n \\ L & m = n ≠ 0 \\ 2L & m = n = 0 \endcases Similar relations hold for \sin\sin and \sin\cos integrals. This orthogonality means that sine and cosine functions at different frequencies are "perpendicular" in function space, allowing unique decomposition. When we compute Fourier coefficients by multiplying f(x) by \cos(nπ x/L) or \sin(nπ x/L) and integrating, the orthogonality relations extract exactly the coefficient for that particular frequency, ignoring all others.

∫_-L^L \cos((mπ x)/(L))\cos((nπ x)/(L))dx = L\delta_mn

Convergence of Fourier Series

Under what conditions does a Fourier series converge to the original function? The Dirichlet conditions provide sufficient criteria: (1) f(x) must be periodic, (2) have a finite number of discontinuities in one period, (3) have a finite number of extrema in one period, and (4) be absolutely integrable over one period. At points of continuity, the series converges to f(x). At discontinuities, it converges to the average of left and right limits: [f(x^-) + f(x^+)]/2. This explains the Gibbs phenomenon—the series overshoots by about 9% near discontinuities, no matter how many terms are included. For smooth functions, convergence is rapid; for functions with discontinuities, it's slower.

f(x) = \lim_N\to∞ [(a_0)/(2) + Σ_n=1^N(a_n\cos(n\omega x) + b_n\sin(n\omega x))]

Complex Exponential Form

Using Euler's formula e^iθ = \cosθ + i\sinθ, the Fourier series can be written in complex exponential form: f(x) = Σ_n=-∞^∞ c_n e^inπ x/L where the complex coefficients are: c_n = (1)/(2L)∫_-L^L f(x)e^-inπ x/Ldx This form is more compact and often simpler for analysis. The relationship to real coefficients is: c_0 = a_0/2, c_n = (a_n - ib_n)/2, c_-n = (a_n + ib_n)/2 for n > 0. The complex form naturally leads to the Fourier transform for non-periodic functions and is the standard in quantum mechanics and signal processing.

f(x) = Σ_n=-∞^∞ c_n e^inπ x/L

Parsevals Theorem and Energy

Parseval's theorem (also called Plancherel's theorem) relates the energy in the time domain to energy in the frequency domain: (1)/(L)∫_-L^L |f(x)|^2 dx = (a_0^2)/(2) + Σ_n=1^∞(a_n^2 + b_n^2) In the complex form: (1)/(2L)∫_-L^L |f(x)|^2 dx = Σ_n=-∞^∞ |c_n|^2. This equality states that the total "energy" or power of a signal equals the sum of energies in all frequency components. It's fundamental in signal processing for analyzing power spectral density and in quantum mechanics where it relates to probability conservation. The theorem shows that Fourier decomposition preserves energy, making it a unitary transformation.

(1)/(L)∫_-L^L |f(x)|^2 dx = (a_0^2)/(2) + Σ_n=1^∞(a_n^2 + b_n^2)

Gibbs Phenomenon

When approximating functions with discontinuities using a finite Fourier series, the Gibbs phenomenon appears as overshooting oscillations near the discontinuity. For a jump of height h, the overshoot approaches approximately 0.09h (about 9%) regardless of how many terms are used—it doesn't decrease as N increases. The oscillations become narrower and more concentrated near the discontinuity as more terms are added, but the peak overshoot remains constant. This is not an error but a fundamental property of representing discontinuous functions with continuous basis functions. In applications, windowing techniques (like Hamming or Hann windows) can reduce these artifacts at the cost of slightly degrading frequency resolution.

\textOvershoot ≈ 0.09h \quad \text(independent of number of terms)

Applications in Engineering and Science

Fourier series appear throughout science and engineering. In electrical engineering, AC circuit analysis uses Fourier series to decompose complex periodic voltage/current waveforms into harmonics, with each harmonic analyzed separately using impedance. In acoustics, musical instruments produce overtones (harmonics) that combine to create timbre—Fourier analysis reveals why different instruments sound different even playing the same note. Heat conduction problems with periodic boundary conditions use Fourier series solutions. Quantum mechanics uses Fourier expansion to solve the Schrödinger equation in periodic potentials (Bloch's theorem). Signal compression (JPEG, MP3) uses related transforms (DCT, MDCT) to compress data by retaining only significant frequency components. Seismology analyzes earthquake vibrations using Fourier decomposition to identify resonant frequencies in structures.

\textApplications: Circuit analysis, acoustics, heat transfer, quantum mechanics, signal processing

Fourier Series Calculator Worked Examples

Worked Example

Inputs

  • period: 6.283
  • terms: 7
  • functionType: square

Result: Square wave with 7 terms showing detailed Fourier coefficients for each harmonic

Explanation

Square wave (period 2π) contains only odd harmonics (1st, 3rd, 5th, 7th) with sine coefficients bₙ = 4/(nπ). Even harmonics are zero. This creates the characteristic sharp transitions of a square wave.

Sawtooth Wave - Classic Example

Inputs

  • period: 6.283
  • terms: 8
  • functionType: sawtooth

Result: Sawtooth wave with 8 harmonics showing all frequency components with alternating signs

Explanation

Sawtooth wave (period 2π) contains all harmonics (both odd and even) with sine coefficients bₙ = 2(-1)^(n+1)/(nπ). Coefficients alternate in sign and decrease as 1/n. Used in music synthesizers for creating bright, buzzy sounds.

Common Fourier Series Calculator Use Cases

  • Homework and exam practice
  • Engineering and science coursework
  • Quick verification of hand calculations
  • Fourier Series homework and study
  • Fourier Series design and analysis

Fourier Series Calculator FAQs

What is a Fourier series and why is it useful?

A Fourier series represents a periodic function as an infinite sum of sine and cosine functions (or complex exponentials). It's useful because it decomposes complex periodic signals into simple frequency components, making analysis much easier. For example, a square wave can be written as a sum of sine waves at odd harmonics. This decomposition is fundamental in signal processing, communications, acoustics, and solving differential equations. Any "reasonable" periodic function can be represented this way, making Fourier series a universal tool.

How do I calculate Fourier coefficients?

For a function f(x) with period 2L, calculate coefficients by integration: a₀ = (1/L)∫f(x)dx from -L to L (average value), aₙ = (1/L)∫f(x)cos(nπx/L)dx (cosine coefficients), and bₙ = (1/L)∫f(x)sin(nπx/L)dx (sine coefficients). These integrals project f(x) onto orthogonal basis functions. For even functions, all bₙ = 0 (only cosines). For odd functions, all aₙ = 0 (only sines). Symmetry simplifies calculations significantly.

Why do we need infinitely many terms?

Infinitely many terms are needed for exact representation of most periodic functions. However, in practice, a finite number of terms often provides excellent approximations. Smooth functions converge quickly—a few terms suffice. Functions with sharp corners or discontinuities need many more terms. The tradeoff is accuracy vs. computational cost. For a square wave, 10 terms give a recognizable approximation; 50 terms are quite accurate. The rate of convergence depends on function smoothness: smoother functions need fewer terms.

What is the Gibbs phenomenon?

The Gibbs phenomenon is an overshoot (about 9% of the jump height) that occurs near discontinuities when approximating functions with finite Fourier series. As you add more terms, the overshoot doesn't decrease—it just gets narrower and more concentrated at the discontinuity. This is fundamental to representing discontinuous functions with continuous basis functions. It's not an error but a inherent limitation. In applications, windowing techniques can reduce it, though with trade-offs in frequency resolution.

How does Fourier series differ from Fourier transform?

Fourier series apply to periodic functions, expanding them as discrete sums over harmonics (integer multiples of fundamental frequency). Fourier transforms apply to non-periodic functions, representing them as continuous integrals over all frequencies. The series is countably infinite (harmonics: n=0,1,2,...), while the transform is uncountably infinite (all real frequencies). For a periodic function, its Fourier transform is a sequence of delta functions at harmonic frequencies with heights equal to the Fourier series coefficients. The series is the "periodic" version of the transform.

Why are sine and cosine functions special for Fourier series?

Sine and cosine functions are eigenfunctions of the derivative operator and form an orthogonal basis for periodic functions. Their orthogonality over a period means ∫cos(mx)cos(nx)dx = 0 for m≠n, allowing unique decomposition. They're also complete—any periodic function can be represented. Physically, sines and cosines represent pure harmonic oscillations, the natural modes of vibration. Mathematically, they solve the wave equation, heat equation, and many other fundamental PDEs, making them ideal basis functions for analysis.

What is Parseval's theorem and what does it mean?

Parseval's theorem states that the total energy (integral of |f(x)|²) equals the sum of energies in all frequency components (sum of |aₙ|² and |bₙ|²). It shows that Fourier decomposition conserves energy—no energy is lost or gained in the transformation between time and frequency domains. This makes Fourier analysis a unitary transformation. In signal processing, it means the power in a signal can be computed either directly or by summing power in all frequency components, which is often easier.

How are Fourier series used in real-world applications?

Fourier series are everywhere: audio engineering (analyzing instrument timbre and designing equalizers), electrical engineering (AC power analysis and harmonic distortion), image compression (JPEG uses related DCT), telecommunications (multiplexing signals), structural engineering (analyzing building vibrations), acoustics (room resonances and speaker design), medical imaging (MRI reconstruction), climate science (analyzing seasonal patterns), and quantum mechanics (solving periodic potential problems). Anywhere periodic phenomena occur, Fourier analysis provides insight and computational tools.