Calculator inputs
The page uses a responsive 3-column grid on large screens, 2 columns on smaller screens, and 1 column on mobile.
Formula used
Triangle wave Fourier series
f(t) = D + (8A/π²) Σ[(-1)^m / (2m+1)²] · sin((2m+1)(ω₀t + φ))
Fundamental angular frequency
ω₀ = 2π / T
Odd-harmonic coefficient
bₙ = (8A/π²)(-1)^((n-1)/2)/n² for odd n, and aₙ = 0.
Exact comparison signal
f_exact(t) = D + (2A/π) asin(sin(ω₀t + φ))
RMS and error metrics
RMS_exact = √(A²/3 + D²)
RMSE = √(average((f_approx - f_exact)²))
THD = √(Σ bₙ² for n≥3) / |b₁| using the chosen truncated set.
This calculator assumes the standard symmetric triangle wave. Only odd harmonics appear, and their magnitudes decay with the square of harmonic order.
How to use this calculator
- Enter the peak amplitude of the triangle wave.
- Provide the signal period in your preferred time unit.
- Set the phase shift and choose degrees or radians.
- Use a DC offset when the waveform is vertically shifted.
- Select how many odd harmonics should build the partial sum.
- Choose sample points and plotted cycles for smoother graphs.
- Press the calculate button to display the results above the form.
- Review waveform plots, harmonic coefficients, RMS, THD, and error tables.
- Use the CSV or PDF buttons to export the results.
Example data table
The example below shows a realistic setup for checking convergence quality with several odd harmonics.
| Amplitude A | Period T | Phase | Offset D | Odd harmonics | Sample points | Cycles | Expected behavior |
|---|---|---|---|---|---|---|---|
| 5 | 2 | 0° | 0 | 9 | 600 | 2 | Good waveform match with visible corner smoothing. |
| 3 | 1 | 30° | 1 | 15 | 1000 | 3 | Higher energy capture and smaller RMSE. |
| 8 | 4 | 0.5 rad | -0.5 | 5 | 400 | 1.5 | Fast estimate with a rougher corner approximation. |
Frequently asked questions
1) Why does the spectrum contain only odd harmonics?
A symmetric triangle wave has half-wave symmetry. That symmetry removes even harmonics from the Fourier series, leaving only odd terms with alternating signs and rapidly decaying magnitudes.
2) Why do the harmonic magnitudes decay as 1/n²?
The triangle wave is smoother than a square wave, so its spectrum falls faster. Its piecewise linear shape creates coefficients proportional to 1/n², which improves convergence noticeably.
3) Why is the approximation smooth near corners?
A finite Fourier sum cannot reproduce the exact sharp slope change with only a few terms. More odd harmonics reduce corner error and make the partial sum look closer to the exact waveform.
4) What does the phase input change?
Phase shift moves the waveform horizontally in time. It affects the plotted starting point and the sine argument inside every harmonic, but it does not change the coefficient magnitudes.
5) What does DC offset do in this calculator?
DC offset shifts the entire signal vertically. It changes the mean level and RMS value, but the zero-mean harmonic structure of the triangle wave remains the same.
6) Why compare exact RMS and approximation RMS?
RMS comparison shows how much signal energy the selected odd harmonics capture. When the approximation RMS approaches the exact RMS, the partial sum is representing more of the waveform energy.
7) What is truncated THD here?
Truncated THD measures harmonic content above the fundamental using only the selected finite series. It is useful for comparison, but it is not the same as an infinite-series THD value.
8) When should I increase sample points?
Increase sample points when plots look coarse, when several cycles are displayed, or when you want more detailed exported waveform samples. Higher sampling improves visual smoothness and numerical comparisons.