bundles / scipy 2.0.0.dev0+git20260907.41eeb59 / scipy / special / _orthogonal / roots_chebyt
function
scipy.special._orthogonal:roots_chebyt
source: build-install/usr/lib/python3.14/site-packages/scipy/special/_orthogonal.py:2168
Signature
def roots_chebyt(n, mu = False)Summary
Gauss-Chebyshev (first kind) quadrature.
Extended Summary
Computes the sample points and weights for Gauss-Chebyshev quadrature. The sample points are the roots of the nth degree Chebyshev polynomial of the first kind, . These sample points and weights correctly integrate polynomials of degree or less over the interval with weight function . See 22.2.4 in [AS] for more details.
Parameters
n: intquadrature order
mu: bool, optionalIf True, return the sum of the weights, optional.
Returns
x: ndarraySample points
w: ndarrayWeights
mu: floatSum of the weights
Examples
from scipy.special import roots_chebyt roots, weights = roots_chebyt(5)✓
roots weights✗
array([0.62832, 0.62832, 0.62832, 0.62832, 0.62832])Verify that the values in `roots` are roots of the Chebyshev polynomial of first kind :math:`T_5(x)`.
from scipy.special import eval_chebyt
✓eval_chebyt(5, roots)
✗array([ 0., 0., 0., 0., -0.])The values of :math:`T_5(x)` evaluated at the roots are indeed zero or very close to it. Verify that the sum of the weights equals the integral from -1 to 1 of :math:`1/\sqrt{1-x^2}` which evaluates to :math:`\pi`. There are two ways to obtain the sum of weights, both resulting in :math:`\pi` within numerical precision.
sum(weights) roots, weights, sum_of_weights = roots_chebyt(5, mu=True) sum_of_weights✓
3.141592653589793Roots and weights obtained from the Chebyshev polynomial of the first kind :math:`T_n(x)` are used in Gauss-Chebyshev quadrature where the integral from -1 to 1 of :math:`f(x)/\sqrt{1-x^2}` is evaluated. Roots and weights for order :math:`n` are expected to yield the exact result for polynomials :math:`f(x)` of a maximal order of :math:`2n-1`.
f = lambda x: x**4
✓weights @ f(roots)
✗np.float64(1.1780972450961722)The exact result is :math:`3\pi/8`.
from math import pi 3*pi/8✓
1.1780972450961724In general, Gauss-Chebyshev quadrature will only yield an approximate value of the integral. Consider the integral from -1 to 1 of :math:`\cos(x)/\sqrt{1-x^2}` which evaluates to :math:`\pi J_0(1)`, where :math:`J_0` is the Bessel function of first kind and order 0.
import numpy as np weights @ np.cos(roots) from scipy.special import jv pi*jv(0, 1)✓
np.float64(2.4039394306344133)
See also
- numpy.polynomial.chebyshev.chebgauss
- scipy.integrate.fixed_quad
Aliases
scipy.special.roots_chebyt