Chebyshev Approximations
This chapter describes the routines for computing Chebyshev approximations to univariate functions provided by the PLT Scheme Science Collection. A Chebyshev approximation is a trucvation of the series
where the Chebyshev polymonials T_{n}(x) = cos(n arccos x) provides an orthogonal basis of polynomials in the interval [  1,1] with the weight function 1 / (1  x^{2})^{1/2}. The first few Chebyshev ploymonials are, T_{0}(x) = 1, T_{1}(x) = x, T_{2}(x) = 2 x^{2}  1. For more information see Abramowitz and Stegan, Chapter 22.
The functions described in this chapter are defined in the chebyshev.ss file in the science collection and are made available using the form:
(require (planet "chebyshev.ss" ("williams" "science.plt")))
11.1 The chebyshevseries Structure
Structure:
chebyshevseries 
Contract: (struct chebyshevseries ((coefficient (vectorof real?)) (order naturalnumber?) (lower real?) (upper real?))) 

The approximations are made over the range [lower, upper] using order + 1 terms, including coefficient[0]. The series is computed using the following convention,
which is needed when accessing the coefficients directly.
11.2 Creation and Calculation of Chebyshev Series
Function:
(makechebyshevseriesorder order) 
Contract: (> naturalnumber? chebyshevseries?) 

Function:
(chebyshevseriesinit cs func a b) 
Contract: (> chebyshevseries? procedure? real? real? void?) 

11.3 Chebyshev Series Evaluation
Function:
(chebysheveval cs x) 
Contract: (> chebyshevseries? real? real?) 

Function:
(chebyshevevaln cs n x) 
Contract: (> chebyshevseries? naturalnumber? real? real?) 

11.4 Examples
Example: The following program computes Chebyshev approximations to a step function. This is an extremely difficult approximation to make, due to the discontinuity, and was chosed as an example where approximation error is visible. For smooth functions the Chebyshev approximation converges extremely rapidly and errors would not be visible.
(require (planet "chebyshev.ss" ("williams" "science.plt"))) (require (lib "plot.ss" "plot")) (define (f x) (if (< x 0.5) .25 .75)) (define (chebyshevexample n) (let ((cs (makechebyshevseriesorder 40)) (yvalues '()) (ycs10values '()) (ycs40values '())) (chebyshevseriesinit cs f 0.0 1.0) (do ((i 0 (+ i 1))) ((= i n) (void)) (let* ((x (exact>inexact (/ i n))) (y (f x)) (ycs10 (chebyshevevaln cs 10 x)) (ycs40 (chebysheveval cs x))) ;(printf "~a ~a ~a ~a\n" ; x y ycs10 ycs40) (set! yvalues (cons (vector x y) yvalues)) (set! ycs10values (cons (vector x ycs10) ycs10values)) (set! ycs40values (cons (vector x ycs40) ycs40values)))) (printf "~a~n" (plot (mix (points (reverse yvalues)) (points (reverse ycs10values))) (xmin 0) (xmax 1) (ymin 0) (ymax 1) (title "Chebyshev Series Order 10"))) (printf "~a~n" (plot (mix (points (reverse yvalues)) (points (reverse ycs40values))) (xmin 0) (xmax 1) (ymin 0) (ymax 1) (title "Chebyshev Series Order 40"))))) (chebyshevexample 100)
Figures 71 and 72 show the resulting output plots.

