Skip to content

Add libeta and libetac, the logarithms of ibeta and ibetac - #1500

Merged
NAThompson merged 7 commits into
developfrom
libeta
Oct 3, 2026
Merged

NAThompson merged 7 commits into
developfrom
libeta

Conversation

@NAThompson

@NAThompson NAThompson commented Oct 2, 2026 •

Copy link
Copy Markdown
Collaborator

Logs of the smaller of ibeta and ibetac, switching to log-space power terms over the continued fraction where it underflows. Closes #1173.

Builds on #1498 (lbeta), so its first commits are that PR's; supersedes #1359.

ulps against Arb's arb_hypgeom_beta_lower: libeta/libetac in blue, log(ibeta)/log(ibetac) in orange; crosses are clipped or -inf. The scatter near the mean is ibeta's own error, which libeta inherits there (ibeta(1000, 1000, x) is off by up to 391 eps near x = 0.5).

🤖 Generated with Claude Code

@NAThompson

NAThompson commented Oct 2, 2026 •

Copy link
Copy Markdown
Collaborator Author

reporting/performance/libeta_performance.cpp. Ordinary arguments: a, b log-uniform in [0.5, 1000], x uniform in (0, 1). Underflow: a = b log-uniform in [1e4, 1e5], x in [0.05, 0.4], where log(ibeta) is -inf. Median of 5 repetitions, Apple M-series, Homebrew clang 23, -O3.

float double long double
libeta, ordinary 129 ns 237 ns 236 ns
log(ibeta), ordinary 111 ns 222 ns 220 ns
libeta, underflow 72 ns 136 ns 137 ns

@mborland

mborland commented Oct 2, 2026

Copy link
Copy Markdown
Member

@NAThompson please add the CUDA tests here as well. If need be I can go back through your flurry of recent PRs and add them where need be. Need to also fix the breakage identified this morning

@NAThompson
NAThompson force-pushed the libeta branch 3 times, most recently from d7b951c to aafcb8a Compare October 3, 2026 04:51
NAThompson and others added 7 commits October 3, 2026 07:22
Logs of the smaller of ibeta and ibetac, switching to log-space power terms over the continued fraction where it underflows. Closes #1173.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Its first term is 0/0 there; the target can underflow with a = 1 when x or b is tiny.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… type

Only targets that underflow it are checked, so the result comes from the new generic power terms.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…an error

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@NAThompson
NAThompson merged commit 34eb840 into develop Oct 3, 2026
46 of 48 checks passed
@dschmitz89

Copy link
Copy Markdown
Contributor

Thanks @NAThompson , things are moving quite fast here lately. This will be very helpful over at SciPy!

I know that it is a big ask but would it be possible to test all the already existing ibeta cases with libeta as well (if not already done, cannot evaluate the full diff arm)? The incomplete beta has many branches and special cases that caused some pain in the past.

@NAThompson

Copy link
Copy Markdown
Collaborator Author

@dschmitz89 : Good point-I created ulps plots for tons of regimes locally but didn't post them.

I also think that the ulps plot code needs to be extended to 2D so that we can tackle more regimes in a single graphic. Lemme create an issue.

@mdhaber

mdhaber commented Oct 4, 2026

Copy link
Copy Markdown

Thank you for this!

@NAThompson
NAThompson deleted the libeta branch October 4, 2026 14:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

New special functions: logarithm of incomplete gamma and beta functions

4 participants