program.py

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

1141 bytes, as of the version from 2026-11-02 08:29. Recorded here, not run.

import numberdb.sage as numberdb
from sage.rings.integer_ring import ZZ
from sage.rings.rational_field import QQ
from sage.rings.real_arb import RealBallField
from sage.combinat.partition import Partitions  # initialize partition support first
from sage.combinat.partition_tuple import PartitionTuples
from math import factorial

def character_degree_sum(q, n, s, digits=100):
    q, n, s = int(q), int(n), QQ(s)
    if q < 1 or n < 2:
        raise ValueError('q>=1 and n>=2 are required; s may be any rational')
    if n == 2:
        degrees = [(1, 2*q), (2, q*(q-1)//2)]
    else:
        degrees = []
        for shapes in PartitionTuples(q, n):
            hooks = ZZ(1)
            for shape in ([shapes] if q == 1 else shapes):
                hooks *= shape.hook_product(1)
            degrees.append((ZZ(factorial(n)) // hooks, 1))
    if s.denominator() == 1:
        return sum(QQ(count)*QQ(degree)**int(s) for degree, count in degrees)
    R = RealBallField(numberdb.bits(digits, losing=64))
    return sum(R(count)*R(d)**R(s) for d, count in degrees)

# One further signed-permutation group.
character_degree_sum(2, 13, '9/4')