Skip to main content

omnibias.core.verified.complex_interval

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.complex_interval
Module contract & mathematical conventions

Rigorous *complex* interval arithmetic (rectangular enclosures).

A ComplexInterval is a rectangle [re] + i[im] in the complex plane, built from two real ~omnibias.core.verified.interval.Interval\s, that *guaranteed* encloses the true complex result of every operation (each part is computed with the outward-rounded real interval algebra). This is the substrate the verified Fourier series (omnibias.core.verified.fourier) needs: Fourier coefficients are complex, and the nonlocal symbols that matter -- Riesz i k_j/|k| and Leray \delta_{ab} - k_a k_b/|k|^2 -- act on them by complex multiplication.

Rectangular (as opposed to disc/midpoint-radius) enclosures keep the implementation purely on top of the existing real Interval, at the cost of some dependency overestimation in __mul__ (the usual price of the naive complex product); for the per-mode multiplier application and the coefficient products in a truncated convolution this is tight enough, and the weighted-norm tail accounting never relies on cancellation anyway.

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.

CLASS

ComplexInterval​

omnibias.core.verified.ComplexIntervalSource ↗
class ComplexInterval

Dataclass constructor fields; inherited fields, if any, are declared by the base class. A field(...) expression describes a default factory or field options, not a literal argument default.

A rigorous rectangular enclosure [re] + i[im] of a complex quantity.

Parameters

NameType & defaultContract
redataclass fieldIntervalRequiredSee the operation contract and implementation below.
imdataclass fieldIntervalRequiredSee the operation contract and implementation below.
Executed regression · modulus lower bound zero when straddling origin

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_modulus_lower_bound_zero_when_straddling_origin() -> None:
    box = ComplexInterval(Interval(-1.0, 1.0), Interval(-1.0, 1.0))
    assert box.modulus().lo == 0.0
python -m pytest "packages/omnibias-core/tests/test_verified_complex_interval.py::test_modulus_lower_bound_zero_when_straddling_origin" -q
Regression example · complex coefficients round trip through from value

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_complex_coefficients_round_trip_through_from_value() -> None:
    c = ComplexInterval.point(2 - 3j)
    expansion = HermiteExpansion([c])
    assert expansion.get(0).re.mid == 2.0
    assert expansion.get(0).im.mid == -3.0
python -m pytest packages/omnibias-core/tests/verified/test_hermite_basis.py -k test_complex_coefficients_round_trip_through_from_value -q

Fields & methods

refield
re: Interval

Declared Interval field on ComplexInterval. A value must be provided when constructing the configuration, unless an inherited constructor supplies it.

View source ↗
imfield
im: Interval

Declared Interval field on ComplexInterval. A value must be provided when constructing the configuration, unless an inherited constructor supplies it.

View source ↗
pointmethod
point(cls, value: complex | float | int) -> ComplexInterval

Exact degenerate enclosure of the complex/real number value.

Parameters

NameType & defaultContract
valuepositional-or-keywordcomplex | float | intRequiredSee the operation contract and implementation below.

Returns: ComplexInterval

Executed regression · all bounds nonnegative

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_all_bounds_nonnegative() -> None:
    problem, a_star = _scalar_problem()
    r = quadratic_radii_certificate(problem, a_star)
    assert min(r.y0, r.z0, r.z1, r.z2, r.a_op_norm, r.residual_norm) >= 0.0
python -m pytest "packages/omnibias-core/tests/test_verified_radii_spectral.py::test_all_bounds_nonnegative" -q
Method implementation
    def point(cls, value: complex | float | int) -> ComplexInterval:
        """Exact degenerate enclosure of the complex/real number ``value``."""
        z = complex(value)
        return cls(Interval.point(z.real), Interval.point(z.imag))
View source ↗
from_partsmethod
from_parts(cls, re: IntervalLike, im: IntervalLike=0.0) -> ComplexInterval

Enclosure from real/imaginary IntervalLike parts.

Parameters

NameType & defaultContract
repositional-or-keywordIntervalLikeRequiredSee the operation contract and implementation below.
impositional-or-keywordIntervalLikeDefault: 0.0See the operation contract and implementation below.

Returns: ComplexInterval

Executed regression · continue exponential to real point

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_continue_exponential_to_real_point() -> None:
    result = continue_dfinite(
        ((-1,), (1,)),
        0.0,
        (1.0,),
        0.1,
        n_steps=16,
        order=14,
    )

    assert result.value.contains(math.exp(0.1))
python -m pytest "packages/omnibias-core/tests/verified/test_dfinite_continuation.py::test_continue_exponential_to_real_point" -q
Method implementation
    def from_parts(cls, re: IntervalLike, im: IntervalLike = 0.0) -> ComplexInterval:
        """Enclosure from real/imaginary :data:`IntervalLike` parts."""
        return cls(Interval.from_value(re), Interval.from_value(im))
View source ↗
zeromethod
zero(cls) -> ComplexInterval

See the class contract above and the exact method implementation below.

Returns: ComplexInterval

Executed regression · manufactured solution is an exact zero

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_manufactured_solution_is_an_exact_zero() -> None:
    problem, a_star = _scalar_problem()
    residual = evaluate_residual(problem, a_star)
    assert residual.norm().hi < 1e-12
python -m pytest "packages/omnibias-core/tests/test_verified_radii_spectral.py::test_manufactured_solution_is_an_exact_zero" -q
Method implementation
    def zero(cls) -> ComplexInterval:
        return cls(Interval.point(0.0), Interval.point(0.0))
View source ↗
onemethod
one(cls) -> ComplexInterval

See the class contract above and the exact method implementation below.

Returns: ComplexInterval

Executed regression · all bounds nonnegative

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_all_bounds_nonnegative() -> None:
    problem, a_star = _scalar_problem()
    r = quadratic_radii_certificate(problem, a_star)
    assert min(r.y0, r.z0, r.z1, r.z2, r.a_op_norm, r.residual_norm) >= 0.0
python -m pytest "packages/omnibias-core/tests/test_verified_radii_spectral.py::test_all_bounds_nonnegative" -q
Method implementation
    def one(cls) -> ComplexInterval:
        return cls(Interval.point(1.0), Interval.point(0.0))
View source ↗
imag_unitmethod
imag_unit(cls) -> ComplexInterval

The imaginary unit i.

Returns: ComplexInterval

Executed regression · imag unit and conj

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_imag_unit_and_conj() -> None:
    i = ComplexInterval.imag_unit()
    sq = i * i
    assert sq.contains(-1 + 0j)
    z = ComplexInterval.point(3 - 4j)
    assert z.conj().contains(3 + 4j)
    # |z|^2 = z * conj(z) is real and ~25
    prod = z * z.conj()
    assert prod.contains(25 + 0j)
python -m pytest "packages/omnibias-core/tests/test_verified_complex_interval.py::test_imag_unit_and_conj" -q
Method implementation
    def imag_unit(cls) -> ComplexInterval:
        """The imaginary unit ``i``."""
        return cls(Interval.point(0.0), Interval.point(1.0))
View source ↗
from_valuemethod
from_value(cls, value: ComplexLike) -> ComplexInterval

See the class contract above and the exact method implementation below.

Parameters

NameType & defaultContract
valuepositional-or-keywordComplexLikeRequiredSee the operation contract and implementation below.

Returns: ComplexInterval

Executed regression · manufactured solution is an exact zero

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_manufactured_solution_is_an_exact_zero() -> None:
    problem, a_star = _scalar_problem()
    residual = evaluate_residual(problem, a_star)
    assert residual.norm().hi < 1e-12
python -m pytest "packages/omnibias-core/tests/test_verified_radii_spectral.py::test_manufactured_solution_is_an_exact_zero" -q
Method implementation
    def from_value(cls, value: ComplexLike) -> ComplexInterval:
        if isinstance(value, ComplexInterval):
            return value
        if isinstance(value, Interval):
            return cls(value, Interval.point(0.0))
        if isinstance(value, complex):
            return cls.point(value)
        return cls(Interval.from_value(value), Interval.point(0.0))
View source ↗
__add__method
__add__(self, other: ComplexLike) -> ComplexInterval

See the class contract above and the exact method implementation below.

Parameters

NameType & defaultContract
otherpositional-or-keywordComplexLikeRequiredSee the operation contract and implementation below.

Returns: ComplexInterval

Executed regression · manufactured solution is an exact zero

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_manufactured_solution_is_an_exact_zero() -> None:
    problem, a_star = _scalar_problem()
    residual = evaluate_residual(problem, a_star)
    assert residual.norm().hi < 1e-12
python -m pytest "packages/omnibias-core/tests/test_verified_radii_spectral.py::test_manufactured_solution_is_an_exact_zero" -q
Method implementation
    def __add__(self, other: ComplexLike) -> ComplexInterval:
        o = ComplexInterval.from_value(other)
        return ComplexInterval(self.re + o.re, self.im + o.im)
View source ↗
__neg__method
__neg__(self) -> ComplexInterval

See the class contract above and the exact method implementation below.

Returns: ComplexInterval

Executed regression · manufactured solution is an exact zero

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_manufactured_solution_is_an_exact_zero() -> None:
    problem, a_star = _scalar_problem()
    residual = evaluate_residual(problem, a_star)
    assert residual.norm().hi < 1e-12
python -m pytest "packages/omnibias-core/tests/test_verified_radii_spectral.py::test_manufactured_solution_is_an_exact_zero" -q
Method implementation
    def __neg__(self) -> ComplexInterval:
        return ComplexInterval(-self.re, -self.im)
View source ↗
__sub__method
__sub__(self, other: ComplexLike) -> ComplexInterval

See the class contract above and the exact method implementation below.

Parameters

NameType & defaultContract
otherpositional-or-keywordComplexLikeRequiredSee the operation contract and implementation below.

Returns: ComplexInterval

Executed regression · continue exponential to real point

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_continue_exponential_to_real_point() -> None:
    result = continue_dfinite(
        ((-1,), (1,)),
        0.0,
        (1.0,),
        0.1,
        n_steps=16,
        order=14,
    )

    assert result.value.contains(math.exp(0.1))
python -m pytest "packages/omnibias-core/tests/verified/test_dfinite_continuation.py::test_continue_exponential_to_real_point" -q
Method implementation
    def __sub__(self, other: ComplexLike) -> ComplexInterval:
        return self.__add__(-ComplexInterval.from_value(other))
View source ↗
__rsub__method
__rsub__(self, other: ComplexLike) -> ComplexInterval

See the class contract above and the exact method implementation below.

Parameters

NameType & defaultContract
otherpositional-or-keywordComplexLikeRequiredSee the operation contract and implementation below.

Returns: ComplexInterval

Method implementation
    def __rsub__(self, other: ComplexLike) -> ComplexInterval:
        return ComplexInterval.from_value(other).__add__(-self)
View source ↗
__mul__method
__mul__(self, other: ComplexLike) -> ComplexInterval

See the class contract above and the exact method implementation below.

Parameters

NameType & defaultContract
otherpositional-or-keywordComplexLikeRequiredSee the operation contract and implementation below.

Returns: ComplexInterval

Executed regression · manufactured solution is an exact zero

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_manufactured_solution_is_an_exact_zero() -> None:
    problem, a_star = _scalar_problem()
    residual = evaluate_residual(problem, a_star)
    assert residual.norm().hi < 1e-12
python -m pytest "packages/omnibias-core/tests/test_verified_radii_spectral.py::test_manufactured_solution_is_an_exact_zero" -q
Method implementation
    def __mul__(self, other: ComplexLike) -> ComplexInterval:
        o = ComplexInterval.from_value(other)
        # (a + bi)(c + di) = (ac - bd) + (ad + bc) i
        re = self.re * o.re - self.im * o.im
        im = self.re * o.im + self.im * o.re
        return ComplexInterval(re, im)
View source ↗
__truediv__method
__truediv__(self, other: ComplexLike) -> ComplexInterval

See the class contract above and the exact method implementation below.

Parameters

NameType & defaultContract
otherpositional-or-keywordComplexLikeRequiredSee the operation contract and implementation below.

Returns: ComplexInterval

Validation & failure cases
  • When denom.contains_zero(), raises ZeroDivisionError('complex interval division requires a denominator box excluding zero').
Executed regression · all bounds nonnegative

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_all_bounds_nonnegative() -> None:
    problem, a_star = _scalar_problem()
    r = quadratic_radii_certificate(problem, a_star)
    assert min(r.y0, r.z0, r.z1, r.z2, r.a_op_norm, r.residual_norm) >= 0.0
python -m pytest "packages/omnibias-core/tests/test_verified_radii_spectral.py::test_all_bounds_nonnegative" -q
Method implementation
    def __truediv__(self, other: ComplexLike) -> ComplexInterval:
        o = ComplexInterval.from_value(other)
        # z / w = z * conj(w) / |w|^2
        denom = o.re.pow_int(2) + o.im.pow_int(2)  # real, must exclude 0
        if denom.contains_zero():
            raise ZeroDivisionError(
                "complex interval division requires a denominator box excluding zero"
            )
        num = self * o.conj()
        return ComplexInterval(num.re / denom, num.im / denom)
View source ↗
conjmethod
conj(self) -> ComplexInterval

See the class contract above and the exact method implementation below.

Returns: ComplexInterval

Executed regression · all bounds nonnegative

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_all_bounds_nonnegative() -> None:
    problem, a_star = _scalar_problem()
    r = quadratic_radii_certificate(problem, a_star)
    assert min(r.y0, r.z0, r.z1, r.z2, r.a_op_norm, r.residual_norm) >= 0.0
python -m pytest "packages/omnibias-core/tests/test_verified_radii_spectral.py::test_all_bounds_nonnegative" -q
Method implementation
    def conj(self) -> ComplexInterval:
        return ComplexInterval(self.re, -self.im)
View source ↗
magproperty
mag(self) -> float

Outward-rounded **upper** bound on |z| over the rectangle.

The modulus is maximised at a corner, sqrt(mag(re)^2 + mag(im)^2).

Returns: float

Executed regression · modulus lower bound zero when straddling origin

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_modulus_lower_bound_zero_when_straddling_origin() -> None:
    box = ComplexInterval(Interval(-1.0, 1.0), Interval(-1.0, 1.0))
    assert box.modulus().lo == 0.0
python -m pytest "packages/omnibias-core/tests/test_verified_complex_interval.py::test_modulus_lower_bound_zero_when_straddling_origin" -q
Method implementation
    def mag(self) -> float:
        """Outward-rounded **upper** bound on ``|z|`` over the rectangle.

        The modulus is maximised at a corner, ``sqrt(mag(re)^2 + mag(im)^2)``.
        """
        rr = Interval.point(self.re.mag)
        ii = Interval.point(self.im.mag)
        arg = rr.pow_int(2) + ii.pow_int(2)
        # squaring an exact 0 rounds the lower endpoint one ulp below 0; the
        # radicand is a true sum of squares, so clamp before the sqrt.
        arg = Interval(max(arg.lo, 0.0), arg.hi)
        return float(arg.sqrt().hi)
View source ↗
modulusmethod
modulus(self) -> Interval

Enclosure [min |z|, max |z|] of the modulus over the rectangle.

The minimum is the origin-to-rectangle distance sqrt(mig(re)^2 + mig(im)^2) (0 when the rectangle straddles the respective axis), the maximum the corner value mag.

Returns: Interval

Executed regression · modulus lower bound zero when straddling origin

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_modulus_lower_bound_zero_when_straddling_origin() -> None:
    box = ComplexInterval(Interval(-1.0, 1.0), Interval(-1.0, 1.0))
    assert box.modulus().lo == 0.0
python -m pytest "packages/omnibias-core/tests/test_verified_complex_interval.py::test_modulus_lower_bound_zero_when_straddling_origin" -q
Method implementation
    def modulus(self) -> Interval:
        """Enclosure ``[min |z|, max |z|]`` of the modulus over the rectangle.

        The minimum is the origin-to-rectangle distance
        ``sqrt(mig(re)^2 + mig(im)^2)`` (``0`` when the rectangle straddles the
        respective axis), the maximum the corner value :attr:`mag`.
        """
        arg = (
            Interval.point(self.re.mig).pow_int(2)
            + Interval.point(self.im.mig).pow_int(2)
        )
        arg = Interval(max(arg.lo, 0.0), arg.hi)
        return Interval(max(arg.sqrt().lo, 0.0), self.mag)
View source ↗
containsmethod
contains(self, z: complex | float | int) -> bool

See the class contract above and the exact method implementation below.

Parameters

NameType & defaultContract
zpositional-or-keywordcomplex | float | intRequiredSee the operation contract and implementation below.

Returns: bool

Executed regression · continue exponential to real point

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_continue_exponential_to_real_point() -> None:
    result = continue_dfinite(
        ((-1,), (1,)),
        0.0,
        (1.0,),
        0.1,
        n_steps=16,
        order=14,
    )

    assert result.value.contains(math.exp(0.1))
python -m pytest "packages/omnibias-core/tests/verified/test_dfinite_continuation.py::test_continue_exponential_to_real_point" -q
Method implementation
    def contains(self, z: complex | float | int) -> bool:
        zz = complex(z)
        return bool(self.re.contains(zz.real) and self.im.contains(zz.imag))
View source ↗
__repr__method
__repr__(self) -> str

See the class contract above and the exact method implementation below.

Returns: str

Executed regression · hermite expansion repr

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_hermite_expansion_repr() -> None:
    expansion = HermiteExpansion.from_coeffs([1.0, 2.0])
    text = repr(expansion)
    assert "HermiteExpansion" in text
    assert "order=1" in text
python -m pytest "packages/omnibias-core/tests/verified/test_hermite_basis.py::test_hermite_expansion_repr" -q
Method implementation
    def __repr__(self) -> str:
        return f"ComplexInterval(re={self.re!r}, im={self.im!r})"
View source ↗
Read the implementation
class ComplexInterval:
    """A rigorous rectangular enclosure ``[re] + i[im]`` of a complex quantity."""

    re: Interval
    im: Interval

    # ----- constructors -------------------------------------------------- #
    @classmethod
    def point(cls, value: complex | float | int) -> ComplexInterval:
        """Exact degenerate enclosure of the complex/real number ``value``."""
        z = complex(value)
        return cls(Interval.point(z.real), Interval.point(z.imag))

    @classmethod
    def from_parts(cls, re: IntervalLike, im: IntervalLike = 0.0) -> ComplexInterval:
        """Enclosure from real/imaginary :data:`IntervalLike` parts."""
        return cls(Interval.from_value(re), Interval.from_value(im))

    @classmethod
    def zero(cls) -> ComplexInterval:
        return cls(Interval.point(0.0), Interval.point(0.0))

    @classmethod
    def one(cls) -> ComplexInterval:
        return cls(Interval.point(1.0), Interval.point(0.0))

    @classmethod
    def imag_unit(cls) -> ComplexInterval:
        """The imaginary unit ``i``."""
        return cls(Interval.point(0.0), Interval.point(1.0))

    @classmethod
    def from_value(cls, value: ComplexLike) -> ComplexInterval:
        if isinstance(value, ComplexInterval):
            return value
        if isinstance(value, Interval):
            return cls(value, Interval.point(0.0))
        if isinstance(value, complex):
            return cls.point(value)
        return cls(Interval.from_value(value), Interval.point(0.0))

    # ----- arithmetic ---------------------------------------------------- #
    def __add__(self, other: ComplexLike) -> ComplexInterval:
        o = ComplexInterval.from_value(other)
        return ComplexInterval(self.re + o.re, self.im + o.im)

    __radd__ = __add__

    def __neg__(self) -> ComplexInterval:
        return ComplexInterval(-self.re, -self.im)

    def __sub__(self, other: ComplexLike) -> ComplexInterval:
        return self.__add__(-ComplexInterval.from_value(other))

    def __rsub__(self, other: ComplexLike) -> ComplexInterval:
        return ComplexInterval.from_value(other).__add__(-self)

    def __mul__(self, other: ComplexLike) -> ComplexInterval:
        o = ComplexInterval.from_value(other)
        # (a + bi)(c + di) = (ac - bd) + (ad + bc) i
        re = self.re * o.re - self.im * o.im
        im = self.re * o.im + self.im * o.re
        return ComplexInterval(re, im)

    __rmul__ = __mul__

    def __truediv__(self, other: ComplexLike) -> ComplexInterval:
        o = ComplexInterval.from_value(other)
        # z / w = z * conj(w) / |w|^2
        denom = o.re.pow_int(2) + o.im.pow_int(2)  # real, must exclude 0
        if denom.contains_zero():
            raise ZeroDivisionError(
                "complex interval division requires a denominator box excluding zero"
            )
        num = self * o.conj()
        return ComplexInterval(num.re / denom, num.im / denom)

    def conj(self) -> ComplexInterval:
        return ComplexInterval(self.re, -self.im)

    # ----- magnitude ----------------------------------------------------- #
    @property
    def mag(self) -> float:
        """Outward-rounded **upper** bound on ``|z|`` over the rectangle.

        The modulus is maximised at a corner, ``sqrt(mag(re)^2 + mag(im)^2)``.
        """
        rr = Interval.point(self.re.mag)
        ii = Interval.point(self.im.mag)
        arg = rr.pow_int(2) + ii.pow_int(2)
        # squaring an exact 0 rounds the lower endpoint one ulp below 0; the
        # radicand is a true sum of squares, so clamp before the sqrt.
        arg = Interval(max(arg.lo, 0.0), arg.hi)
        return float(arg.sqrt().hi)

    def modulus(self) -> Interval:
        """Enclosure ``[min |z|, max |z|]`` of the modulus over the rectangle.

        The minimum is the origin-to-rectangle distance
        ``sqrt(mig(re)^2 + mig(im)^2)`` (``0`` when the rectangle straddles the
        respective axis), the maximum the corner value :attr:`mag`.
        """
        arg = (
            Interval.point(self.re.mig).pow_int(2)
            + Interval.point(self.im.mig).pow_int(2)
        )
        arg = Interval(max(arg.lo, 0.0), arg.hi)
        return Interval(max(arg.sqrt().lo, 0.0), self.mag)

    def contains(self, z: complex | float | int) -> bool:
        zz = complex(z)
        return bool(self.re.contains(zz.real) and self.im.contains(zz.imag))

    def __repr__(self) -> str:
        return f"ComplexInterval(re={self.re!r}, im={self.im!r})"
Other public import paths
  • omnibias.core.verified.ComplexInterval
  • omnibias.core.verified.complex_interval.ComplexInterval
CONSTANT

ComplexLike​

omnibias.core.verified.ComplexLikeSource ↗
ComplexLike = Union['ComplexInterval', Interval, complex, float, int, Fraction]

Anything promotable to a ComplexInterval.

Read the implementation
ComplexLike = Union["ComplexInterval", Interval, complex, float, int, Fraction]
Other public import paths
  • omnibias.core.verified.ComplexLike
  • omnibias.core.verified.complex_interval.ComplexLike