scipy.special.

lqn#

scipy.special.lqn(n, z)[source]#

Legendre functions of the second kind.

Compute sequence of Legendre functions of the second kind, Qn(z) and derivatives for all degrees from 0 to n (inclusive). Returns two arrays of size (n+1,) + z.shape containing Qn(z) and Qn'(z).

Parameters:
nint

Maximum degree of the Legendre functions.

zarray_like, complex

Real or complex input values.

Returns:
Qn_zndarray, shape (n+1,) + shape(z)

Values for all degrees 0..n

Qn_d_zndarray, shape (n+1,) + shape(z)

Derivatives for all degrees 0..n

References

[1]

Zhang, Shanjie and Jin, Jianming. “Computation of Special Functions”, John Wiley and Sons, 1996. https://people.sc.fsu.edu/~jburkardt/f77_src/special_functions/special_functions.html

Examples

Compute \(Q_n(x)\) and its derivatives on an interval.

>>> import numpy as np
>>> from scipy.special import lqn
>>> import matplotlib.pyplot as plt
>>> xs = np.linspace(-2, 2, 200)
>>> n_max = 3
>>> Qn, dQn = lqn(n_max, xs)

Plot the Legendre functions of the second kind \(Q_n(x)\).

>>> fig, ax = plt.subplots()
>>> ax.plot(xs, Qn.T, "-")
>>> ax.set_xlabel(r"$x$")
>>> ax.set_ylabel(r"$Q_n(x)$")
>>> ax.legend([fr"$n={n}$" for n in range(n_max + 1)])
>>> plt.show()
../../_images/scipy-special-lqn-1_00_00.png

Plot the derivatives \(Q_n'(x)\).

>>> fig, ax = plt.subplots()
>>> ax.plot(xs, dQn.T, "-")
>>> ax.set_xlabel(r"$x$")
>>> ax.set_ylabel(r"$Q_n'(x)$")
>>> ax.legend([fr"$n={n}$" for n in range(n_max + 1)])
>>> plt.show()
../../_images/scipy-special-lqn-1_01_00.png