Trigonometric Fitting and Interpolation

Trigonometric functions might be the best choice for fitting or interpolating periodic data. If the highest order (period) of the trigonometric function is less than 10, then the least-squares fit to the 10 points is shown. If the order is 10, then the interpolating trigonometric function is plotted. The values of the 10 data points are controlled by the 10 sliders. The checkbox adds a polynomial interpolation to the plot for comparison.


  • [Snapshot]
  • [Snapshot]
  • [Snapshot]


Because of the orthogonality of trigonometric functions, coefficients obtained from the discrete Fourier transform give the proper weights for both least-squares fitting and interpolation. From [1], if is the order of the trigonometric polynomial and is the number of data points, then
is the least-squares fit of the data if and the interpolating function if . In this equation, is the discrete Fourier transform of the data.
[1] T. Sauer, Numerical Analysis, 2nd ed., Boston: Pearson, 2012.
    • Share:

Embed Interactive Demonstration New!

Just copy and paste this snippet of JavaScript code into your website or blog to put the live Demonstration on your site. More details »

Files require Wolfram CDF Player or Mathematica.