archimedes.measure.Measure¶

class archimedes.measure.Measure¶

The weight and reference domain defining an orthogonal polynomial family.

A weight function \(w(x) \geq 0\) together with its support (the reference domain \(\mathcal{D}\)) defines an orthogonality measure \(d\mu(x) = w(x) \, dx\).

The polynomials orthogonal with respect to this measure also determine the nodes of the associated Gauss quadrature rule: for the degree-n orthogonal polynomial, the n roots \(x_i\) and quadrature weights \(w_i\) satisfy

\[\int_\mathcal{D} f(x) \, w(x) \, dx = \sum_{i=1}^n w_i f(x_i)\]

exactly for every polynomial f of degree \(\leq 2n - 1\).

Subclasses implement one classical family each (Legendre, Jacobi, Laguerre, Hermite), pairing a weight with the domain it lives on. The domain – the reference support and the affine map onto other instances of it – is factored out into ReferenceDomain, since several families share one (Legendre and Jacobi are both UnitInterval; both Hermite conventions are RealLine) and since consumers with no weight function at all, such as a nodal Basis, need the domain without the measure.

Methods

affine_params(*args, **kwargs)

Return (scale, shift) mapping the reference measure onto the requested instance of this family; forwarded to domain.affine_params.

mass(*args, **kwargs)

Total mass of the measure mapped by affine_params(*args, **kwargs).

recurrence_coeffs(n)

Monic three-term recurrence coefficients, each shape (n,).

weight(x)

Weight function \(w(x)\), evaluated at x.

Attributes

affine_invariant

True if this measure's weight is provably the same shape, just relocated/rescaled, under affine_params's reparametrization.

reference_mass

Zeroth moment \(\int_\mathcal{D} w(t) ~ dt\) of the reference weight.

support

Support \(\mathcal{D} = [a, b]\); forwarded from domain.

uniform_weight

True if the weight is constant (weight(x) == weight(y)) for every x, y in support -- e.g. true for Legendre, false for Jacobi (singular at the endpoints) or Hermite/Laguerre (unbounded support).

domain

The reference domain this measure's weight is supported on.

__init__()¶
affine_params(*args, **kwargs) → tuple[float, float]¶

Return (scale, shift) mapping the reference measure onto the requested instance of this family; forwarded to domain.affine_params.

Quadrature weights pick up the same scale as a Jacobian factor, since \(dx = \mathrm{scale} \cdot dt\). The meaning of the arguments is domain-specific – a/b for UnitInterval, loc/scale for RealLine, rate/start for HalfLine – see the corresponding ReferenceDomain subclass.

mass(*args, **kwargs) → float¶

Total mass of the measure mapped by affine_params(*args, **kwargs).

Equal to scale * reference_mass, where scale is the affine scale factor. Dividing a mapped weight by this quantity turns it into a probability density on the mapped domain. Concrete subclasses don’t need to override this; it’s fully determined by affine_params and reference_mass.

recurrence_coeffs(n: int) → tuple[ndarray, ndarray]¶

Monic three-term recurrence coefficients, each shape (n,).

The monic polynomials orthogonal with respect to this (reference) measure satisfy

\[\pi_{k+1}(x) = (x - \alpha_k) \, \pi_k(x) - \beta_k \, \pi_{k-1}(x), \qquad k = 0, \ldots, n-1,\]

with \(\pi_{-1} = 0\), \(\pi_0 = 1\). beta[0] plays no role in the recursion itself (since \(\pi_{-1} = 0\)) and is instead defined as reference_mass (see there for how it’s obtained by default) – the normalization Gauss quadrature (e.g. the Golub-Welsch algorithm) needs to recover quadrature weights from these coefficients.

Only reference-instance coefficients are provided; a mapped instance’s coefficients follow from affine_params (alpha' = scale * alpha + shift, beta' = scale**2 * beta with beta'[0] = mass(...)), which callers can apply themselves.

The default implementation falls back to a discretized Stieltjes procedure (stieltjes_recurrence()), which numerically integrates the required moments via scipy.integrate.quad instead of a closed form. Classical families override this method with a closed-form recursion for speed and much better high-degree accuracy.

Parameters:

n (int) – Number of coefficients to compute, i.e. degrees 0, ..., n-1. Must be >= 1; not validated here.

abstractmethod weight(x: ndarray) → ndarray¶

Weight function \(w(x)\), evaluated at x.

affine_invariant: bool = False¶

True if this measure’s weight is provably the same shape, just relocated/rescaled, under affine_params’s reparametrization. False (the default) for anything relying on the generic Stieltjes-based recurrence_coeffs fallback, since it is not guaranteed that an arbitrary weight family stays affine-closed.

domain: ReferenceDomain¶

The reference domain this measure’s weight is supported on. Set as a class attribute by each concrete subclass; carries the support, affine_params and Parameters that Measure delegates to.

property reference_mass: float¶

Zeroth moment \(\int_\mathcal{D} w(t) ~ dt\) of the reference weight.

Since affine_params only ever rescales/shifts the reference domain, the zeroth moment of the mapped weight is always scale * reference_mass, with no dependence on shift. This is the normalizing constant that turns the (raw) weight into a probability density, weight(x) / reference_mass. See also mass, which generalizes this to a mapped instance.

The default implementation numerically integrates weight over support via scipy.integrate.quad(), so (together with the default recurrence_coeffs()) a custom Measure subclass needs only weight and domain to be fully usable.

property support: tuple[float, float]¶

Support \(\mathcal{D} = [a, b]\); forwarded from domain.

uniform_weight: bool = False¶

True if the weight is constant (weight(x) == weight(y)) for every x, y in support – e.g. true for Legendre, false for Jacobi (singular at the endpoints) or Hermite/Laguerre (unbounded support). Used by consumers that need to know whether the weight’s shape is trivial, e.g. archimedes.quadrature.composite_quad, which can only tile a rule across sub-elements when there’s no interior discontinuity in the weight to worry about.