## Curve Fitting and Polynomial Evaluation

Because each DADiSP analysis window can be a mathematical combination of other windows in the Worksheet, you can use DADiSP to evaluate and plot polynomial expressions such as:

To generate a graph of the polynomial, we need to sweep x through a range of values and plot the result of this equation for each x value. You can use DADiSP to evaluate this expression with the following steps:

1. Generate a four-window Worksheet.

2. In W2, type the polynomial by substituting W1 for x:

(W1 + 1)/(W1 ^ 2 + 2 * W1 + 1)

3. Now, to sweep W2 through a linear range of values, generate a line in window 1:

gline(100, .01, 1.0, 0.0)

4. Window 2 displays the polynomial for 100 x values ranging from 0.0 to 1.0 and spaced 0.01 units apart.

5. To alter the number of points, spacing, or range of the sweep, just change the GLINE parameters in W1.

We could also use the variable x directly. For example:

x = -1..0.01..1;

y = (x + 1) / (x^2 + 2*x + 1);

Now the variable y contains the polynomial values ranging from –1 to 1 by an increment of 0.01.

This polynomial evaluation technique is not limited to linear sweeps. You can also evaluate polynomials with any sweep function. Because of this, DADiSP can also easily process Z-transforms. For example, consider the following single pole transform:

To evaluate this transform:

1. Set up the equation in window 4 by substituting W3 for z:

W4: 1/(1 - 0.5 * W3 ^ -1)

2. Now, set up the unit circle values in window 3:

W3: exp(w1 * 2 * pi * i)

3. Since window 1 sweeps from 0.0 to 1.0, window 3 now contains 100 values of the unit circle sampled 0.01 radians apart. Window 4 displays the Z-transform evaluated over the unit circle.

4. By calculating the IFFT of window 4, we can view the transform in the time domain:

W5: real(ifft(w4))

and window 5 contains the expected decaying exponential.

This method of Z transform evaluation is encapsulated by the functions ZFREQ for the frequency domain response and IMPZ for the time domain impulse response, For example:

W6: zfreq({1}, {1, -0.5})

W7: impz({1}, {1, -0.5})

compute the frequency domain response and impulse response directly for the single pole system.