It is necessary to lay a polynomial using the polynomial base of Chebyshev

I applied linear least squares polynomials to the data using the polyfit function in matlab. From what I read, the standard polynomial basis (one-dimensional basis) is used. I read that using the Chebyshev polynomial basis for correspondence leads to greater numerical stability, so I would like to do this. Does this option have matlab?

+7
source share
2 answers

I think you are looking for the Chebfun toolbox. It overloads, in particular, the polyfit function using Chebychev points and Chebychev interpolations.

In addition to the above, you can always code it yourself. It is not that difficult. EDIT: see Post Mathematics1975 :).

+5
source

I assume here that you want Chebyshev polynomials of the first kind. As far as I know, Matlab does not have this built-in. However, it is easy to code yourself. Chebyshev polynomials are defined only on [-1,1], so you must first match your data x with this range. Then we use the recurrence relation to generate the Chebyshev polynomials http://en.wikipedia.org/wiki/Chebyshev_polynomials#Definition

T_ (n + 1) (x) = 2xT_ (n) x - T_ (n-1) (x)

If x is your abscissas and y , your data points generate your observation matrix A (this is equivalent to the Vandermond matrix for a monomial basis) for a polynomial correspondence of degree n , using:

 n = degree; m = length(x); %% Generate the z variable as a mapping of your x data range into the %% interval [-1,1] z = ((x-min(x))-(max(x)-x))/(max(x)-min(x)); A(:,1) = ones(m,1); if n > 1 A(:,2) = z; end if n > 2 for k = 3:n+1 A(:,k) = 2*z.*A(:,k-1) - A(:,k-2); %% recurrence relation end end 

then you can simply solve the linear system for your solution parameters (approximation coefficients) b using matrix division

 b = A \ y 

Here you must remember that when you evaluate your approximation, you must match the value with the interval [-1.1] before evaluating it. The coefficients will be valid only in the initial range of x , which you give for approximation. You cannot convince the approximation (in the right sense) outside of your initial range x . If you want to do this, you must use a wider span than your data, so when you match the points inside using a transform, your points will always be at [-1,1], and so your approximation estimate is valid.

I have not used Matlab for a while, so newer versions may have a built-in function that will do all this for you. This is not the last time I used it, but if all else fails, it will allow you to generate polynomial least squares approximations using the Chebyshev basis (first view)

+10
source

All Articles