{ } Raw JSON

bundles / scipy latest / scipy / special / _orthogonal / gegenbauer

function

scipy.special._orthogonal:gegenbauer

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

Signature

def   gegenbauer ( n alpha monic = False )

Summary

Gegenbauer (ultraspherical) polynomial.

Extended Summary

Defined to be the solution of

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 over with 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
p(1)
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("G_3(x)")
plt.show()
fig-1b4fd1734d874e60.png

Aliases

  • scipy.special.gegenbauer