MATLAB Guide

This chapter describes MATLAB's functions for solving problems involving, polynomials, nonlinear equations, optimization and the fast Fourier transform. In many cases a function fun must be passed as an argument. As described in Section 10.1, fun can be a function handle, a string expression or an inline object. The MATLAB functions described in this chapter place various demands on the function that is to be passed, but most require it to return a vector of values when given a vector of inputs.
For mathematical background on the methods described in this and the next chapter suitable textbooks are [5], [6], [11], [18], [35], [61], [70], [81].
MATLAB represents a polynomial
by a row vector p = [p(1) p(2) p(n+1)] of the coefficients. (Note that compared with the representation ? n i=0 p ix i used in many textbooks, MATLAB's vector is reversed and its subscripts are increased by 1.)
Here are three problems related to polynomials:
Evaluation: Given the coefficients evaluate the polynomial at one or more points.
Root finding: Given the coefficients find the roots (the points at which the polynomial evaluates to zero).
Data fitting: Given a set of data { x i, y i} m i=1 find a polynomial that "fits" the data.
The standard technique for evaluating p( x) is Horner's method, which corresponds to the nested representation
Function polyval carries out Horner's method: y...