Skip to main content

omnibias.core.verified.spectral

0.5.0rc1Release candidatePython >=3.10Apache-2.0

Coefficient recurrences, activation contracts, jet algebra, and verified arithmetic shared by the numerical backends.

import omnibias.core.verified.spectral
Module contract & mathematical conventions

Verified periodic spectral operators -- the nonlocal ingredient.

Boundary / Euler-type blow-up models (De Gregorio, Hou-Luo, Boussinesq) are driven by a **nonlocal** operator: the Hilbert transform / Biot-Savart law. This module supplies it rigorously.

  • hilbert_circulant builds the discrete periodic Hilbert transform on N equispaced nodes as a *verified* circulant Interval matrix. Its entries come from the spectral multiplier -i sgn(k) summed in high precision and rounded outward, so applying it to an interval vector is theorem-grade. On the grid it reproduces H cos(kx) = sin(kx), H sin(kx) = -cos(kx) for the resolved modes 1 <= k < N/2.
  • cos_matrix / sin_matrix build verified trig design matrices C[j,i] = cos(k_i x_j) / S[j,i] = sin(k_i x_j) for collocation in a Fourier basis (the basis in which the periodic Hilbert transform acts exactly).

The kernel sums use mpmath when available (the high-precision backend named in the certified-evidence contract) and fall back to ulp-inflated libm otherwise.

Shared formulas do not imply universal floating-point identity. Verify dtype, shape, derivative-order support, and the stated numerical assumptions for the path you use.

FUNCTION

cos_matrix​

omnibias.core.verified.cos_matrixSource ↗
cos_matrix(x_nodes: Sequence[float], k_values: Sequence[float]) -> list[list[Interval]]

Verified C[j,i] = cos(k_i * x_j).

Parameters

NameType & defaultContract
x_nodespositional-or-keywordSequence[float]RequiredSee the operation contract and implementation below.
k_valuespositional-or-keywordSequence[float]RequiredSee the operation contract and implementation below.
Returnslist[list[Interval]]
Executed regression · design matrices enclose truth

Recorded coverage confirms this test executed the API body. This example belongs to the pinned upstream test suite. It may use fixtures and imports from its full file. Run it from that checkout with its test dependencies installed.

def test_design_matrices_enclose_truth() -> None:
    nodes = uniform_nodes(8)
    ks = [1.0, 2.0, 3.0]
    cmat = cos_matrix(nodes, ks)
    smat = sin_matrix(nodes, ks)
    for j, x in enumerate(nodes):
        for i, k in enumerate(ks):
            assert cmat[j][i].contains(math.cos(k * x))
            assert smat[j][i].contains(math.sin(k * x))
            assert cmat[j][i].width < 1e-12
            assert smat[j][i].width < 1e-12
python -m pytest "packages/omnibias-core/tests/verified/test_spectral.py::test_design_matrices_enclose_truth" -q
Read the implementation
def cos_matrix(x_nodes: Sequence[float], k_values: Sequence[float]) -> list[list[Interval]]:
    """Verified ``C[j,i] = cos(k_i * x_j)``."""
    return [[cos_point(float(k) * float(x)) for k in k_values] for x in x_nodes]
Other public import paths
  • omnibias.core.verified.cos_matrix
  • omnibias.core.verified.spectral.cos_matrix
FUNCTION

hilbert_circulant​

omnibias.core.verified.hilbert_circulantSource ↗
hilbert_circulant(n: int) -> list[list[Interval]]

Verified n x n discrete periodic Hilbert-transform matrix.

Parameters

NameType & defaultContract
npositional-or-keywordintRequiredSee the operation contract and implementation below.
Returnslist[list[Interval]]
Executed regression · hilbert requires even grid

Recorded coverage confirms this test executed the API body. This example belongs to the pinned upstream test suite. It may use fixtures and imports from its full file. Run it from that checkout with its test dependencies installed.

def test_hilbert_requires_even_grid() -> None:
    with pytest.raises(ValueError):
        hilbert_circulant(7)
python -m pytest "packages/omnibias-core/tests/verified/test_spectral.py::test_hilbert_requires_even_grid" -q
Regression example · hilbert kills constant

This example belongs to the pinned upstream test suite. It may use fixtures and imports from its full file. Run it from that checkout with its test dependencies installed.

def test_hilbert_kills_constant() -> None:
    n = 16
    hmat = hilbert_circulant(n)
    ones = [Interval.point(1.0) for _ in range(n)]
    out = matvec(hmat, ones)
    for v in out:
        assert v.contains(0.0)
        assert abs(v.lo) < 1e-12 and abs(v.hi) < 1e-12
python -m pytest packages/omnibias-core/tests/verified/test_spectral.py -k test_hilbert_kills_constant -q
Read the implementation
def hilbert_circulant(n: int) -> list[list[Interval]]:
    """Verified ``n x n`` discrete periodic Hilbert-transform matrix."""
    kernel = _hilbert_kernel(n)
    return [[kernel[(j - col) % n] for col in range(n)] for j in range(n)]
Other public import paths
  • omnibias.core.verified.hilbert_circulant
  • omnibias.core.verified.spectral.hilbert_circulant
FUNCTION

sin_matrix​

omnibias.core.verified.sin_matrixSource ↗
sin_matrix(x_nodes: Sequence[float], k_values: Sequence[float]) -> list[list[Interval]]

Verified S[j,i] = sin(k_i * x_j).

Parameters

NameType & defaultContract
x_nodespositional-or-keywordSequence[float]RequiredSee the operation contract and implementation below.
k_valuespositional-or-keywordSequence[float]RequiredSee the operation contract and implementation below.
Returnslist[list[Interval]]
Executed regression · design matrices enclose truth

Recorded coverage confirms this test executed the API body. This example belongs to the pinned upstream test suite. It may use fixtures and imports from its full file. Run it from that checkout with its test dependencies installed.

def test_design_matrices_enclose_truth() -> None:
    nodes = uniform_nodes(8)
    ks = [1.0, 2.0, 3.0]
    cmat = cos_matrix(nodes, ks)
    smat = sin_matrix(nodes, ks)
    for j, x in enumerate(nodes):
        for i, k in enumerate(ks):
            assert cmat[j][i].contains(math.cos(k * x))
            assert smat[j][i].contains(math.sin(k * x))
            assert cmat[j][i].width < 1e-12
            assert smat[j][i].width < 1e-12
python -m pytest "packages/omnibias-core/tests/verified/test_spectral.py::test_design_matrices_enclose_truth" -q
Read the implementation
def sin_matrix(x_nodes: Sequence[float], k_values: Sequence[float]) -> list[list[Interval]]:
    """Verified ``S[j,i] = sin(k_i * x_j)``."""
    return [[sin_point(float(k) * float(x)) for k in k_values] for x in x_nodes]
Other public import paths
  • omnibias.core.verified.sin_matrix
  • omnibias.core.verified.spectral.sin_matrix
FUNCTION

uniform_nodes​

omnibias.core.verified.uniform_nodesSource ↗
uniform_nodes(n: int, period: float=2.0 * math.pi) -> list[float]

n equispaced nodes on [0, period).

Parameters

NameType & defaultContract
npositional-or-keywordintRequiredSee the operation contract and implementation below.
periodpositional-or-keywordfloatDefault: 2.0 * math.piSee the operation contract and implementation below.
Returnslist[float]
Executed regression · design matrices enclose truth

Recorded coverage confirms this test executed the API body. This example belongs to the pinned upstream test suite. It may use fixtures and imports from its full file. Run it from that checkout with its test dependencies installed.

def test_design_matrices_enclose_truth() -> None:
    nodes = uniform_nodes(8)
    ks = [1.0, 2.0, 3.0]
    cmat = cos_matrix(nodes, ks)
    smat = sin_matrix(nodes, ks)
    for j, x in enumerate(nodes):
        for i, k in enumerate(ks):
            assert cmat[j][i].contains(math.cos(k * x))
            assert smat[j][i].contains(math.sin(k * x))
            assert cmat[j][i].width < 1e-12
            assert smat[j][i].width < 1e-12
python -m pytest "packages/omnibias-core/tests/verified/test_spectral.py::test_design_matrices_enclose_truth" -q
Regression example · hilbert mode action approx

This example belongs to the pinned upstream test suite. It may use fixtures and imports from its full file. Run it from that checkout with its test dependencies installed.

def test_hilbert_mode_action_approx(n: int) -> None:
    """Sanity: H cos(kx)~sin(kx), H sin(kx)~-cos(kx) to O(n*ulp)."""
    nodes = uniform_nodes(n)
    hmat = hilbert_circulant(n)
    tol = 50 * n * 2.3e-16
    for k in range(1, n // 2):
        hc = matvec(hmat, [cos_point(k * x) for x in nodes])
        hs = matvec(hmat, [sin_point(k * x) for x in nodes])
        for j, x in enumerate(nodes):
            assert abs(hc[j].mid - math.sin(k * x)) < tol
            assert abs(hs[j].mid + math.cos(k * x)) < tol
python -m pytest packages/omnibias-core/tests/verified/test_spectral.py -k test_hilbert_mode_action_approx -q
Read the implementation
def uniform_nodes(n: int, period: float = 2.0 * math.pi) -> list[float]:
    """``n`` equispaced nodes on ``[0, period)``."""
    return [period * j / n for j in range(n)]
Other public import paths
  • omnibias.core.verified.uniform_nodes
  • omnibias.core.verified.spectral.uniform_nodes