FLINT3.7.0-dev

flint_mpn_brsqrt, flint_mpn_bsqrt

Synopsis#include <flint/mpn_extras.h>
int flint_mpn_brsqrt(mp_ptr res, mp_srcptr x, mp_size_t xn, mp_size_t n)source
int flint_mpn_bsqrt(mp_ptr res, mp_srcptr x, mp_size_t xn, mp_size_t n)source

If x≡1(mod8)x \equiv 1 \pmod 8, set (res,n)(\mathit{res}, n) to the 2-adic reciprocal square root yy (with xy2≡1(modBn)x y^2 \equiv 1 \pmod{B^n}), respectively the square root ss (with s2≡x(modBn)s^2 \equiv x \pmod{B^n}), that is congruent to 1 modulo 4, and return 1. Otherwise return 0 without writing anything (an odd xx is a square modulo BnB^n if and only if x≡1(mod8)x \equiv 1 \pmod 8).

The reciprocal square root is computed by a Newton iteration in bit precision (each step maps cc correct bits to 2c−22c - 2), using high products with known low part above the basecase range and full low products below FLINT_MPN_BRSQRT_MULLOW_CUTOFF limbs. The square root adds one Karp–Markstein refinement to a reciprocal square root of ⌈n/2⌉+1\lceil n/2 \rceil + 1 limbs.

Cite this page

The FLINT team, “flint_mpn_brsqrt, flint_mpn_bsqrt (mpn_extras.h),” FLINT: Fast Library for Number Theory, documentation, version 3.7.0-dev, 2026. https://flintlib.org/doc/mpn_extras/flint_mpn_brsqrt.html (generated 2026-11-02).