omnibias.core.verified.spectral
Coefficient recurrences, activation contracts, jet algebra, and verified arithmetic shared by the numerical backends.
import omnibias.core.verified.spectralModule 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_circulantbuilds the discrete periodic Hilbert transform onNequispaced nodes as a *verified* circulantIntervalmatrix. 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 reproducesH cos(kx) = sin(kx),H sin(kx) = -cos(kx)for the resolved modes1 <= k < N/2.cos_matrix/sin_matrixbuild verified trig design matricesC[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.
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
| Name | Type & default | Contract |
|---|---|---|
x_nodespositional-or-keyword | Sequence[float]Required | See the operation contract and implementation below. |
k_valuespositional-or-keyword | Sequence[float]Required | See the operation contract and implementation below. |
list[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-12python -m pytest "packages/omnibias-core/tests/verified/test_spectral.py::test_design_matrices_enclose_truth" -qRead 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_matrixomnibias.core.verified.spectral.cos_matrix
hilbert_circulant
omnibias.core.verified.hilbert_circulantSource ↗hilbert_circulant(n: int) -> list[list[Interval]]Verified n x n discrete periodic Hilbert-transform matrix.
Parameters
| Name | Type & default | Contract |
|---|---|---|
npositional-or-keyword | intRequired | See the operation contract and implementation below. |
list[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" -qRegression 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-12python -m pytest packages/omnibias-core/tests/verified/test_spectral.py -k test_hilbert_kills_constant -qRead 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_circulantomnibias.core.verified.spectral.hilbert_circulant
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
| Name | Type & default | Contract |
|---|---|---|
x_nodespositional-or-keyword | Sequence[float]Required | See the operation contract and implementation below. |
k_valuespositional-or-keyword | Sequence[float]Required | See the operation contract and implementation below. |
list[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-12python -m pytest "packages/omnibias-core/tests/verified/test_spectral.py::test_design_matrices_enclose_truth" -qRead 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_matrixomnibias.core.verified.spectral.sin_matrix
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
| Name | Type & default | Contract |
|---|---|---|
npositional-or-keyword | intRequired | See the operation contract and implementation below. |
periodpositional-or-keyword | floatDefault: 2.0 * math.pi | See the operation contract and implementation below. |
list[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-12python -m pytest "packages/omnibias-core/tests/verified/test_spectral.py::test_design_matrices_enclose_truth" -qRegression 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)) < tolpython -m pytest packages/omnibias-core/tests/verified/test_spectral.py -k test_hilbert_mode_action_approx -qRead 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_nodesomnibias.core.verified.spectral.uniform_nodes