Skip to main content

Y0_ZEROS

Static Y0_ZEROS 

Source
pub(crate) static Y0_ZEROS: [(u64, u64); 48]
Expand description

Y0 zeros and extremums. Generated by SageMath:

R120 = RealField(120)

zeros = []

mp.prec = 150

step = mpf("0.1")
epsilon = mpf("1e-35")
x = mpf("1.25")

previous_zero = R120(0)
y0_zeros = []

while x < mpf("76.0"):
    f1 = bessely(0, x)
    f2 = bessely(0, x + step)
    if f1 * f2 < 0:
        zero = findroot(lambda t: bessely(0, t), (x, x + step), solver='secant', tol=mp.mpf("1e-41"))
        previous_zero = zero
        y0_zeros.append(zero)
    if previous_zero is not None and abs(x - mpf(f'{round(x)}')) < epsilon:
        zeros.append(previous_zero)
    x += step

y0_extrema = []

x = mpf("1.25")
while x < mpf("76.0"):
    d1 = mp.diff(lambda t: bessely(0, t), x)
    d2 = mp.diff(lambda t: bessely(0, t), x + step)
    if d1 * d2 < 0:
        extremum = findroot(lambda t: mp.diff(lambda u: bessely(0, u), t), (x, x + step), solver='secant', tol=mp.mpf("1e-41"))
        y0_extrema.append(extremum)
    x += step

# Print results
for i, z in enumerate(j0_zeros):
    print(f"Zero {i+1}: x ≈ {z}")

print("Extrema (peaks/valleys) of Y0(x):")
for e in y0_extrema:
    print(f"nExtrema: {e}")

y0_zeros.extend(y0_extrema)

y0_zeros = sorted(y0_zeros)

# Print results
for i, z in enumerate(y0_zeros):
    print(f"Peak or zero {i+1}: x ≈ {z}")

print("")

print("pub(crate) static Y0_ZEROS: [(u64, u64); 48] = [")
print(f"(0x0, 0x0),")
for z in y0_zeros:
    k = split_double_double(z)
    hi = double_to_hex(k[1])
    lo = double_to_hex(k[0])
    print(f"({lo}, {hi}),")

print("];")