Fourier Approximation Calculator

Approximate periodic functions with flexible harmonic controls. Inspect coefficients, reconstruction quality, and pointwise error instantly. Export sampled values, charts, and summaries for deeper study.

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.

Custom mode uses the sampled table below.
Applied to preset waves and custom sample values.
One repeating interval for the target function.
Higher values improve detail and cost more time.
Used for numerical coefficient integration.
More points make smoother curves.
Shift the input function horizontally.
Moves the waveform upward or downward.
Used mainly by the square waveform.
Controls the horizontal span of the graph.
Use one x,y pair per line. Example: 0,0 then 1,0.5. The data is extended periodically with linear interpolation.

Example Data Table

This sample table matches the custom waveform field and demonstrates one period of a piecewise signal.

x y Meaning
00.0Start of the period.
10.5Moderate rise.
21.0Local crest.
30.2Sharp descent.
4-0.8Negative trough.
5-0.3Recovery section.
60.0End 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

  1. Select a preset waveform or choose custom sampled data.
  2. Enter amplitude, period, harmonic count, and integration resolution.
  3. Adjust phase shift, vertical offset, duty cycle, and plot cycles if needed.
  4. For custom mode, provide one x,y pair per line for a single period.
  5. Click Approximate Function to compute the coefficients and render the Plotly graph.
  6. Review mean value, error measures, the coefficient table, and the graph.
  7. 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.

Related Calculators

fourier series visualizercosine series calculatortriangle wave fourierfourier analysis calculatoreven function fourierfourier series evaluatorfourier sum calculator

Important Note: All the Calculators listed in this site are for educational purpose only and we do not guarentee the accuracy of results. Please do consult with other sources as well.