FLINT3.7.0-dev

_mp_real_neglog_agm, _mp_real_neglog_agm_tune

Synopsis#include <flint/mp_real.h>
void _mp_real_neglog_agm(nn_ptr y, ulong * err, nn_srcptr x, slong n)source
void _mp_real_neglog_agm_tune(nn_ptr y, ulong * err, nn_srcptr x, slong n, slong N)source

Set (y,n)(y, n) to −log⁡x-\log x for (x,n)(x, n) in [1/2,1)[1/2, 1) by the Sasaki–Kanada AGM formula [SK1982]; err is computed at run time and at most 2. The second function takes the number NN of terms of the theta series (0 for the default, 4).

With r=x2−er = x 2^{-e} and q=r4q = r^4,

−log⁡x=π/4agm⁡(4r2S22,θ32)−elog⁡2,θ3=1+2∑k≥1qk2,S2=1+∑k≥1qk(k+1),-\log x = \frac{\pi/4}{\operatorname{agm}(4 r^2 S_2^2, \theta_3^2)} - e \log 2, \qquad \theta_3 = 1 + 2\sum_{k \ge 1} q^{k^2}, \quad S_2 = 1 + \sum_{k \ge 1} q^{k(k+1)},

with π/4\pi/4 and log⁡2\log 2 from the shared caches and the shift e=⌈p/(4(N+1)2)⌉e = \lceil p/(4(N + 1)^2) \rceil for pp bits. The cost is O(M(n)log⁡n)O(M(n) \log n) against the O(M(n)log⁡2n)O(M(n) \log^2 n) of _mp_real_neglog_newton; with warm caches the two cross over near 7⋅1057 \cdot 10^5 limbs, and against the table-free exponential the AGM is faster from about 20000 limbs. mp_real_exp_agm uses it.

References#

  • [SK1982] T. Sasaki and Y. Kanada. Practically fast multiple-precision evaluation of log(x). Journal of Information Processing 5:4 (1982), 247–250.
Cite this page

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