Dirichlet characters
- Cost
- One discrete logarithm per prime power component for a value; or a sieve with logarithms for all values up to ; conductor, parity and order from the number in .
A Dirichlet character modulo is a group homomorphism , extended to by periodicity and by for . For the theory see [Apo1976, Chapter 6] and [IR1990, Chapter 4]; the numbering is that of Conrey, used by the LMFDB [LMFDB].
The unit group#
By the Chinese remainder theorem , and the factors have the following structure [IR1990, Theorem 2 of Chapter 4].
Theorem 1. For an odd prime , is cyclic of order , and an integer generates it for every if and only if generates . For , is the direct product of the subgroup and the cyclic subgroup of order generated by 5; and is trivial.
The Conrey generators are: for odd , the smallest positive integer that is a primitive root modulo ; for , the two generators and of the 2-part; for , the generator . For all primes up to except and , the smallest primitive root modulo is also a primitive root modulo , so FLINT computes it with n_primitive_root_prime and treats the two exceptions separately (the generators are 10 and 7); larger prime factors are not supported. Each generator of order is lifted to , , so that every is uniquely
The vector is the log of . The exponent of the group is .
Characters and the Conrey pairing#
A character is determined by its values on the generators, which are -th roots of unity. Conrey's choice is
for with logs and . This is a nondegenerate symmetric bilinear pairing on , so is an isomorphism from the group onto its dual. As a consequence, the character group operations are those of the numbers (), the order of is the multiplicative order of , and by symmetry . Values are exact roots of unity with , which the module returns as the exponent .
Conductor, parity and primitivity#
A character modulo is induced by a character modulo if it is the composition with the reduction . The conductor is the smallest such , and is primitive if its conductor is .
Proposition 2. The conductor of is the product over the components of the following factors. For an odd with log entry : 1 if , and otherwise. For the 2-part: 1 if both log entries are zero; 4 if only the entry of is nonzero; if the entry of is nonzero.
Proof. The character is induced modulo if and only if it is trivial on the kernel of the reduction modulo , which is a product over the components. For a cyclic component generated by of order , the kernel of the reduction to is generated by , and is 1 if and only if . The smallest such is . The 2-part is analogous, with the kernel of the reduction from to , , generated by , and to by .
From the number instead of the log, the -part of the conductor is , where is the least integer with (and 1 if ), since the order of in the component determines . The parity follows from the symmetry of the pairing:
Proposition 3. , where is the product of the distinct odd primes dividing , is the Jacobi symbol, and if and , otherwise .
Proof. . In an odd component, has log entry , contributing where is the log entry of ; is even exactly when is a square modulo , so the contribution is the Legendre symbol . In the 2-part, has entry 1 on the generator and 0 on , contributing with exactly when .
Counting the logs that give conductor in each component, the number of primitive characters is multiplicative: for , for with , and for the 2-part 0, 1 and for , and with .
Computing values#
The value requires the log of , hence a discrete logarithm in each odd component; the 2-part needs only and a 2-adic logarithm. These are computed with the dlog module (Discrete logarithm tables): a single logarithm with dlog_once, or with tables precomputed for many calls.
For the vector of values there are two strategies.
- Loop over the group. Enumerating the logs in lexicographic order (
dirichlet_char_next), each step multiplies the number by one generator and adds a constant to the value exponent, so all values cost operations without any discrete logarithm. This is best when is comparable with . - Sieve. Since is completely multiplicative, it suffices to know for the primes ;
dlog_vec_addcomputes the discrete logarithms of the small primes directly and obtains those of the larger primes cheaply from relations found by a partial extended Euclidean algorithm, then fills in all by multiplicativity. Each odd component contributes its part of the exponent, and the 2-part is added directly. This is best for much smaller than .
Use in FLINT#
dirichlet_group_initfactors and computes the Conrey generators and their lifts;dirichlet_group_dlog_precomputebuildsdlog_precomp_modpe_inittables for each component.dirichlet_char_logcomputes the log of a number withdlog_once,dlog_mod2e_1mod4or the precomputed tables;_dirichlet_char_expgoes back with modular powers.dirichlet_conductor_char,dirichlet_parity_charanddirichlet_order_charuse the log (Proposition 2); the_uiversions use the number, with modular powers, a Jacobi symbol (Proposition 3) and the factorisation of the group exponent.dirichlet_chi_vecuses the loop over the group when and the sieve otherwise.acb_dirichletbuilds on these functions for the numerical values, Gauss sums and -functions.
int dirichlet_group_init(dirichlet_group_t G, ulong q)void dirichlet_char_log(dirichlet_char_t x, const dirichlet_group_t G, ulong m)ulong dirichlet_chi(const dirichlet_group_t G, const dirichlet_char_t chi, ulong n)void dirichlet_chi_vec(ulong * v, const dirichlet_group_t G, const dirichlet_char_t chi, slong nv)ulong dirichlet_conductor_ui(const dirichlet_group_t G, ulong a)int dirichlet_parity_ui(const dirichlet_group_t G, ulong a)Referenced from#
- acb_dirichlet.h (module)
- Discrete logarithm tables (algorithm)
- Characters in the Conrey numbering
- dirichlet.h (module)
References#
- [Apo1976] T. M. Apostol, Introduction to Analytic Number Theory, Undergraduate Texts in Mathematics, Springer, 1976. https://doi.org/10.1007/978-1-4757-5579-4
- [IR1990] K. Ireland and M. Rosen, A Classical Introduction to Modern Number Theory, second edition, Graduate Texts in Mathematics 84, Springer, 1990. https://doi.org/10.1007/978-1-4757-2103-4
- [LMFDB] The LMFDB Collaboration, The L-functions and modular forms database, https://www.lmfdb.org (Dirichlet characters: https://www.lmfdb.org/Character/Dirichlet/).
The FLINT team, “Dirichlet characters,” FLINT: Fast Library for Number Theory, documentation, version 3.7.0-dev, 2026. https://flintlib.org/doc/algorithms/number-theory/dirichlet-characters.html (generated 2026-11-02).
@misc{flint-doc-algorithms-number-theory-dirichlet-characters,
author = {{The FLINT team}},
title = {{Dirichlet characters}},
howpublished = {FLINT: Fast Library for Number Theory, documentation, version 3.7.0-dev},
year = {2026},
url = {https://flintlib.org/doc/algorithms/number-theory/dirichlet-characters.html},
note = {Generated 2026-11-02}
}