Skip to content

Add Newton (reciprocal based) division for large quotients#80

Draft
cmpute wants to merge 1 commit into
masterfrom
newton-div
Draft

Add Newton (reciprocal based) division for large quotients#80
cmpute wants to merge 1 commit into
masterfrom
newton-div

Conversation

@cmpute

@cmpute cmpute commented Jun 17, 2026

Copy link
Copy Markdown
Owner

Division via an approximate reciprocal of the divisor (Brent-Zimmermann's precision-doubling Newton iteration) followed by Moller-style quotient-block development with a bounded correction loop. It is dispatched alongside schoolbook and Burnikel-Ziegler when both the divisor and the quotient exceed ~6000 words, where it is up to ~2x faster than Burnikel-Ziegler (see the new ubig_div_asymmetric benchmark; the existing symmetric ubig_div stays on the schoolbook path).

Also fixes a latent memory-sizing bug in gcd_ext post-processing (it sized the scratch for the wrong divisor length, exposed by Newton's larger requirement), and adds a defensive fallback so callers that under-size scratch transparently use Burnikel-Ziegler.

Division via an approximate reciprocal of the divisor (Brent-Zimmermann's
precision-doubling Newton iteration) followed by Moller-style quotient-block
development with a bounded correction loop. It is dispatched alongside
schoolbook and Burnikel-Ziegler when both the divisor and the quotient exceed
~6000 words, where it is up to ~2x faster than Burnikel-Ziegler (see the new
ubig_div_asymmetric benchmark; the existing symmetric ubig_div stays on the
schoolbook path).

Also fixes a latent memory-sizing bug in gcd_ext post-processing (it sized the
scratch for the wrong divisor length, exposed by Newton's larger requirement),
and adds a defensive fallback so callers that under-size scratch transparently
use Burnikel-Ziegler.

Co-Authored-By: Claude <noreply@anthropic.com>
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.

1 participant