BUG: gamma, rgamma: use the real functions on the real axis #639
All Vouch review confidence checks passed
Residual risk 0.13 = Change Risk (0.33) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.33 · 152 lines diff across 1 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
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.301
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #639"
general
weight: 0.35
j-bowhay
Reference issue
No issue; item 12 of #629. Found while porting xsf to Rust (https://github.com/jorenham/xsf-rust/pull/1880).
What does this implement/fix?
For real
z, complexgamma(z)andrgamma(z)lose accuracy and get a spurious imaginary part fromexp(loggamma(z))andexp(-loggamma(z)), e.g.gamma(-150.7+0j)gives-2.029162431824821e-264-7.36e-278jinstead of-2.029162431825101e-264+0j. For realzother than the poles and zeros, they now return the realGamma/rgammawith imaginary partcopysign(0, imag(z)), so thatf(conj(z)) == conj(f(z)). This is limited to1 - MAXGAM < z < MAXGAMforgammaand-178 < z < MAXGAMforrgamma, where the real functions do not overflow or underflow too early.Additional information
The new tests fail on
mainwith GCC and Clang (relative error up to 1.4e-13 and nonzero imaginary parts) and pass with the fix. Thegamma,rgamma, andloggammaxsref table tests pass.AI Generation Disclosure
Claude Opus 5.5 (Claude Code) wrote the fix, the test, and this description, following the plan in this comment. GPT-6.2 Sol (Codex CLI) reviewed it.