bundles / scipy latest / scipy / special / _orthogonal / roots_chebyu
function
scipy.special._orthogonal:roots_chebyu
source: build-install/usr/lib/python3.14/site-packages/scipy/special/_orthogonal.py:2388
Signature
def roots_chebyu(n, mu = False)Summary
Gauss-Chebyshev (second 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 second kind, . These sample points and weights correctly integrate polynomials of degree or less over the interval with weight function . See 22.2.5 in [AS] for 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_chebyu roots, weights = roots_chebyu(5)✓
roots weights✗
array([0.1309, 0.3927, 0.5236, 0.3927, 0.1309])Verify that the values in `roots` are roots of the Chebyshev polynomial of second kind :math:`U_5(x)`.
from scipy.special import eval_chebyu
✓eval_chebyu(5, roots)
✗array([-0., -0., 0., -0., 0.])The values of :math:`U_5(x)` evaluated at the roots are indeed very close to zero. Verify that the sum of the weights equals the integral from -1 to 1 of :math:`\sqrt{1-x^2}` which evaluates to :math:`\pi/2`. There are two ways to obtain the sum of weights, both resulting in :math:`\pi/2` within numerical precision.
sum(weights) roots, weights, sum_of_weights = roots_chebyu(5, mu=True) sum_of_weights✓
1.5707963267948966Roots and weights obtained from the Chebyshev polynomial of the second kind :math:`U_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(0.19634954084936204)The exact result is :math:`\pi/16`.
from math import pi pi/16✓
0.19634954084936207In 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_1(1)`, where :math:`J_1` is the Bessel function of first kind and order 1.
import numpy as np
✓weights @ np.cos(roots)
✗np.float64(1.3824596877989563)
from scipy.special import jv pi*jv(1, 1)✓
np.float64(1.3824596873841686)
See also
Aliases
scipy.special.roots_chebyu