bundles / scipy 2.0.0.dev0+git20260907.41eeb59 / scipy / special / _orthogonal / roots_chebyc
function
scipy.special._orthogonal:roots_chebyc
source: build-install/usr/lib/python3.14/site-packages/scipy/special/_orthogonal.py:2596
Signature
def roots_chebyc(n, mu = False)Summary
Gauss-Chebyshev (first kind) quadrature.
Extended Summary
Compute 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.6 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_chebyc roots, weights = roots_chebyc(5)✓
roots weights✗
array([1.257, 1.257, 1.257, 1.257, 1.257])Verify that the values in `roots` are roots of the Chebyshev polynomial of first kind :math:`C_5(x)`.
from scipy.special import eval_chebyc
✓eval_chebyc(5, roots)
✗array([ 0., 0., 0., 0., -0.])The values of :math:`C_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 -2 to 2 of :math:`1/\sqrt{1-(x/2)^2}` which evaluates to :math:`2\pi`. There are two ways to obtain the sum of weights, both resulting in :math:`2\pi` within numerical precision.
sum(weights) roots, weights, sum_of_weights = roots_chebyc(5, mu=True) sum_of_weights✓
6.283185307179586Roots and weights obtained from the Chebyshev polynomial of the first kind :math:`C_n(x)` are used in Gauss-Chebyshev quadrature where the integral from -2 to 2 of :math:`f(x)/\sqrt{1-(x/2)^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(37.69911184307751)The exact result is :math:`12\pi`.
from math import pi 12*pi✓
37.69911184307752In general, Gauss-Chebyshev quadrature will only yield an approximate value of the integral. Consider the integral from -2 to 2 of :math:`\cos(x)/\sqrt{1-(x/2)^2}` which evaluates to :math:`2\pi J_0(2)`, 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 2*pi*jv(0, 2)✓
np.float64(1.4067472539132013)
See also
Aliases
scipy.special.c_roots