Fourier Series of Sawtooth Wave: Formula and Example
The
Fourier series of a sawtooth wave is an infinite sum of sine terms with coefficients decreasing as 1/n. It is given by f(t) = (2/π) Σ (-1)^(n+1) (sin(n t) / n) for n=1 to infinity, representing the wave as a sum of harmonics.Syntax
The Fourier series for a sawtooth wave with period 2π is:
f(t) = (2/π) ∑n=1∞ (-1)^(n+1) (sin(n t) / n)
- f(t): value of the sawtooth wave at time t
- n: harmonic number (integer starting from 1)
- sin(n t): sine function at harmonic n
- 1/n: amplitude decreases with harmonic number
- (-1)^(n+1): alternates sign for each term
python
def sawtooth_fourier(t, terms=10): import numpy as np result = 0 for n in range(1, terms + 1): term = ((-1)**(n + 1)) * np.sin(n * t) / n result += term return (2 / np.pi) * result
Example
This example computes the sawtooth wave using its Fourier series with 10 terms and plots it over one period.
python
import numpy as np import matplotlib.pyplot as plt def sawtooth_fourier(t, terms=10): result = 0 for n in range(1, terms + 1): term = ((-1)**(n + 1)) * np.sin(n * t) / n result += term return (2 / np.pi) * result # Time values from -pi to pi t = np.linspace(-np.pi, np.pi, 400) # Compute sawtooth wave approximation sawtooth_wave = sawtooth_fourier(t, terms=10) # Plot plt.plot(t, sawtooth_wave, label='Fourier Series Approximation') plt.title('Sawtooth Wave Fourier Series (10 terms)') plt.xlabel('t') plt.ylabel('f(t)') plt.grid(True) plt.legend() plt.show()
Output
A plot window showing a sawtooth wave shape approximated by 10 Fourier terms over the interval [-π, π]. The wave rises linearly and sharply drops, repeating periodically.
Common Pitfalls
- Using cosine terms instead of sine terms; the sawtooth wave Fourier series uses only sine terms.
- Not including the alternating sign
(-1)^(n+1), which changes the wave shape. - Using too few terms leads to a poor approximation and visible Gibbs phenomenon (overshoot near discontinuities).
- Confusing the period; the formula assumes period 2π. Scaling time incorrectly changes the wave.
python
import numpy as np def wrong_sawtooth(t, terms=10): # Incorrect: uses cosine instead of sine result = 0 for n in range(1, terms + 1): term = np.cos(n * t) / n result += term return (2 / np.pi) * result # Correct function is sawtooth_fourier from previous section
Quick Reference
Fourier series formula for sawtooth wave:
f(t) = (2/π) Σ (-1)^(n+1) (sin(n t) / n)- Period: 2π
- Only sine terms, no cosine
- Amplitude decreases as 1/n
- Alternating sign for each harmonic
Key Takeaways
The sawtooth wave Fourier series uses only sine terms with amplitudes decreasing as 1/n and alternating signs.
The formula assumes a period of 2π; scaling time changes the wave shape.
Using more terms improves the approximation but Gibbs phenomenon near jumps remains.
Common mistakes include using cosine terms or missing the alternating sign factor.
Plotting the series helps visualize how harmonics build the sawtooth shape.