Functions > Data Analysis > Interpolation and Prediction > Example: Using Units with the Polynomial Interpolation Functions
Example: Using Units with the Polynomial Interpolation Functions
1. Define two input vectors and an independent variable.
Click to copy this expression
Click to copy this expression
Click to copy this expression
2. Define the units.
Click to copy this expression
Click to copy this expression
3. Evaluate the input vectors and the input variable.
Click to copy this expression
Click to copy this expression
Click to copy this expression
* 
The unit of the independent variable U must match the unit of the first argument vector.
Polynomial Interpolation
1. Use the polyint function to evaluate the interpolation function at the specified independent variable values.
Click to copy this expression
Click to copy this expression
Looking up U in input vector X results in a match and the corresponding exact value in vector Y is 1.333 with an error of zero. However, 2U has no exact match in X and this results in an interpolated value with a none-zero error.
2. Use function length to determine the length of the input vectors, then create a short program to evaluate the interpolation functions at different points. Display the interpolated points in the first column and the error values in the second column.
Click to copy this expression
Click to copy this expression
Variable u must be a scalar, and the unit m is added as part of the function argument.
3. Save the interpolation points and the error values into two separate vectors.
Click to copy this expression
Click to copy this expression
Click to copy this expression
4. Plot the interpolation points along with the error envelope.
Click to copy this expression
The error starts out relatively large then becomes negligent after the second interpolation point.
Polynomial Iteration
1. Use the polyiter function to evaluate the iteration function at the specified independent variable value, the number of maximum iterations and the tolerance.
Click to copy this expression
Click to copy this expression
* 
The algorithm stops if the last two iterated estimates of the data point agree to within the tolerance value, or if the number of iterations reaches the maximum allowed number of iterations.
The first result shows that the iteration function failed to converge after reaching the maximum allowed number of two iterations, so it returned the corresponding element in vector Y.
The second result shows that the iteration function converged after the third iteration and it did not reach the maximum allowed number of five iterations.
2. Use a short program to evaluate the iteration function at ten different points. Use function augment to add the error value in the fourth column of the returned matrix which displays the merge status in the first column, the number of utilized iterations in the second column, and the iterated values in the third column.
Click to copy this expression
3. Save the interpolation points and the error values into separate vectors.
Click to copy this expression
Click to copy this expression
4. Plot the iteration points for 3 iterations and an error of 0.25.
Click to copy this expression
The error is constant at every interpolation point.
5. Compare the returned results of interpolation and iteration when the maximum number of iterations is set to 3 and the error is set to 0.25.
Click to copy this expression
6. Show that the result of interpolation is identical to the result of iteration when the number of iterations is set to a large number and the error is set to zero.
Click to copy this expression
Click to copy this expression
The maximum number of iterations must be less than the length of the input vectors.
Was this helpful?