[go: up one dir, main page]

login
A374856
a(n) is the least integer m such that the distance of x_m from its nearest integer is less than 1/n, where x_m is the m-th extrema of gamma(x).
2
0, 1, 6, 23, 76, 231, 681, 1968, 5605, 15817, 44324, 123573, 343157, 950000, 2623530, 7230746, 19896140, 54671729, 150058028, 411465352, 1127315946, 3086355718, 8444524052, 23092305853, 63117665557, 172444844373, 470961842866, 1285804853026, 3509404275438, 9575773901601
OFFSET
1,3
COMMENTS
a(n) approximately equals exp(Pi/tan(Pi/n)).
FORMULA
A377376(a(n)) = n.
EXAMPLE
-1 + 1.46163214496836 < 1/1
1 - 0.50408300826446 < 1/2
6 - 5.66716244155689 < 1/3
23 - 22.7502429843061 < 1/4
76 - 75.8003723367285 < 1/5
231 - 230.833395691244 < 1/6
PROG
(Python)
from gmpy2 import mpq, get_context, exp, digamma, sign, is_nan, RoundUp, RoundDown
def apply_on_interval(func, interval):
ctx.round = RoundUp
rounded_up = func(interval[0])
ctx.round = RoundDown
rounded_down = func(interval[1])
return rounded_down, rounded_up
def digamma_sign_near_int(i, f):
while True:
d, u = apply_on_interval(lambda x: digamma(i + 1/x), [f, f])
if not(is_nan(d)) and not(is_nan(u)) and (sign(d) == sign(u)): return sign(d)
ctx.precision += 1
def find_next_zero_crossing(f, i, growth_factor): # Bisect.
lo, hi = int(i * const_e), int(i * growth_factor)
while lo - 1 != hi:
if digamma_sign_near_int(mid := (hi + lo) // 2, f) == -1: lo = mid
else: hi = mid
return hi
def generate_sequence(n):
seq, frac_denoms = [0, 1, 6], (mpq(str(i)) for i in range(4, n + 1))
for f in frac_denoms: seq.append(-find_next_zero_crossing(f, -seq[-1], seq[-1] / seq[-2]))
return seq
const_e, ctx = exp(1), get_context()
ctx.precision = 2
A374856 = generate_sequence(30)
CROSSREFS
KEYWORD
nonn
AUTHOR
Jwalin Bhatt, Sep 16 2024
STATUS
approved