Skip to main content

roots_gegenbauer

Function roots_gegenbauer 

Source
pub fn roots_gegenbauer(n: usize, alpha: f64) -> (Vec<f64>, Vec<f64>)
Expand description

Gauss-Gegenbauer quadrature

Corresponds to scipy.special.roots_gegenbauer.

The nodes are the roots of the Gegenbauer polynomial $C_n^{(\alpha)}$, and the rule is exact for polynomials of degree $2n - 1$ with the weight function $(1 - x^2)^{\alpha - 1/2}$ on $[-1, 1]$ (A&S 22.2.3). For $\alpha = 0$, these are the roots of $T_n$, see roots_chebyshev_t.

The weights are NaN if $C_n^{(\alpha)}$ overflows at all nodes, e.g. for $n = 150$ and $\alpha = 10^4$ (also in SciPy). Near $\alpha = -1/2$, they lose accuracy (also in SciPy): for odd $n$, the relative error is about $n \cdot 10^{-16} / (\alpha + 1/2)$, and within about $10^{-15}$ of $-1/2$, some can be NaN. roots_jacobi with $\alpha - 1/2$ for both parameters doesn’t have this problem.

§Panics

  • if n is zero
  • if $\alpha \le -1/2$

§See also