Gabriela
Gabriela

Reputation: 67

Integrate numerically a Chebyshev polynomial in Python

I would like to integrate numerically a Chebyshev polynomial in Python

This is what I am using:

p = numpy.polynomial.Chebyshev.basis(5, domain = [0,1], window = [0,1])
coef = p.convert(kind=numpy.polynomial.Polynomial, domain = [0,1], window = [0,1])

I would like to integrate a Chebyshev of order 30 by using the following integral

$I = \int_{-1}^{1} dx T_j(x)$

How can I do it in python? I can't find how I should write my lower and upper limits.

Upvotes: 0

Views: 261

Answers (1)

Jean-Didier
Jean-Didier

Reputation: 1977

Did you try one of the functions in scipy.integrate ?

For example:

>>> import numpy as np
>>> from scipy.integrate import quad
>>> p = np.polynomial.Chebyshev.basis(5, domain = [0,1], window = [0,1])
>>> quad(p,-1,1)
(0.0, 1.3873040010713506e-14)

Upvotes: 2

Related Questions