Wolfram Function Repository
Instant-use add-on functions for the Wolfram Language
Function Repository Resource:
Generate a trig series that approximates a list of data
ResourceFunction["TrigApproximateList"][data,var] generates a trig series in var which approximately matches equally spaced data. | |
ResourceFunction["TrigApproximateList"][data,var,n] generates a trig series of n terms in var which approximately matches equally spaced data. | |
ResourceFunction["TrigApproximateList"][{{x1,y1},{x2,y2},…},var,n] generates two trig series of n terms in var which, as a parametric function, approximately matches each column of data. |
Create an approximate formula for a sequence of values based on the discrete Fourier transform of the data:
In[1]:= |
Out[2]= |
In[3]:= |
Out[3]= |
A simpler approximation can be created by using only the three most dominant values from the discrete Fourier transform:
In[4]:= |
Out[4]= |
In[5]:= |
Out[5]= |
For unevenly-spaced data or a path of points in 2D space, TrigApproximateList generates a pair of expressions using a common variable:
In[6]:= |
Out[10]= |
In[11]:= |
Out[11]= |
The output is appropriate for use within ParametricPlot to generate this approximation to a square:
In[12]:= |
Out[12]= |
More terms produce more accurate approximations:
In[13]:= |
Out[13]= |
When the number of terms is not specified, TrigApproximateList uses Length[data]/2 terms:
In[14]:= |
Out[14]= |
This produces the most accurate approximation possible while still preventing high-frequency over-fitting:
In[15]:= |
Out[15]= |
The data range is assumed to be from 1 to Length[data]. To change this, use DataRange:
In[16]:= |
Out[17]= |
In[18]:= |
Out[18]= |
Instead of specifying the number of terms to return, you can specify a criteria for deciding when a Fourier term is significant enough to use:
In[19]:= |
Out[19]= |
When a fixed number of terms is requested, you can specify which terms are more important with "TermOrderingFunction". Here terms with the largest real component are used first:
In[20]:= |
Out[20]= |
Create a smooth parametric outline from an image:
In[21]:= |
Out[22]= |
In[23]:= |
Out[23]= |
This work is licensed under a Creative Commons Attribution 4.0 International License