Calculator Inputs
The page keeps a single-column reading flow, while the calculator controls use a responsive grid: three columns on large screens, two on medium screens, and one on mobile.
Example Data Table
This sample table matches the custom waveform field and demonstrates one period of a piecewise signal.
| x | y | Meaning |
|---|---|---|
| 0 | 0.0 | Start of the period. |
| 1 | 0.5 | Moderate rise. |
| 2 | 1.0 | Local crest. |
| 3 | 0.2 | Sharp descent. |
| 4 | -0.8 | Negative trough. |
| 5 | -0.3 | Recovery section. |
| 6 | 0.0 | End of the period and wrap point. |
Formula Used
The calculator estimates the finite Fourier series of a periodic function over one period T. It uses numerical integration with the trapezoidal rule.
a0 = (2 / T) ∫0→T f(x) dx
an = (2 / T) ∫0→T f(x) cos(2πnx / T) dx
bn = (2 / T) ∫0→T f(x) sin(2πnx / T) dx
SN(x) = a0/2 + Σ[n=1→N] (an cos(2πnx / T) + bn sin(2πnx / T))
Magnitude of harmonic n = √(an² + bn²)
Phase of harmonic n = atan2(bn, an)
The error metrics compare the original function and the reconstructed series at sampled plot points. RMSE emphasizes larger deviations, while maximum absolute error highlights the worst mismatch.
How to Use This Calculator
- Select a preset waveform or choose custom sampled data.
- Enter amplitude, period, harmonic count, and integration resolution.
- Adjust phase shift, vertical offset, duty cycle, and plot cycles if needed.
- For custom mode, provide one x,y pair per line for a single period.
- Click Approximate Function to compute the coefficients and render the Plotly graph.
- Review mean value, error measures, the coefficient table, and the graph.
- Use the CSV button for sampled values and coefficients, or PDF for a report snapshot.
FAQs
1. What does the harmonic count control?
It sets how many sine and cosine terms are included. More harmonics capture sharper edges and finer detail, but computation becomes heavier and Gibbs oscillations may remain near discontinuities.
2. Why does the approximation overshoot at jumps?
That behavior is the Gibbs phenomenon. Finite Fourier sums oscillate near discontinuities. Adding harmonics narrows the oscillation zone, yet the local overshoot does not disappear completely.
3. What does a0 represent?
The coefficient a0 controls the average level of the function over one period. The plotted series uses a0 divided by 2 as the constant term.
4. When should I increase integration points?
Increase them when the waveform is sharp, irregular, or defined by custom samples. A denser integration grid usually improves coefficient accuracy and reduces numerical noise.
5. How is custom data handled?
The calculator sorts the x,y pairs within one period and connects them with linear interpolation. That single period is then repeated periodically across the graph.
6. What is the magnitude column for?
It compresses each harmonic into one strength value, computed from an and bn. Larger magnitudes indicate stronger frequency content at that harmonic index.
7. Why can RMS values differ between the original and approximation?
A truncated series contains only limited harmonics. Missing higher frequencies reduce or reshape signal energy, so the reconstructed RMS may differ from the original waveform.
8. What does the CSV export include?
It exports a summary section, all harmonic coefficients, and the plotted sampled values with original, approximation, and pointwise error columns.