numpy.polynomial.chebyshev.chebinterpolate¶

numpy.polynomial.chebyshev.
chebinterpolate
(func, deg, args=())[source]¶ Interpolate a function at the Chebyshev points of the first kind.
Returns the Chebyshev series that interpolates func at the Chebyshev points of the first kind in the interval [1, 1]. The interpolating series tends to a minmax approximation to func with increasing deg if the function is continuous in the interval.
New in version 1.14.0.
 Parameters
 funcfunction
The function to be approximated. It must be a function of a single variable of the form
f(x, a, b, c...)
, wherea, b, c...
are extra arguments passed in the args parameter. degint
Degree of the interpolating polynomial
 argstuple, optional
Extra arguments to be used in the function call. Default is no extra arguments.
 Returns
 coefndarray, shape (deg + 1,)
Chebyshev coefficients of the interpolating series ordered from low to high.
Notes
The Chebyshev polynomials used in the interpolation are orthogonal when sampled at the Chebyshev points of the first kind. If it is desired to constrain some of the coefficients they can simply be set to the desired value after the interpolation, no new interpolation or fit is needed. This is especially useful if it is known apriori that some of coefficients are zero. For instance, if the function is even then the coefficients of the terms of odd degree in the result can be set to zero.
Examples
>>> import numpy.polynomial.chebyshev as C >>> C.chebfromfunction(lambda x: np.tanh(x) + 0.5, 8) array([ 5.00000000e01, 8.11675684e01, 9.86864911e17, 5.42457905e02, 2.71387850e16, 4.51658839e03, 2.46716228e17, 3.79694221e04, 3.26899002e16])