This is documentation for Mathematica 6, which was
based on an earlier version of the Wolfram Language.
View current documentation (Version 11.2)

Manipulating Numerical Data

When you have numerical data, it is often convenient to find a simple formula that approximates it. For example, you can try to "fit" a line or curve through the points in your data.
Fit[{y1,y2,...},{f1, f2,...},x]
fit the values yn to a linear combination of functions fi
Fit[{{x1,y1},{x2,y2},...},{f1, f2,...},x]
fit the points (xn, yn) to a linear combination of the fi

Fitting curves to linear combinations of functions.

This generates a table of the numerical values of the exponential function. Table is discussed in "Making Tables of Values".
In[1]:=
Click for copyable input
Out[1]=
This finds a least-squares fit to data of the form c1+c2x+c3x2. The elements of data are assumed to correspond to values 1, 2, ... of x.
In[2]:=
Click for copyable input
Out[2]=
This finds a fit of the form c1+c2x+c3x3+c4x5.
In[3]:=
Click for copyable input
Out[3]=
This gives a table of x, y pairs.
In[4]:=
Click for copyable input
Out[4]=
This finds a fit to the new data, of the form c1+c2sin (x)+c3sin (2x).
In[5]:=
Click for copyable input
Out[5]=
FindFit[data,form,{p1,p2,...},x]
find a fit to form with parameters pi

Fitting data to general forms.

This finds the best parameters for a linear fit.
In[6]:=
Click for copyable input
Out[6]=
This does a nonlinear fit.
In[7]:=
Click for copyable input
Out[7]=
One common way of picking out "signals" in numerical data is to find the Fourier transform, or frequency spectrum, of the data.
Fourier[data]numerical Fourier transform
InverseFourier[data]inverse Fourier transform

Fourier transforms.

Here is a simple square pulse.
In[8]:=
Click for copyable input
Out[8]=
This takes the Fourier transform of the pulse.
In[9]:=
Click for copyable input
Out[9]=
Note that the Fourier function in Mathematica is defined with the sign convention typically used in the physical sciences—opposite to the one often used in electrical engineering. "Fourier Transforms" gives more details.