Fourier Series Calculator

CalculusFreeNo sign-up

A Fourier series writes a periodic function as a sum of sines and cosines. On [−π, π], \(f(x) = x\) has \(b_{n} = -\frac{2(-1)^{n}}{n}\), so x = 2(sin x − ½ sin 2x + ⅓ sin 3x − …).

Try it

Summation (Sigma) Calculator

Open the full calculator →

Type the problems from this lesson and check each step.

FreeStep by stepPartial-sum graph

\(x\)

Type pi for the interval [−π, π].

Try:
Fourier series
\(\displaystyle f(x) \sim \sum_{n=1}^{\infty}\left(-\frac{2\left(-1\right)^{n}}{n}\right)\sin\left(nx\right)\)
Exact coefficient formulas, checked against numerical integration for n = 1 to 6.
xy0−2π−3π/2−π−1π/21π/2π3π/22π−3−2−1123f (repeated every 2L)partial sum, 10 terms

The function repeated with period 2L (gray) and the partial sum (green). Jumps cause the Gibbs overshoot.

a₀ 0
n = 1: aₙ, bₙ 0, 2
n = 2: aₙ, bₙ 0, −1
n = 3: aₙ, bₙ 0, 0.6666667
n = 4: aₙ, bₙ 0, −0.5
n = 5: aₙ, bₙ 0, 0.4
n = 6: aₙ, bₙ 0, −0.3333333
n = 7: aₙ, bₙ 0, 0.2857143
n = 8: aₙ, bₙ 0, −0.25
Root-mean-square error of the 10-term sum 0.43627
Show steps
  1. On \([-\pi, \pi]\), \(f(x) = \frac{a_{0}}{2} + \sum_{n=1}^{\infty}\left[a_{n}\cos\left(nx\right) + b_{n}\sin\left(nx\right)\right]\).
  2. \(a_{0} = \frac{1}{\pi}\int_{-\pi}^{\pi} f(x)\,dx = 0\)
  3. \(a_{n} = \frac{1}{\pi}\int_{-\pi}^{\pi} f(x)\cos\left(nx\right)dx = 0\) (f is odd, so all cosine terms vanish)
  4. \(b_{n} = \frac{1}{\pi}\int_{-\pi}^{\pi} f(x)\sin\left(nx\right)dx = -\frac{2\left(-1\right)^{n}}{n}\)

How to use the Fourier series calculator

  1. Enter f(x), or choose piecewise and enter the formula on each half.
  2. Enter the half-period L (pi for [−π, π]).
  3. Choose how many terms to draw. Press Compute to see the coefficient formulas, a table of values and the graph.

Fourier coefficient formulas

\(f(x) \sim \frac{a_{0}}{2} + \sum_{n=1}^{\infty}\left[a_{n}\cos\frac{n\pi x}{L} + b_{n}\sin\frac{n\pi x}{L}\right]\)

  • \(a_{0} = \frac{1}{L}\int_{-L}^{L} f(x)\,dx\)
  • \(a_{n} = \frac{1}{L}\int_{-L}^{L} f(x)\cos\frac{n\pi x}{L}\,dx\)
  • \(b_{n} = \frac{1}{L}\int_{-L}^{L} f(x)\sin\frac{n\pi x}{L}\,dx\)

Useful facts: \(\sin(n\pi) = 0\) and \(\cos(n\pi) = (-1)^{n}\).

Even and odd functions

An odd function (like x or the square wave) has only sine terms: all \(a_{n} = 0\). An even function (like x² or |x|) has only cosine terms: all \(b_{n} = 0\). Checking symmetry first halves the work.

Worked example: square wave

f = −1 on (−π, 0) and 1 on (0, π). It is odd, so \(a_{n} = 0\) and \(b_{n} = \frac{2}{n\pi}\left(1 – (-1)^{n}\right)\), which is \(\frac{4}{n\pi}\) for odd n and 0 for even n: \(f(x) = \frac{4}{\pi}\left(\sin x + \frac{\sin 3x}{3} + \frac{\sin 5x}{5} + \cdots\right)\). Near the jumps the partial sums overshoot by about 9% (the Gibbs phenomenon).

Fourier series practice quiz: 10 questions

Test yourself with 10 multiple-choice questions. Choose an answer and press Submit to see if you are right and why. Your score appears at the end.

Question 1 of 10
1. An odd function on [−π, π] has…

Found a mistake? Let us know!

2. An even function has…

Found a mistake? Let us know!

3. cos(nπ) equals…

Found a mistake? Let us know!

4. sin(nπ) for integer n equals…

Found a mistake? Let us know!

5. For f(x) = 5 on [−π, π], a₀ = ?

Found a mistake? Let us know!

6. The period of the Fourier series on [−L, L] is…

Found a mistake? Let us know!

7. Is f(x) = x² even or odd?

Found a mistake? Let us know!

8. The Gibbs phenomenon is…

Found a mistake? Let us know!

9. At a jump, the Fourier series converges to…

Found a mistake? Let us know!

10. For f(x) = x on [−π, π], b₁ = ?

Found a mistake? Let us know!

Frequently asked questions

What is a Fourier series?

A way to write a periodic function as a constant plus an infinite sum of sines and cosines with frequencies that are whole-number multiples of a base frequency.

How are the coefficients calculated?

By integrating f(x) times cos(nπx/L) or sin(nπx/L) over one period and dividing by L.

Can I enter a piecewise function?

Yes, with one formula on (−L, 0) and another on (0, L), which covers square waves, triangle waves and half-wave functions.

Why are the formulas sometimes not shown?

When nerdamer cannot find a closed form that passes the numerical check for n = 1 to 6, the calculator shows the numerical coefficients instead.

What do the partial sums show?

They show how adding more terms makes the series approach the function, and the overshoot (Gibbs phenomenon) near jumps.

Sources

Related calculators

Browse all calculators

More calculus calculators

Browse all 354 calculators

Related to This Article

What people say about "Fourier Series Calculator - Effortless Math"?

No one replied yet.

Leave a Reply