scipy.special.eval_sh_legendre#

scipy.special.eval_sh_legendre(n, x, out=None) = <ufunc 'eval_sh_legendre'>#

Evaluate shifted Legendre polynomial at a point.

These polynomials are defined as

\[P_n^*(x) = P_n(2x - 1)\]

where \(P_n\) is a Legendre polynomial. See 22.2.11 in [AS] or [DLMF] for details.

Parameters:
narray_like

Degree of the polynomial. If not an integer, the value is determined via the relation to eval_legendre.

xarray_like

Points at which to evaluate the shifted Legendre polynomial

outndarray, optional

Optional output array for the function values

Returns:
Pscalar or ndarray

Values of the shifted Legendre polynomial

See also

roots_sh_legendre

roots and quadrature weights of shifted Legendre polynomials

sh_legendre

shifted Legendre polynomial object

eval_legendre

evaluate Legendre polynomials

numpy.polynomial.legendre.Legendre

Legendre series

References

[AS]

Milton Abramowitz and Irene A. Stegun, eds. Handbook of Mathematical Functions with Formulas, Graphs, and Mathematical Tables. New York: Dover, 1972.

[DLMF]

NIST Digital Library of Mathematical Functions, https://dlmf.nist.gov/18.7.E10

Examples

>>> import numpy as np
>>> from scipy.special import eval_sh_legendre
>>> import matplotlib.pyplot as plt

Evaluate the order 3 polynomial at a few values of x.

>>> eval_sh_legendre(3, [0, 0.25, 0.5])
array([-1.    ,  0.4375,  0.    ])

Plot the polynomials of order 0 through 4.

>>> x = np.linspace(0, 1, 800)
>>> fig, ax = plt.subplots(1, 1, constrained_layout=True)
>>> for n in range(5):
...     y = eval_sh_legendre(n, x)
...     ax.plot(x, y, label=f'{n = }')
>>> ax.grid()
>>> ax.set_title("Shifted Legendre Polynomials")
>>> ax.set_xlabel("$x$")
>>> ax.set_ylabel("$P_n^*(x)$")
>>> ax.legend(loc='upper left', bbox_to_anchor=(1, 1), shadow=True)
>>> plt.show()
../../_images/scipy-special-eval_sh_legendre-1.png