Skip to content

arb interval powers with integer exponents can return nan #426

Description

@morluto

Description

Raising an arb interval that crosses zero to an exact integer exponent can return nan, even when the power has a finite real enclosure. This affects the released 0.9.0 wheel and the current arb.__pow__ implementation.

Reproducer

from flint import arb

x = arb(0, 1)
print(x)       # [+/- 1.01]
print(x ** 1)  # nan
print(x ** 2)  # nan

Observed with python-flint 0.9.0 and FLINT 3.6.0.

Expected behavior

Both results should be finite enclosures. In particular, squaring an interval that contains [-1, 1] should contain both 0 and 1.

Cause

arb.__pow__ currently converts every supported exponent to an arb and calls arb_pow. That discards the fact that Python int and fmpz operands are exact integers. FLINT exposes arb_pow_fmpz specifically for integer exponents, and using it also avoids the zero-crossing failure in generic real exponentiation.

The FLINT power API documents arb_pow_fmpz as integer binary exponentiation: https://flintlib.org/doc/arb.html#c.arb_pow_fmpz

I have a focused patch with regression coverage for Python int and fmpz exponents.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions