archimedes.approximation.OrthogonalPolynomialBasis¶
- class archimedes.approximation.OrthogonalPolynomialBasis(
- measure: Measure,
- n_basis: int,
- density: bool = False,
A classical orthonormal polynomial basis
Orthonormal polynomials \(\{p_0, p_1, \ldots, p_{n-1}\}\), constructed to be orthonormal with respect to a given measure (reference domain and inner product weight).
The monic polynomials orthogonal w.r.t. any
Measuresatisfy the three-term recurrence\[\pi_{k+1}(x) = (x - \alpha_k) \, \pi_k(x) - \beta_k \, \pi_{k-1}(x)\]which holds for any classical orthogonal polynomial family. The squared norm for the associated weight function \(w(x)\) is \(\int \pi_k^2 \, w \, dx = \beta_0 \beta_1 \cdots \beta_k\).
The basis functions are additionally normalized with \(p_k = \pi_k / \sqrt{\beta_0 \cdots \beta_k}\) for conditioning at high polynomial degree.
Supported measures include:
JacobiMeasure(also Chebyshev as a special case)
However, customized measures may be constructed by defining a domain and weight function, with recursions computed automatically using the discretized Stieltjes procedure. See the [documentation on quadrature](handbook/quadrature) for details.
An orthogonal polynomial basis can be constructed from any such custom measure, with the basis functions defined automatically via the three-term recurrence.
Methods
boundary_dofs([order])Indices of the degrees of freedom at the left/right ends of the domain.
evaluate(x[, deriv, side])Evaluate all
n_basisbasis functions atx.Attributes
The target-domain parameters this basis expects.
Whether this basis is orthonormal with respect to a probability measure (unit mass) rather than the raw weight of the associated
Measure.Number of independent variables the basis functions take.
Defines the orthogonality weight and reference domain.
Number of basis functions in this basis.
- boundary_dofs(order: int = 0) tuple[int | None, int | None]¶
Indices of the degrees of freedom at the left/right ends of the domain.
Can be used for example to set boundary conditions or enforce continuity at the domain endpoints.
- Parameters:
order (int, optional) – Derivative order to look up. Default 0 (the endpoint value).
- Returns:
left, right – Index into this basis’s functions, or
Nonewhere there is no degree of freedom of that order at that end.- Return type:
int or None
Notes
Only meaningful for nodal families (e.g.
LagrangeBasis) with nodes at the endpoints. Modal families (e.g.OrthogonalPolynomialBasis) and nodal bases with interior-only nodes (Gauss-Legendre points, for instance) do not have boundary DOFs.
- evaluate(
- x,
- deriv: int = 0,
- *,
- side: str = RIGHT,
- **domain_kwargs,
Evaluate all
n_basisbasis functions atx.- Parameters:
x (array_like) – Evaluation points, shape
(npts,).deriv (int, optional) – Order of derivative to evaluate. Default 0.
side ({"right", "left"}, optional) – Which one-sided limit to take where the basis is two-valued. Default
"right". Irrelevant for smooth bases.**domain_kwargs – Target-domain parameters; see the subclass docstring.
- Returns:
phi – Basis values (or
deriv-th derivatives), shape(npts, n_basis).- Return type:
ndarray
- property Parameters: type¶
The target-domain parameters this basis expects.
A
Parameterssubclass (e.g.UnitInterval.Parameters). Returns the type, not an instance.Determines which reference domain the basis is defined on, for example:
UnitIntervalfor \([-1, 1]\).HalfLinefor \([0, \infty)\).RealLinefor \((-\infty, \infty)\).
- density: bool = False¶
Whether this basis is orthonormal with respect to a probability measure (unit mass) rather than the raw weight of the associated
Measure.Only meaningful for orthogonal polynomial families based on a
Measure(in particularOrthogonalPolynomialBasis); other families should leave thisFalse.
- n_basis: int¶
Number of basis functions in this basis.
- ndim: int = 1¶
Number of independent variables the basis functions take.
Typically 1, since most bases are univariate.
TensorBasisis the exception, with one variable per tensored factor.