CHEBYSHEV FIT
The operator family Chebyshev_... implements approximation and evaluation of functions by the Chebyshev method. Let T(n,a,b,x) be the Chebyshev polynomial of order n transformed to the interval (a,b). Then a function f(x) can be approximated in (a,b) by a series
for i := 0:n sum c(i)*T(i,a,b,x)
The operator chebyshev_fit computes this approximation an d returns a list, which has as first element the sum expressed as a polynomial and as second element the sequence of Chebyshev coefficients. Chebyshev_df and Chebyshev_int transform a Chebyshev coefficient list into the coefficients of the corresponding derivative or integral respectively. For evaluating a Chebyshev approximation at a given point in the basic interval the operator Chebyshev_eval can be used. Chebyshev_eval is based on a recurrence relation which is in general more stable than a direct evaluation of the complete polynomial.
chebyshev_eval(<coeffs>,<var>=(<lo> .. <hi>), <var>=<pt>)
chebyshev_df(<coeffs>,<var>=(<lo> .. <hi>))
chebyshev_int(<coeffs>,<var>=(<lo> .. <hi>))
where <fcn> is an algebraic expression (the target function), <var> is the variable of <fcn>, <lo> and <hi> are numerical real values which describe an interval <lo> <<hi>, the integer <n> is the approximation order (set to 20 if missing), <pt> is a number in the interval and <coeffs> is a series of Chebyshev coefficients.
on rounded; w:=chebyshev_fit(sin x/x,x=(1 .. 3),5); 3 2 w := {0.03824*x - 0.2398*x + 0.06514*x + 0.9778, {0.8991,-0.4066,-0.005198,0.009464,-0.00009511}} chebyshev_eval(second w, x=(1 .. 3), x=2.1); 0.4111