Fourier Series Calculator
Calculate Fourier series coefficients for periodic functions. Enter values for instant results with step-by-step formulas.
Calculator
Adjust values & calculateHarmonic Coefficients
Formula
Where a0 is the DC component (average value), an and bn are the Fourier cosine and sine coefficients for the n-th harmonic, and omega = 2*pi/T is the fundamental angular frequency with period T.
Last reviewed: December 2025
Worked Examples
Example 1: Square Wave Fourier Coefficients
Example 2: Triangle Wave Analysis
Background & Theory
The Fourier Series Calculator applies the following established principles and formulas. Mathematics rests on a hierarchy of number systems, each extending the previous. The natural numbers (1, 2, 3, ...) support counting and ordering. The integers add negative values and zero, enabling subtraction without restriction. The rational numbers, expressible as p/q where p and q are integers and q is nonzero, close the system under division. The real numbers fill the gaps left by irrationals such as the square root of 2 or pi, forming a complete ordered field. The complex numbers, written as a + bi where i is the square root of negative one, complete the algebraic closure of the reals and allow every polynomial to have a root. Prime factorization states that every integer greater than one is uniquely expressible as a product of primes, a result known as the Fundamental Theorem of Arithmetic. Computing the greatest common divisor (GCD) of two integers relies most efficiently on the Euclidean algorithm: repeatedly replace the larger number with the remainder when it is divided by the smaller, until the remainder is zero. The last nonzero remainder is the GCD. The least common multiple (LCM) follows from the identity LCM(a, b) = |a * b| / GCD(a, b). Modular arithmetic defines equivalence classes of integers that share the same remainder under division by a modulus n. Fermat's Little Theorem and Euler's Theorem arise from this structure and underpin modern cryptography. Logarithms are the inverses of exponential functions. If b raised to the power x equals y, then the logarithm base b of y equals x. The natural logarithm uses base e, approximately 2.71828. Combinatorics counts arrangements and selections. The number of ordered arrangements (permutations) of r objects from n distinct objects is nPr = n! / (n - r)!. The number of unordered selections (combinations) is nCr = n! / (r! * (n - r)!). Pascal's triangle arranges these binomial coefficients so that each entry equals the sum of the two entries directly above it. The Fibonacci sequence, defined by F(1) = 1, F(2) = 1, and F(n) = F(n-1) + F(n-2), appears throughout nature and connects deeply to the golden ratio via Binet's formula.
History
The history behind the Fourier Series Calculator traces back through the following developments. Mathematics as a systematic discipline traces to ancient Mesopotamia. Babylonian clay tablets dating to around 1800 BCE demonstrate knowledge of quadratic equations, Pythagorean triples, and base-60 arithmetic, suggesting a practical mathematical tradition far preceding Greek formalism. Euclid of Alexandria compiled the Elements around 300 BCE, establishing the axiomatic method that would define rigorous mathematics for over two thousand years. His work organized plane geometry, number theory, and proportion into logically chained propositions derived from a small set of postulates. The algorithm bearing his name for computing GCDs appears in Book VII and remains in use today. In the 9th century, the Persian scholar Muhammad ibn Musa Al-Khwarizmi wrote Al-Kitab al-mukhtasar fi hisab al-jabr wal-muqabala, the treatise whose title gave algebra its name. He systematized the solution of linear and quadratic equations and described procedures that operated on unknowns as objects, a conceptual leap away from purely numerical calculation. Rene Descartes introduced coordinate geometry in 1637 by uniting algebra and Euclidean geometry, allowing curves to be studied through equations. This synthesis set the stage for calculus. Isaac Newton and Gottfried Wilhelm Leibniz independently developed calculus during the 1660s and 1670s, triggering a priority dispute that lasted decades and divided British and Continental mathematicians. Carl Friedrich Gauss proved the Fundamental Theorem of Algebra in 1799, showing that every nonconstant polynomial has at least one complex root. His Disquisitiones Arithmeticae of 1801 established modern number theory. David Hilbert's formalist program at the turn of the 20th century sought to place all of mathematics on an explicit axiomatic foundation, a project that Kurt Godel's incompleteness theorems of 1931 showed to be fundamentally limited. Alan Turing's work in the 1930s on computability introduced the theoretical model of the stored-program computer and linked mathematical logic directly to the limits of algorithmic calculation. His proof that no algorithm can decide in general whether an arbitrary program will halt or run forever placed fundamental boundaries on what mathematics can mechanically determine, and it opened the discipline now known as theoretical computer science.
Frequently Asked Questions
Formula
f(x) = a0/2 + sum(an*cos(n*omega*x) + bn*sin(n*omega*x))
Where a0 is the DC component (average value), an and bn are the Fourier cosine and sine coefficients for the n-th harmonic, and omega = 2*pi/T is the fundamental angular frequency with period T.
Worked Examples
Example 1: Square Wave Fourier Coefficients
Problem: Find the first 5 non-zero Fourier coefficients and approximate value at x = 0.5 for a square wave with amplitude 1 and period 2*pi.
Solution: Square wave: f(x) = (4/pi) * sum of sin(nx)/n for odd n\nb1 = 4/(1*pi) = 1.2732\nb3 = 4/(3*pi) = 0.4244\nb5 = 4/(5*pi) = 0.2546\nb7 = 4/(7*pi) = 0.1819\nb9 = 4/(9*pi) = 0.1415\nApprox at x=0.5: 1.2732*sin(0.5) + 0.4244*sin(1.5) + 0.2546*sin(2.5) + 0.1819*sin(3.5) + 0.1415*sin(4.5) = 0.9955
Result: 5-term approximation at x=0.5: 0.9955 | THD: 48.3%
Example 2: Triangle Wave Analysis
Problem: Compute the Fourier series of a triangle wave with amplitude 2 and period 2*pi using 10 terms.
Solution: Triangle wave: f(x) = (8A/pi^2) * sum of [(-1)^((n-1)/2) / n^2] * sin(nx) for odd n\nb1 = 8*2/pi^2 = 1.6211\nb3 = -8*2/(9*pi^2) = -0.1801\nb5 = 8*2/(25*pi^2) = 0.0649\nb7 = -8*2/(49*pi^2) = -0.0331\nCoefficients decrease as 1/n^2 - much faster convergence than square wave
Result: Triangle wave converges rapidly | b1 = 1.6211 | b3 = -0.1801 | THD: 12.1%
Frequently Asked Questions
What is a Fourier series and why is it important?
A Fourier series is a mathematical representation of a periodic function as an infinite sum of sine and cosine functions, each with specific amplitudes and frequencies. Named after Joseph Fourier, this decomposition reveals the frequency content hidden within any periodic signal. The importance of Fourier series lies in their ability to break complex waveforms into simple harmonic components that are much easier to analyze individually. This principle is fundamental to signal processing, audio engineering, telecommunications, quantum mechanics, heat transfer, and image compression. Without Fourier analysis, technologies like MP3 compression, MRI imaging, and digital communications would not exist.
What do the Fourier coefficients a_n and b_n represent?
The Fourier coefficients a_n and b_n represent the amplitudes of the cosine and sine components at each harmonic frequency. The coefficient a0 divided by 2 gives the DC offset or average value of the function over one period. The coefficient a_n multiplies cos(n*omega*t), representing the even (symmetric) component at the n-th harmonic, while b_n multiplies sin(n*omega*t), representing the odd (antisymmetric) component. Together, they determine the magnitude and phase of each frequency component. A large coefficient at harmonic n means that frequency contributes significantly to the overall shape of the waveform. These coefficients are calculated using integral formulas that essentially measure how much the original function correlates with each sine and cosine basis function.
How does a square wave relate to its Fourier series?
A square wave is represented by a Fourier series containing only odd harmonics with coefficients that decrease as 1/n. Specifically, a square wave of amplitude A has the series (4A/pi) times [sin(x) + sin(3x)/3 + sin(5x)/5 + sin(7x)/7 + ...]. The even harmonics (2nd, 4th, 6th) are all zero due to the half-wave symmetry of the square wave. This slow 1/n decay means many terms are needed for a good approximation, which is why the overshoot at discontinuities (Gibbs phenomenon) is prominent. The square wave Fourier series is one of the most studied examples in mathematics and engineering because it clearly demonstrates how sharp transitions require high-frequency content.
What is the Gibbs phenomenon in Fourier series?
The Gibbs phenomenon is an overshoot that occurs near discontinuities when approximating a function with a finite number of Fourier terms. At any jump discontinuity, the partial sum of the Fourier series overshoots by approximately 8.95 percent of the jump, regardless of how many terms are included. Adding more terms makes the overshoot narrower but not shorter. This was discovered by Henry Wilbraham in 1848 and later rediscovered by Josiah Willard Gibbs in 1899. The Gibbs phenomenon has practical implications in signal processing, where it causes ringing artifacts near sharp transitions. Engineers use windowing functions like Hamming or Hann windows to reduce these overshoots at the cost of slightly worse frequency resolution.
What is the difference between Fourier series and Fourier transform?
The Fourier series applies to periodic functions and decomposes them into discrete harmonics at integer multiples of the fundamental frequency. The Fourier transform applies to non-periodic (aperiodic) functions and produces a continuous spectrum of frequencies. You can think of the Fourier series as a special case where the frequency spectrum is discrete, like the teeth of a comb, while the Fourier transform spreads energy across all frequencies continuously. In practice, the Discrete Fourier Transform (DFT) and its fast implementation (FFT) are used on sampled data. For periodic signals, the Fourier series gives exact harmonic amplitudes; for transient signals, the Fourier transform reveals the frequency distribution over a continuous range.
How many terms are needed for a good Fourier approximation?
The number of terms needed depends on the smoothness of the original function and the desired accuracy. Smooth functions like sine waves need very few terms (sometimes just one), while discontinuous functions like square waves need many more. For a square wave, 10 terms give a recognizable approximation, 50 terms look quite close, but the Gibbs overshoot at discontinuities never fully disappears. For a triangle wave, coefficients decrease as 1/n^2, so convergence is much faster and 10 to 20 terms produce an excellent fit. As a general rule, smoother functions converge faster because their high-frequency Fourier coefficients decrease more rapidly. Functions with k continuous derivatives have coefficients that decrease at least as fast as 1/n^(k+1).
References
Reviewed by Manoj Kumar, Mathematics Educator ยท Editorial policy