{ } Raw JSON

bundles / scipy 1.18.0 / scipy / special / _orthogonal / gegenbauer

function

scipy.special._orthogonal:gegenbauer

source: /scipy/special/_orthogonal.py:1629

Signature

def gegenbauer(n, alpha, monic = False)

Summary

Gegenbauer (ultraspherical) polynomial.

Extended Summary

Defined to be the solution of the second-order linear ordinary differential equation

for ; is a polynomial of degree .

Parameters

n : int

Degree of the polynomial.

alpha : float

Parameter, must be greater than -0.5.

monic : bool, optional

If True, scale the leading coefficient to be 1. Default is False.

Returns

C : orthopoly1d

Gegenbauer polynomial.

Notes

The polynomials are orthogonal on with respect to the weight function .

Examples

import numpy as np
from scipy import special
import matplotlib.pyplot as plt
✓
We can initialize a variable ``p`` as a Gegenbauer polynomial using the `gegenbauer` function and evaluate at a point ``x = 1``.
p = special.gegenbauer(3, 0.5, monic=False)
p
✓
poly1d([ 2.5,  0. , -1.5,  0. ])
p(1)
✗
np.float64(1.0)
To evaluate ``p`` at various points ``x`` in the interval ``(-3, 3)``, simply pass an array ``x`` to ``p`` as follows:
x = np.linspace(-3, 3, 400)
y = p(x)
✓
We can then visualize ``x, y`` using `matplotlib.pyplot`.
fig, ax = plt.subplots()
✓
ax.plot(x, y)
ax.set_title("Gegenbauer (ultraspherical) polynomial of degree 3")
ax.set_xlabel("x")
ax.set_ylabel(r"$C_3^{(0.5)}(x)$")
✗
Text(0, 0.5, '$C_3^{(0.5)}(x)$')
plt.show()
✓
fig-b396f6b98a64c968.png

Aliases

  • scipy.special.gegenbauer