Fourier Series Calculator

Use this Fourier Series Calculator to enter values, adjust options, and review results in a compact responsive workspace.

Results are calculated automatically as you enter data.

Formula and interpretation

Waveform overlay

Adaptive RMS error: -

Fourier series formula -

Coefficients

▼ See explanations and tips below ▼

What Is a Fourier Series?

A Fourier series is a way to describe a periodic function as a sum of simple waves. Instead of trying to work with a complicated repeating shape all at once, Fourier series break it into a constant average term plus sine and cosine waves called harmonics.

In practical terms, a Fourier series answers a useful question: which sine and cosine waves would you add together to rebuild one repeating pattern?

A smooth wave may need only one or two terms. A sharp-edged wave, such as a square wave, usually needs many harmonics before the approximation looks close to the original. Even then, the behavior near jump discontinuities has special limitations.

Fourier series are used throughout mathematics, physics, engineering, signal processing, acoustics, vibration analysis, heat-transfer problems, and differential equations. They are especially helpful when the same pattern repeats over a known period.


Why Fourier Series Matter

Many real systems repeat: alternating current, sound waves, rotating machinery, seasonal patterns, vibrations, and periodic boundary-value problems. Fourier series give a structured way to study those repeating patterns by frequency content.

This matters because sine and cosine waves are mathematically convenient. They are orthogonal over a full period, which means each harmonic can be measured separately without mixing with the others. Once the coefficients are known, the function can be approximated, graphed, compared, filtered, or analyzed one harmonic at a time.

For students, Fourier series make abstract ideas such as orthogonality, approximation, and convergence more concrete. For engineering and signal-processing users, the coefficients help show which frequency components dominate a waveform.


Key Terms to Know

  • Periodic function: A function that repeats after a fixed interval. If \(f(x + L) = f(x)\), then \(L\) is a period.
  • Period length: The width of one full repeat of the function. In this calculator, \(L = b - a\), where \(a\) is the period start and \(b\) is the period end.
  • Fundamental angular frequency: The base angular frequency of the repeating pattern, given by \(\omega = \frac{2\pi}{L}\).
  • Harmonic: A sine or cosine wave whose frequency is an integer multiple of the fundamental frequency.
  • Fourier coefficient: A number that tells how much of a particular cosine or sine harmonic is present.
  • \(a_0\) coefficient: The coefficient used for the constant, or average, part of the series. In the displayed reconstruction, the constant term is \(\frac{a_0}{2}\).
  • \(a_n\) coefficient: The cosine coefficient for harmonic \(n\).
  • \(b_n\) coefficient: The sine coefficient for harmonic \(n\).
  • Truncated Fourier series: A Fourier series stopped after a finite number of harmonics. It is an approximation, not the full infinite series.
  • RMS error: An adaptively integrated root-mean-square difference between the original function and the reconstruction.
  • Gibbs phenomenon: The persistent overshoot that appears near jump discontinuities when a Fourier series approximates a discontinuous function.

How Fourier Series Work

Suppose one period of a real-valued function \(f(x)\) runs from \(a\) to \(b\). The period length is

$$ L = b - a $$

and the fundamental angular frequency is

$$ \omega = \frac{2\pi}{L}. $$

A truncated Fourier reconstruction with \(N\) harmonics has the form

$$ S_N(x) = \frac{a_0}{2} + \sum_{n=1}^{N}\left[a_n\cos(n\omega x) + b_n\sin(n\omega x)\right]. $$

The coefficients are found by integrating the function against the matching sine or cosine wave over one period:

$$ a_0 = \frac{2}{L}\int_a^b f(x)\,dx $$
$$ a_n = \frac{2}{L}\int_a^b f(x)\cos(n\omega x)\,dx $$
$$ b_n = \frac{2}{L}\int_a^b f(x)\sin(n\omega x)\,dx. $$

The reason these formulas work is orthogonality. Over a full period, different sine and cosine harmonics do not overlap in the integral sense. Multiplying by a matching harmonic and integrating isolates that harmonic’s coefficient.

The constant term \(\frac{a_0}{2}\) represents the average level of the waveform. The cosine and sine terms then add variation above and below that average. As more harmonics are included, the truncated sum often gets closer to the original function over the chosen period.

For numerical use, the definite integrals do not have to be solved symbolically. This calculator evaluates complementary shifted grids, compares a neighboring grid, and doubles the density until the coefficient estimates agree. This helps expose ordinary grid aliasing while retaining the periodic-grid interpretation.


Examples of Fourier Series in Practice

Example 1: A Simple Sine Combination

Consider

$$ f(x) = \sin(x) + 0.5\sin(3x) $$

over \([-\pi, \pi]\).

This function is already written as a sum of sine harmonics. Its average value is zero, and it has no cosine terms. The important coefficients are

$$ b_1 = 1 $$

and

$$ b_3 = 0.5. $$

All other main coefficients are zero. In this case, the Fourier series is easy to read directly from the formula because the function is already in sine-and-cosine form.


Example 2: A Square Wave

A common square wave on \([-\pi, \pi]\) is

$$ f(x) = \begin{cases} -1, & x < 0 \\ 1, & x \ge 0. \end{cases} $$

This definition differs from an odd function only at \(x=0\). Replacing its value there with \(0\) gives an odd representative with the same Fourier coefficients, so its cosine coefficients are zero and its sine coefficients are nonzero only for odd harmonics:

$$ f(x) \sim \frac{4}{\pi}\left(\sin x + \frac{1}{3}\sin 3x + \frac{1}{5}\sin 5x + \cdots\right). $$

Adding more odd sine harmonics makes the flat parts and steep jump more recognizable. Near the jump, however, the approximation usually shows overshoot and ringing. That is not just a graphing issue; it is a known behavior of Fourier approximations near discontinuities.


Example 3: A Triangle-Like Wave

A triangle-like preset such as

$$ f(x) = 1 - \frac{2|x|}{\pi} $$

over \([-\pi, \pi]\) is even, so the sine coefficients are zero. The approximation is mainly built from cosine terms.

Compared with a square wave, a triangle-like wave is continuous, though it has sharp corners. Its Fourier coefficients usually shrink faster than those of a discontinuous square wave, so fewer harmonics may be needed for a visually smooth approximation.


How to Interpret the Result

The displayed formula \(S_N(x)\) is the current truncated Fourier reconstruction. It uses the selected number of included terms, not the full infinite series.

The value of \(\omega\) tells you the fundamental angular frequency set by the selected period. A longer period gives a smaller \(\omega\); a shorter period gives a larger \(\omega\).

The coefficient table shows how much each harmonic contributes:

  • \(a_0\) controls the constant offset through \(\frac{a_0}{2}\).
  • \(a_n\) multiplies the cosine part of harmonic \(n\).
  • \(b_n\) multiplies the sine part of harmonic \(n\).
  • The amplitude summarizes the combined sine-and-cosine strength of a harmonic as \(\sqrt{a_n^2 + b_n^2}\).

A large harmonic amplitude means that harmonic has a strong presence in the reconstruction. A value close to zero means the harmonic contributes little or nothing.

The adaptive RMS error estimates the period average of the squared difference between the original function and the current truncated reconstruction:

$$ \text{RMS error} = \sqrt{\frac{1}{L}\int_a^b\left(f(x)-S_N(x)\right)^2\,dx}. $$

A smaller RMS error means the reconstruction is closer in the period-wide mean-square sense. The calculator evaluates this integral on independent shifted and neighboring grids and refines them adaptively. The reported numerical error remains an estimate rather than a rigorous mathematical bound.

The graph is best read as a visual comparison: original function, reconstructed Fourier approximation, and the selected harmonic contribution. If the approximation improves as terms are added, the graph should generally follow the original curve more closely away from difficult points such as jumps, corners, or rapidly changing regions.


Common Mistakes and Misconceptions

One common mistake is treating the harmonic count and the starting sample count as the same thing. The harmonic count controls how many sine and cosine terms are included. Starting samples controls the first numerical grid; the calculator refines it automatically.

Another mistake is expecting exact symbolic coefficients. Numerical Fourier calculators estimate integrals, so results can differ slightly from exact hand-derived coefficients, especially when the function has jumps, sharp corners, or rapid oscillations.

It is also easy to choose the wrong period. The interval from period start to period end should represent one complete repeat of the function. If the interval contains only part of a repeat, or more than one intended repeat, the coefficients will describe that chosen interval as one period.

Users sometimes expect more harmonics to remove all visible artifacts near a jump. More terms usually make the approximation better over much of the interval, but discontinuities can still show overshoot near the jump.

Syntax can also cause problems. Use decimal points rather than decimal commas, use \(x\) as the only variable, and keep period bounds as constants rather than expressions involving \(x\).

Finally, when many terms are resolved, the formula display shows up to five largest active sine or cosine terms and then an ellipsis. The coefficient table is the better place to inspect the full computed list of coefficients.


When to Use Fourier Series

Use Fourier series when a problem involves one repeating interval and you want to approximate, analyze, or visualize it with sine and cosine waves.

Typical uses include:

  • studying periodic functions in calculus, differential equations, and applied mathematics;
  • approximating square, sawtooth, triangle, and custom waveforms;
  • identifying dominant harmonics in a signal-like function;
  • comparing how adding terms changes the reconstruction;
  • exploring the effect of discontinuities, corners, and symmetry;
  • preparing for related topics such as Fourier transforms, frequency analysis, and spectral methods.

Fourier series are most appropriate when the function is intended to repeat periodically. For nonrepeating data or functions on an infinite interval, a Fourier transform or another approximation method may be more suitable.


Limitations and Things to Keep in Mind

A truncated Fourier series is an approximation. The full mathematical series may have infinitely many terms, but a calculator can only display and compute a finite number.

The calculator treats the entered function over the selected interval as one period of a periodic function. The periodic extension outside that interval is implied, even if the typed expression itself does not naturally repeat.

The coefficients are estimated with adaptive, shifted periodic grids and compensated summation. Results are suppressed if refined and neighboring grids do not agree. Functions with singularities, holes, or non-finite values are not treated as improper Fourier integrals.

The calculator is designed for real-valued functions of one variable, \(x\). Complex-valued functions, multiple variables, user-defined functions, and unsupported function names are outside its scope.

Harmonics must be a whole number from 1 through 40, and starting samples must be a whole number from 200 through 4000. Refinement may use up to 32000 points. Invalid values are rejected rather than silently rounded or clamped.

Displayed numbers use significant-digit formatting that preserves small nonzero values and scientific exponents. A term is omitted from the compact formula only when it is indistinguishable from zero at its estimated coefficient uncertainty.

The RMS integral and coefficient errors are numerical estimates. Cross-checking catches many aliasing failures, but no finite collection of samples can prove correctness for every possible function.

For engineering, scientific, or safety-critical work, verify important results with an appropriate analytical method, numerical method, or professional tool.


How to Use This Calculator

  1. Choose a preset wave or select the custom option.
  2. Enter a function of \(x\). Supported names include \(x\), \(\pi\), \(e\), sin, cos, tan, asin, acos, atan, abs, exp, log, ln, sqrt, floor, ceil, min, max, and pow.
  3. Enter the period start and period end as constant expressions, such as -pi and pi. The period end must be greater than the period start.
  4. Set the harmonic count from 1 to 40.
  5. Set the starting integration density as a whole number from 200 to 4000.
  6. Use the included-terms explorer to choose how many harmonics appear in the current reconstruction.
  7. Optionally enable animation to watch the reconstruction change as more terms are included.
  8. Review the formula, adaptive RMS error, coefficient table and error column, convergence status, graph, and calculation steps.
  9. Download the graph after a valid calculation has been produced, if you need a PNG image of the result.

Use decimal points for decimal numbers. For example, enter 1.5, not 1,5.


Frequently Asked Questions

Is a Fourier series always exact?

The infinite Fourier series may represent the function under suitable conditions, but a finite reconstruction is only an approximation. At jump discontinuities, the series typically converges to the midpoint of the left- and right-hand limits rather than to either side of the jump.


Why does the approximation overshoot near a square-wave jump?

Sharp jumps require many harmonics. As more terms are added, the overshoot becomes narrower, but its height does not disappear in the simple way users often expect. This behavior is known as the Gibbs phenomenon.


What is the difference between \(a_n\) and \(b_n\)?

The \(a_n\) coefficients multiply cosine harmonics, while the \(b_n\) coefficients multiply sine harmonics. If a function has even symmetry on a symmetric interval, many sine coefficients may be zero. If it has odd symmetry, many cosine coefficients may be zero.


How many harmonics should I use?

Use enough harmonics for the level of detail you need. Smooth functions may look accurate with only a few terms. Discontinuous or sharply changing functions usually need more terms, and even then the approximation near jumps should be interpreted carefully.


What does a lower adaptive RMS error mean?

A lower adaptive RMS error means the truncated series is closer to the original function in estimated mean-square distance across the period. It is useful for comparing term counts, but it is not a guarantee of exact agreement everywhere.


Why was my function rejected?

The function may contain unsupported names, a variable other than \(x\), a decimal comma, a top-level comma, an expression that is too long, or a value that becomes undefined at a sampled point. Period bounds must be finite constants and cannot contain \(x\).


Can this handle complex Fourier series?

No. This calculator uses the real trigonometric form with sine and cosine coefficients. Complex Fourier coefficients require a different representation.


Sources and References

Books and Open Textbooks

  1. Russell Herman. Introduction to Partial Differential Equations. Mathematics LibreTexts, Chapter 3, Sections 3.2 “Fourier Trigonometric Series” and 3.3 “Fourier Series Over Other Intervals.” Accessed June 28, 2026. Section 3.2/03%3ATrigonometricFourierSeries/3.02%3AFourierTrigonometricSeries>) and Section 3.3/03%3ATrigonometricFourierSeries/3.03%3AFourierSeriesOverOtherIntervals>)
  2. William F. Trench. Elementary Differential Equations with Boundary Value Problems. Free edition, originally published by Brooks/Cole Thomson Learning, 2001; open edition hosted through Mathematics LibreTexts and Trinity University. Chapter 11, Section 11.2 “Fourier Series I.” Accessed June 28, 2026. Section 11.2/11%3ABoundaryValueProblemsandFourierExpansions/11.02%3AFourierSeries_I>)
  3. OpenStax. Calculus Volume 2. Section 3.6 “Numerical Integration.” Rice University, accessed June 28, 2026. Section 3.6

Online and Official Sources

  1. National Institute of Standards and Technology. “ROOT MEAN SQUARE ERROR.” NIST/SEMATECH Dataplot Reference Manual, created September 8, 2010; last updated October 7, 2016. Accessed June 28, 2026. NIST Dataplot reference