"""Certify the first failure of the proposed recurrence using Arb real balls."""
from flint import arb, ctx


def predicted(index):
    prefix = [1, 4, 26, 29, 51, 73, 95, 117, 139, 161, 183]
    return prefix[index] if index < len(prefix) else 183 + 355 * (index - 10)


def main():
    ctx.prec = 128
    minimum = None
    records = []
    for argument in range(1, 26432):
        value = abs(arb(argument).bessel_y(0))
        if minimum is None or value < minimum:
            minimum = value
            records.append(argument)
        elif not value > minimum:
            raise ArithmeticError(f"Undecided comparison at {argument}")
    assert len(records) == 84
    assert records[:83] == [predicted(i) for i in range(83)]
    assert (records[82], predicted(83), records[83]) == (25743, 26098, 26431)
    print("Indices 0 to 82 agree. Index 83 gives 26431, whereas the conjecture gives 26098.")
    for argument in (25743, 26098, 26431):
        print(f"|Y0({argument})| = {abs(arb(argument).bessel_y(0))}")


if __name__ == "__main__":
    main()
