archimedes.approximation.FourierBasis¶

class archimedes.approximation.FourierBasis(
n_basis: int,
kind: Literal['full', 'cosine', 'sine'] = 'full',
density: bool = False,
)¶

Trigonometric basis on a periodic interval.

Basis functions are:

\[\{1, \cos(\theta), \sin(\theta), \ldots, \cos(N\theta), \sin(N\theta)\}, \qquad \theta \in [a, b],\]

where \(a\) and \(b\) are identified as the same point (periodic domain).

kind selects which trigonometric family:

  • "full" (default): both sines and cosines; n_basis = 2N + 1 (odd)

  • "cosine": cosines, and the constant term; n_basis = N + 1.

  • "sine": sines only; n_basis = N.

max_mode gives \(N\) uniformly across all three.

Derivatives are closed-form and exact to arbitrary order via the cyclic identity, e.g. \(d^m \cos(k\theta)/dx^m = (k\omega)^m \cos(k\theta + m\pi/2)\) for cosines.

Integrals. "full"/"cosine" both contain the constant basis function, whose antiderivative is a non-periodic linear ramp with no representation in any Fourier-type space, so its antiderivative cannot be represented in the basis. "sine" has no constant term, so its first integral is well-defined, but higher orders raise the same error.

See also

FunctionSpace.fourier

Convenience constructor for a FunctionSpace built from a Fourier basis.

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_basis basis functions at x.

Attributes

Parameters

The target-domain parameters this basis expects.

density

Whether this basis is orthonormal with respect to a probability measure (unit mass) rather than the raw weight of the associated Measure.

kind

"full", "cosine", or "sine".

max_mode

Highest mode number \(N\) present in this basis.

ndim

Number of independent variables the basis functions take.

n_basis

Number of basis functions; constrained by kind.

__init__(
n_basis: int,
kind: Literal['full', 'cosine', 'sine'] = 'full',
density: bool = False,
) → None¶
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 None where 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_basis basis functions at x.

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 Parameters subclass (e.g. UnitInterval.Parameters). Returns the type, not an instance.

Determines which reference domain the basis is defined on, for example:

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 particular OrthogonalPolynomialBasis); other families should leave this False.

kind: Literal['full', 'cosine', 'sine'] = 'full'¶

"full", "cosine", or "sine".

Type:

The type of trigonometric family

property max_mode: int¶

Highest mode number \(N\) present in this basis.

n_basis: int¶

Number of basis functions; constrained by kind.

ndim: int = 1¶

Number of independent variables the basis functions take.

Typically 1, since most bases are univariate. TensorBasis is the exception, with one variable per tensored factor.