Skip to content

Legendre polynomials

legendre

Legendre polynomials.

This module provides functions to evaluate the orthogonal Legendre polynomials on \([-1, 1]^d\) using tensorized basis functions.

Functions:

Name Description
legval

Evaluates Legendre polynomials up to degree \(n\).

evaluate_basis

Evaluates a tensorized Legendre basis.

multichaos.legendre.legval

legval(n: int, sample: np.ndarray) -> np.ndarray

Evaluates Legendre polynomials up to degree \(n\).

This evaluates the Legendre polynomials \(P_0, \ldots, P_n\) up to degree \(n \in \mathbb{N}_0\) in the given sample. The polynomials are orthonormalized with respect to the uniform weighting on \([-1, 1]\), such that

\[ \begin{equation} \int_{-1}^1 P_i(x) P_j(x) \, \frac{dx}{2} = \delta_{ij}. \end{equation} \]

Parameters:

Name Type Description Default
n int

Number of polynomials to evaluate.

required
sample np.ndarray

Sample points with shape (n_samples,).

required

Returns:

Type Description
np.ndarray

Evaluations of shape (n_samples, n + 1).

multichaos.legendre.evaluate_basis

evaluate_basis(index_set: np.ndarray, sample: np.ndarray) -> np.ndarray

Evaluates a tensorized Legendre basis.

Evaluates the tensorized Legendre basis defined by the index set on the given sample. For an index \(\lambda \in \Lambda\) for some multi-index set \(\Lambda \subset \mathbb{N}_0^d\), the corresponding basis function is given by

\[ \begin{equation} P_\lambda (x) := \prod_{j=1}^d P_{\lambda_j} (x_j), \quad \text{for} \quad x \in [-1, 1]^d, \end{equation} \]

where \(P_n\) denotes the \(n\)-th univariate Legendre polynomial.

Parameters:

Name Type Description Default
index_set np.ndarray

Index set \(\Lambda\) of shape (n_basis, d).

required
sample np.ndarray

Sample points with shape (n_samples, d).

required

Returns:

Type Description
np.ndarray

Evaluations of the basis on the sample with shape (n_samples, n_basis).