← Back to Pull requests

BUG: it2i0k0: restore the asymptotic coefficients' exponents and the sqrt(2x/pi) factor #330

Closed
unknown closed this pull request without merging on Oct 21, 2026 21:03 UTC
View on GitHub
unknown unknown commented on Oct 19, 2026 17:31 UTC
Author

Reference issue

None.

What does this implement/fix?

it2i0k0(30)[1], the integral of K0(t)/t from 30 to infinity, returns 2.0349881754088256e-14. mpmath gives 6.780268362546424e-16. Two translation errors from the Fortran ITTIKA:

  • the last six coefficients lost their D+n exponents (1.45380859375D+1 to 1.4950639538279D+5);

  • rc reads x sqrt(2.0 / (pi x)), where the Fortran has RC=XDSQRT(2.0D0/PIX).
  • So the second output is off by about a factor of x for every x above 12, and the first is off by 2.2e-4 from x = 40, where its asymptotic branch starts.

    Additional information

    The new test checks x = 30, 40, 100 and 300 against mpmath and fails on main. Its tolerances (1e-6 at x = 30, 1e-7 above) are looser than the error of the Fortran's own expansion (5.7e-8 at x = 30). clang-format puts the restored coefficients one per line.

    Reference values, mpmath 1.3.0:

    import mpmath as mp
    mp.mp.dps = 40
    
    def it2i0k0(x):
        X = mp.mpf(x)
        with mp.workdps(int(x / 2.3) + 40):
            ti = +mp.nsum(lambda k: (X / 2) ** (2 * k) / (2 * k * mp.factorial(k) ** 2), [1, mp.inf])
        # K0 integrand scaled by exp(x) so the quadrature works with values near 1
        g = lambda u: mp.besselk(0, X + u) * mp.exp(X) / (X + u)
        tk = mp.quad(g, [0, 1, 5, 20, 60, 150, mp.inf]) * mp.exp(-X)
        return ti, tk
    
    for x in [30.0, 40.0, 100.0, 300.0]:
        ti, tk = it2i0k0(x)
        print(x, float(ti), float(tk))
    

    AI Generation Disclosure

    Claude (Anthropic) helped find the case and write the fix and test. I checked it against the Fortran and ran the tests.

    Diff: 200 lines (+150 / -50) across 2 files Reviewer: mkzung Review duration: 3091m
    All Vouch review confidence checks passed
    Residual risk 0.14 = Change Risk (0.36) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.36 · 200 lines diff across 2 files
    0.36
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.317
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #330"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 36.2% (MEDIUM) · Higher = larger blast radius
    36.2%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 60.5% · Lower = rushed or shallow review
    60.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 14.3% · Safe to merge
    14.3%
    Repository