program.py

back to table · edit · history · where entries came from · files · download

1074 bytes, as of the version from 2026-11-17 16:08 (current). Recorded here, not run.

import numberdb.sage as numberdb
from sage.rings.rational_field import QQ
from sage.rings.real_arb import RealBallField
from sage.rings.complex_arb import ComplexBallField

def even_power_determinant(n, normalization='bessel', digits=100):
    n = int(n)
    if n < 1 or normalization not in ('bessel', 'period'):
        raise ValueError('positive n; normalization bessel or period')
    r = (n+1)//2
    R = RealBallField(numberdb.bits(digits, losing=96))
    if n % 2:
        v = R.pi().sqrt()**(r*(r+1)) * R(2).sqrt()**(r*(r-3))
        for a in range(1,r):
            v *= R(a)**(r-a) / R(2*a+1).sqrt()**(2*a+1)
    else:
        v = R.pi().sqrt()**((r+1)**2) / (R(2).sqrt()**(r*(r+3))*R(QQ(r+1)/2).gamma())
        for a in range(1,r):
            v *= R(QQ((2*a+1)**(r-a))/QQ((a+1)**(a+1)))
    C = ComplexBallField(R.precision())
    if normalization == 'bessel':
        return C(v)
    s = r*(r-1)//2
    return C(v*(-1)**(n*r-s)*QQ(2)**(n*r-2*s)*R.pi()**s)*C.gen(0)**s

# Default selection: all n=1..16, bessel then period.
even_power_determinant(17, 'period')