FLINT3.7.0-dev

Exponential and logarithm

Synopsis#include <flint/padic.h>
int padic_exp(padic_t rop, const padic_t op, const padic_ctx_t ctx)source
int padic_exp_rectangular(padic_t rop, const padic_t op, const padic_ctx_t ctx)source
int padic_exp_balanced(padic_t rop, const padic_t op, const padic_ctx_t ctx)source

Return whether the exponential series converges at op, that is, whether op is zero or has valuation at least 1 (odd pp) or 2 (p=2p = 2), and if so set rop to exp⁡(op)\exp(op), reduced. Otherwise rop is not changed. The rectangular version evaluates the series by rectangular splitting, the balanced version by the pp-adic analogue of the bit-burst method with binary splitting, which is quasi-linear in NN for fixed pp.

int padic_log(padic_t rop, const padic_t op, const padic_ctx_t ctx)source
int padic_log_rectangular(padic_t rop, const padic_t op, const padic_ctx_t ctx)source
int padic_log_satoh(padic_t rop, const padic_t op, const padic_ctx_t ctx)source
int padic_log_balanced(padic_t rop, const padic_t op, const padic_ctx_t ctx)source

Return whether the logarithm series converges at op, that is, whether ord⁡p(op−1)≥1\operatorname{ord}_p(op - 1) \ge 1, and if so set rop to log⁡(op)\log(op), reduced. Otherwise rop is not changed. The condition is the same for every pp, including p=2p = 2. The rectangular version evaluates the series by rectangular splitting, the Satoh version first raises op to the power pkp^k with k=⌊N⌋k = \lfloor \sqrt N \rfloor, and the balanced version writes op as a product of factors whose logarithms are summed by binary splitting.

The pp-adic exponential and logarithm are defined by their power series

exp⁡(x)=∑i≥0xii!,log⁡(x)=∑i≥1(−1)i−1(x−1)ii,\exp(x) = \sum_{i \ge 0} \frac{x^i}{i!}, \qquad \log(x) = \sum_{i \ge 1} (-1)^{i - 1} \frac{(x - 1)^i}{i},

which converge for ord⁡p(x)>1/(p−1)\operatorname{ord}_p(x) > 1/(p - 1) and for ord⁡p(x−1)>0\operatorname{ord}_p(x - 1) > 0, respectively. For x∈Qpx \in \mathbf{Q}_p this means ord⁡p(x)≥1\operatorname{ord}_p(x) \ge 1 (≥2\ge 2 if p=2p = 2) for the exponential and x≡1(modp)x \equiv 1 \pmod p for the logarithm. On these domains they are inverse isomorphisms between pZpp\mathbf{Z}_p (or 4Z24\mathbf{Z}_2) and 1+pZp1 + p\mathbf{Z}_p (or 1+4Z21 + 4\mathbf{Z}_2). The functions return 0 and leave the output unchanged when the series diverges, and otherwise return 1 and set the output to the value reduced modulo pNp^N. Since the result of the exponential is a unit and that of the logarithm has valuation at least that of x−1x - 1, the precision NN of the output is also, up to the valuation, its number of correct digits.

AlgorithmThe p-adic exponential and logarithmConvergence and truncation bounds for the p-adic exponential and logarithm series, their evaluation by rectangular splitting with deferred denominators, the balanced (bit-burst) method with binary splitting, and the Satoh–Skjernaa–Taguchi reduction of the logarithm, as implemented in padic, qadic and padic_radix.

Algorithms#

Both series are truncated after the first term whose valuation, and that of every later term, is at least NN (_padic_exp_bound and _padic_log_bound). The tail bounds use ord⁡p(i!)≤(i−1)/(p−1)\operatorname{ord}_p(i!) \le (i - 1)/(p - 1) and ord⁡p(i)≤log⁡pi\operatorname{ord}_p(i) \le \log_p i; for an argument of valuation vv this gives about N(p−1)/((p−1)v−1)N(p - 1)/((p - 1)v - 1) terms for the exponential and about N/vN/v for the logarithm.

  • Rectangular splitting evaluates the truncated series with about 2n2\sqrt n multiplications of full-size integers modulo pN+kp^{N + k}, the kk extra digits absorbing the powers of pp in the denominators i!i! or ii. It is used by padic_exp for N<1024N < 1024 and by padic_log for N<512/bN < 512/b, where bb is the bit length of pp.
  • The balanced algorithms split the argument into pieces x=x0+x1+⋯x = x_0 + x_1 + \cdots with xjx_j having valuation at least 2j2^j and 2j2^j digits, and use exp⁡(x)=∏exp⁡(xj)\exp(x) = \prod \exp(x_j), respectively log⁡(x)=∑log⁡(1−yj)\log(x) = \sum \log(1 - y_j) for a matching factorisation x=∏(1−yj)x = \prod (1 - y_j). Each short series is summed exactly by binary splitting. This is the pp-adic analogue of Brent's bit-burst method and costs O(M(Nlog⁡p)log⁡2N)O(M(N \log p) \log^2 N), quasi-linear in NN.
  • Satoh's method (padic_log_satoh) uses log⁡(x)=p−klog⁡(xpk)\log(x) = p^{-k} \log(x^{p^k}): since xpk−1x^{p^k} - 1 has valuation at least k+1k + 1, the series for the right-hand side has about N/(k+1)N/(k + 1) terms, and with k=⌊N⌋k = \lfloor \sqrt N \rfloor the power (about klog⁡2pk \log_2 p squarings) and the shorter series together cost O(Nlog⁡p)O(\sqrt N \log p) multiplications [SST2003]. It is never selected automatically, and for N<16N < 16 it falls back to rectangular splitting.

Example#

With p=5p = 5 and precision 20, the logarithm inverts the exponential at 15=3⋅515 = 3 \cdot 5, by each of the three algorithms. Neither series converges at the unit 3.

Examplepadic_exp_log.cchecked by make checkdoc
#include <flint/flint.h>
#include <flint/padic.h>

int main(void)
{
    fmpz_t p;
    padic_ctx_t ctx;
    padic_t x, y, z;
    int ok;

    fmpz_init_set_ui(p, 5);
    padic_ctx_init(ctx, p, 0, 20, PADIC_TERSE);
    padic_init2(x, 20);
    padic_init2(y, 20);
    padic_init2(z, 20);

    padic_set_ui(x, 15, ctx);            /* x = 3 * 5, valuation 1 */
    ok = padic_exp(y, x, ctx);
    flint_printf("exp(15) converges: %d\ny = ", ok);
    padic_print(y, ctx); flint_printf("\n");

    ok = padic_log(z, y, ctx);
    flint_printf("log(y) converges: %d, log(y) == 15: %d\n",
                 ok, padic_equal(z, x));

    padic_log_balanced(z, y, ctx);
    flint_printf("balanced agrees: %d\n", padic_equal(z, x));
    padic_log_satoh(z, y, ctx);
    flint_printf("Satoh agrees: %d\n", padic_equal(z, x));

    padic_set_ui(x, 3, ctx);             /* a unit, not 1 mod 5 */
    flint_printf("exp(3) converges: %d, log(3) converges: %d\n",
                 padic_exp(y, x, ctx), padic_log(z, x, ctx));

    padic_clear(x); padic_clear(y); padic_clear(z);
    padic_ctx_clear(ctx);
    fmpz_clear(p);
    return 0;
}
Output
exp(15) converges: 1
y = 87481552191941
log(y) converges: 1, log(y) == 15: 1
balanced agrees: 1
Satoh agrees: 1
exp(3) converges: 0, log(3) converges: 0

The value printed is the representative of exp⁡(15)\exp(15) modulo 5205^{20}. Applying the logarithm to it recovers 15 exactly, because log⁡(exp⁡(x))=x\log(\exp(x)) = x on the domain of convergence and both functions are computed to the full precision of the output.

References#

  • [SST2003] T. Satoh, B. Skjernaa and Y. Taguchi. Fast computation of canonical lifts of elliptic curves and its application to point counting. Finite Fields and Their Applications 9 (2003), 89–101. https://doi.org/10.1016/S1071-5797(02)00013-8
Cite this page

The FLINT team, “Exponential and logarithm (padic.h),” FLINT: Fast Library for Number Theory, documentation, version 3.7.0-dev, 2026. https://flintlib.org/doc/padic/exp-log.html (generated 2026-11-02).