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.
Description
Raising an
arbinterval that crosses zero to an exact integer exponent can returnnan, even when the power has a finite real enclosure. This affects the released 0.9.0 wheel and the currentarb.__pow__implementation.Reproducer
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 both0and1.Cause
arb.__pow__currently converts every supported exponent to anarband callsarb_pow. That discards the fact that Pythonintandfmpzoperands are exact integers. FLINT exposesarb_pow_fmpzspecifically for integer exponents, and using it also avoids the zero-crossing failure in generic real exponentiation.The FLINT power API documents
arb_pow_fmpzas integer binary exponentiation: https://flintlib.org/doc/arb.html#c.arb_pow_fmpzI have a focused patch with regression coverage for Python
intandfmpzexponents.