# cheby - Freeform - Chebyshev¶

 profile Evaluate the chebyshev approximation c at points x. cheby_approx Return the coefficients for the order n chebyshev approximation to function f evaluated over the range [low,high]. cheby_val Evaluate the chebyshev approximation c at points x. cheby_points Return the points in at which a function must be evaluated to generate the order $$n$$ Chebyshev approximation function. cheby_coeff Compute chebyshev coefficients for a polynomial of order n given the function evaluated at the chebyshev points for order n.

Freeform modeling with Chebyshev polynomials.

Chebyshev polynomials $$T_k$$ form a basis set for functions over $$[-1,1]$$. The truncated interpolating polynomial $$P_n$$ is a weighted sum of Chebyshev polynomials up to degree $$n$$:

$f(x) \approx P_n(x) = \sum_{k=0}^n c_i T_k(x)$

The interpolating polynomial exactly matches $$f(x)$$ at the chebyshev nodes $$z_k$$ and is near the optimal polynomial approximation to $$f$$ of degree $$n$$ under the maximum norm. For well behaved functions, the coefficients $$c_k$$ decrease rapidly, and furthermore are independent of the degree $$n$$ of the polynomial.

The models can either be defined directly in terms of the Chebyshev coefficients $$c_k$$ with method = ‘direct’, or in terms of control points $$(z_k, f(z_k))$$ at the Chebyshev nodes cheby_points() with method = ‘interp’. Bounds on the parameters are easier to control using ‘interp’, but the function may oscillate wildly outside the bounds. Bounds on the oscillation are easier to control using ‘direct’, but the shape of the profile is difficult to control.

bumps.cheby.profile(c, t, method)[source]

Evaluate the chebyshev approximation c at points x.

If method is ‘direct’ then $$c_i$$ are the coefficients for the chebyshev polynomials $$T_i$$ yielding $$P = \sum_i{c_i T_i(x)}$$.

If method is ‘interp’ then $$c_i$$ are the values of the interpolated function $$f$$ evaluated at the chebyshev points returned by cheby_points().

bumps.cheby.cheby_approx(n, f, range=(0, 1))[source]

Return the coefficients for the order n chebyshev approximation to function f evaluated over the range [low,high].

bumps.cheby.cheby_val(c, x)[source]

Evaluate the chebyshev approximation c at points x.

The values $$c_i$$ are the coefficients for the chebyshev polynomials $$T_i$$ yielding $$p(x) = \sum_i{c_i T_i(x)}$$.

bumps.cheby.cheby_points(n, range=(0, 1))[source]

Return the points in at which a function must be evaluated to generate the order $$n$$ Chebyshev approximation function.

Over the range [-1,1], the points are $$p_k = \cos(\pi(2 k + 1)/(2n))$$. Adjusting the range to $$[x_L,x_R]$$, the points become $$x_k = \frac{1}{2} (p_k - x_L + 1)/(x_R-x_L)$$.

bumps.cheby.cheby_coeff(fx)[source]

Compute chebyshev coefficients for a polynomial of order n given the function evaluated at the chebyshev points for order n.

This can be used as the basis of a direct interpolation method where the n control points are positioned at cheby_points(n).