program-snippet.py

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

642 bytes, as of the version from 2026-11-01 08:20 (current). Recorded here, not run.

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

def R(x, digits=100):
    x = QQ(x)
    if x == 0:
        return 0
    assert x > 0
    F = RealBallField(numberdb.bits(digits, losing=2*int(x.ceil())+80))
    total, term, majorant = F(0), F(1), QQ(1)
    j = 0
    while True:
        if j+1 > x:
            tail = x*majorant/(1-x/(j+1))
            if tail < QQ(1)/10**(digits+35):
                return F(x)*total + F(0, tail)
        total += term/F(2*j+2).zeta()
        j += 1
        term *= -F(x)/j
        majorant *= x/j

values = [R(x) for x in range(101)]