padic: Fast, type-safe p-adic arithmetic

[ library, math, mit, number-theory ] [ Propose Tags ]

Implementation of p-adic arithmetics on the base of fast modular arithmetics. Module introduces data types for p-adic integers and rationals with arbitrary precision as well as some specific functions (rational reconstruction, p-adic signum function, square roots etc.).

[Skip to Readme]


[Index] [Quick Jump]

  • Math
    • NumberTheory
      • Math.NumberTheory.Padic
        • Math.NumberTheory.Padic.Analysis
        • Math.NumberTheory.Padic.Integer
        • Math.NumberTheory.Padic.Rational
        • Math.NumberTheory.Padic.Types


Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees


  • No Candidates
Versions [RSS]
Change log
Dependencies base (>=4.14 && <4.17), constraints (>=0.13 && <0.14), integer-gmp (>=1.0.3 && <1.1), mod (>= && <1.3) [details]
License MIT
Copyright 2022 Sergey B. Samoylenko
Author Sergey B. Samoylenko <>
Category Math, Number Theory
Home page
Bug tracker
Source repo head: git clone
Uploaded by samsergey at 2022-02-03T16:07:08Z
Downloads 92 total (5 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs uploaded by user
Build status unknown [no reports yet]

Readme for padic-

[back to package description]


Module introduces p-adic integers and p-adic rational numbers of fixed and arbitratry precision, implementing basic arithmetic as well as some specific functions, i.e. detection of periodicity in digital sequence, rational reconstruction, square roots etc.

In order to gain efficiency the integer p-adic number with radix p is internally represented in form N mod p^k as only one digit N, lifted to modulo p^k, where k is chosen so that within working precision numbers belogning to Int and Ratio Int types could be reconstructed by extended Euclidean algorithm. Canonical expansion is used for textual output only.