boundlab.polysp.legendre.Tanh#

class boundlab.polysp.legendre.Tanh[source]#

Bases: LegendreHandler

Placeholder for a Legendre tanh relaxation (not yet implemented).

Methods

__init__

approx_lbub

Elementwise range of the residual fn - p over [c - hw, c + hw].

condition

Whether this handler applies to these operands (default: always).

fn

The scalar function being approximated (elementwise, differentiable).

handle

Transform the operands; sub-operations go through interp.<op> so the enclosing domain's handlers apply to them too.

legendre_coeffs

Compute the Legendre coefficients for center c and half-width hw.

optimized_polynomial

Legendre coefficients plus a sound symmetric bound on the residual.

override_handler

A copy of this handler that takes precedence over other when both are ready for the same call.

quartic_bound

Elementwise bound on |fn''''| over [lb, ub] (for spline3_ibp).

approx_lbub(polyc, c, hw)#

Elementwise range of the residual fn - p over [c - hw, c + hw].

The interpolant p has degree <= 3, so the residual’s fourth derivative is fn'''' and quartic_bound applies unchanged.

condition(*args, **kwargs)#

Whether this handler applies to these operands (default: always).

abstractmethod fn(x)#

The scalar function being approximated (elementwise, differentiable).

handle(interp, x, **kwargs)#

Transform the operands; sub-operations go through interp.<op> so the enclosing domain’s handlers apply to them too.

abstractmethod legendre_coeffs(c, hw, **kwargs)#

Compute the Legendre coefficients for center c and half-width hw.

\[l_i = \frac{2i+1}{2 a^i} \int_{-1}^{1} P_i(x) f(a x + b) dx\]

with a = hw, b = c, so that f(x) \approx \sum_i l_i a^i P_i((x - b) / a). Must be finite for a == 0 (where l_i tends to the Taylor limit).

optimized_polynomial(c, hw, **kwargs)#

Legendre coefficients plus a sound symmetric bound on the residual.

The residual’s center is folded into li[0] so the returned noise is the tightest symmetric enclosure of fn - p.

Non-finite values saturate soundly instead of leaking NaN into the bounds: bad coefficients (overflow, out-of-domain inputs) are zeroed before the residual is bounded against them, and an overflowing residual bound becomes an infinite noise with a finite center.

With an optimizer, every element independently keeps the coefficients of the tightest residual width seen anywhere along the trajectory — the closed form is iterate 0, so no element ever ends looser than it — and the noise is recomputed from that selection.

override_handler(other)#

A copy of this handler that takes precedence over other when both are ready for the same call.

overrides: list[type[OpHandler]] = []#
abstractmethod quartic_bound(lb, ub)#

Elementwise bound on |fn''''| over [lb, ub] (for spline3_ibp).

order: int#
nintvl: int#
optimizer: AdamConfig | None#
opt_iters: int#
op: str#