               NEWS NLREG has been selected as the "Editor"s Pick" by SoftSeek. NLREG is in use at hundreds of universities, laboratories, and government agencies around the world (over 20 countries). For a list of a few organizations using NLREG click here. If you have categorical variables, you may want to use a Decision Tree to model your data. Check out the DTREG Decision Tree Builder. You also should check out the News Rover program that automatically scans Usenet newsgroups, downloads messages of interest to you, decodes binary file attachments, reconstructs files split across multiple messages, and eliminates spam and duplicate files.  ## Fit Sine Series To A Square Wave

This example fits a function involving a sine series to a square wave.

Fourier showed that the sum of a series of sine functions with odd coefficients of the angle could model a square wave if the appropriate multipliers were chosen for each of the sine terms. A perfect fit would require an infinite number of sine terms. In this example, we fit a sine series with four terms to a square wave.

Here are the NLREG statements to fit this function:

```Title "Fit Sine Series to Square Wave";
Variables X,Y;
Parameters p0,p1,p3,p5,p7;
Function y = p0 + p1*sin(x) + p3*sin(3*x) + p5*sin(5*x) + p7*sin(7*x);
Plot;
Data;
[ data goes here ]
```

Here is a plot generated by NLREG showing the function fitted to a a square wave set of values. 