scipy.special.
sh_jacobi#
- scipy.special.sh_jacobi(n, p, q, monic=False)[source]#
Shifted Jacobi polynomial.
Defined by
\[G_n^{(p, q)}(x) = \binom{2n + p - 1}{n}^{-1}P_n^{(p - q, q - 1)}(2x - 1),\]where \(P_n^{(\cdot, \cdot)}\) is the nth Jacobi polynomial.
- Parameters:
- nint
Degree of the polynomial.
- pfloat
Parameter, must have \(p > q - 1\).
- qfloat
Parameter, must be greater than 0.
- monicbool, optional
If True, scale the leading coefficient to be 1. Default is False.
- Returns:
- Gorthopoly1d
Shifted Jacobi polynomial.
Notes
For fixed \(p, q\), the polynomials \(G_n^{(p, q)}\) are orthogonal over \([0, 1]\) with weight function \((1 - x)^{p - q}x^{q - 1}\).
Examples
Evaluate the shifted Jacobi polynomial \(G_3^{(2, 1)}\) at \(x = 0.5\):
>>> import numpy as np >>> from scipy.special import binom, jacobi, sh_jacobi >>> np.isclose(sh_jacobi(3, 2, 1)(0.5), -3/280) True
The polynomial is related to the Jacobi polynomial \(P_n^{(p - q, q - 1)}\):
>>> x = np.linspace(0, 1, 5) >>> n, p, q = 3, 2, 1 >>> scale = 1 / binom(2*n + p - 1, n) >>> np.allclose(sh_jacobi(n, p, q)(x), ... scale * jacobi(n, p - q, q - 1)(2*x - 1)) True
Plot \(G_3^{(p, 1)}\) for several values of \(p\):
>>> import matplotlib.pyplot as plt >>> x = np.linspace(0, 1, 400) >>> fig, ax = plt.subplots() >>> for p in [1, 2, 3]: ... ax.plot(x, sh_jacobi(3, p, 1)(x), label=rf"$p={p}$") >>> ax.set_title(r"Shifted Jacobi polynomials $G_3^{(p, 1)}$") >>> ax.set_xlabel("x") >>> ax.legend(loc="best") >>> plt.show()