Evaluating Dirichlet L-functions
#include <flint/acb_dirichlet.h>void acb_dirichlet_root_number(acb_t res, const dirichlet_group_t G, const dirichlet_char_t chi, slong prec)sourcevoid acb_dirichlet_root_number_theta(acb_t res, const dirichlet_group_t G, const dirichlet_char_t chi, slong prec)sourceSet res to the root number of a primitive character. The theta version uses ; the default version uses the Gauss sum, , when has several prime factors, and the theta series otherwise. The default version throws an exception if is not primitive.
void acb_dirichlet_l(acb_t res, const acb_t s, const dirichlet_group_t G, const dirichlet_char_t chi, slong prec)sourcevoid _acb_dirichlet_l_generic(acb_t res, const acb_t s, const dirichlet_group_t G, const dirichlet_char_t chi, slong prec)sourceSets res to , choosing the algorithm. If is an exact integer, acb_dirichlet_l_si is used. If is an exact real number which is a rational number of small height (see _acb_dirichlet_get_small_fmpq), the approximate functional equation acb_dirichlet_l_fmpq_afe_jet is used when _acb_dirichlet_l_fmpq_use_afe estimates it to be faster (at high precision or for large conductor). Otherwise (and always in the underscore version): the Riemann zeta function for , the functional equation for primitive and (or near for even ), the Euler product for large , and otherwise the decomposition into Hurwitz zeta functions with a precomputation shared by the values.
void acb_dirichlet_l_jet(acb_ptr res, const acb_t s, const dirichlet_group_t G, const dirichlet_char_t chi, int deflate, slong len, slong prec)sourceSets res to the Taylor coefficients . With deflate nonzero and principal , the expansion of is computed instead, which at is the regular part of the Laurent expansion; for non-principal , deflate has no effect. For this calls acb_dirichlet_zeta_jet. Otherwise, if is an exact rational number of small height (see _acb_dirichlet_get_small_fmpq), the approximate functional equation acb_dirichlet_l_fmpq_afe_jet is used when _acb_dirichlet_l_jet_use_afe estimates it to be faster (this is not done for principal characters with deflation); otherwise the Hurwitz zeta expansions are summed.
acb_dirichlet_l evaluates at any complex for a Dirichlet character modulo , acb_dirichlet_l_jet its Taylor expansion, and acb_dirichlet_root_number the root number of the functional equation. With G and chi set to NULL (or ) these compute the Riemann zeta function. The methods are compared on Dirichlet L-functions.
Choice of method#
acb_dirichlet_l uses, in this order:
- for an exact integer ,
acb_dirichlet_l_si, which uses closed forms with generalized Bernoulli numbers when has the same parity as , and otherwise the Euler product, a generalization of Borwein's algorithm (acb_dirichlet_l_ui_borwein_bsplit) or the approximate functional equation; - for an exact dyadic such as (more generally an exact rational number of small height), the approximate functional equation (
acb_dirichlet_l_fmpq_afe_jet) when_acb_dirichlet_l_fmpq_use_afeestimates it to be faster, i.e. at high precision or for large conductor; - for ,
acb_dirichlet_zeta; - for primitive and (or near 0 and even), the functional equation , which moves the evaluation to the right half-plane;
- for at precision , the Euler product
acb_dirichlet_l_euler_product; - otherwise the decomposition (
acb_dirichlet_l_hurwitz), where the Hurwitz zeta values come from a precomputed grid of Taylor expansions in (acb_dirichlet_hurwitz_precomp_init_num) when this is cheaper than evaluating each by Euler–Maclaurin summation.
The cost of step 6 grows linearly with , so these functions are meant for moderate moduli. For many characters with the same modulus, acb_dirichlet_l_vec_hurwitz computes all values with one set of Hurwitz zeta values and a DFT. For rational that cannot be represented exactly by an acb_t (such as ), acb_dirichlet_l_fmpq makes the same choices.
For exact rational of small height, acb_dirichlet_l_jet uses the approximate functional equation when _acb_dirichlet_l_jet_use_afe estimates it to be faster; otherwise it sums the Hurwitz zeta expansions (deflated at , where the poles cancel for non-principal ) weighted by the character values, for any length; for principal characters, deflate removes the pole .
acb_dirichlet_root_number requires a primitive character. For composite moduli it computes from the Gauss sum, which is a product of local Gauss sums; for prime power moduli it uses the theta series, , which needs terms at precision .
Example#
for the nontrivial character modulo 4, and the value, derivative and root number at of the character modulo 13 with Conrey number 2 (a generator, so the character has order 12).
#include <flint/acb.h>
#include <flint/acb_dirichlet.h>
int main(void)
{
dirichlet_group_t G;
dirichlet_char_t chi;
acb_t s, eps;
acb_ptr L;
slong prec = 128;
acb_init(s);
acb_init(eps);
L = _acb_vec_init(2);
dirichlet_group_init(G, 4);
dirichlet_char_init(chi, G);
dirichlet_char_log(chi, G, 3);
acb_one(s);
acb_dirichlet_l(L, s, G, chi, prec);
flint_printf("L(1, chi_4) = "); acb_printn(L, 30, 0); flint_printf("\n");
dirichlet_char_clear(chi);
dirichlet_group_clear(G);
dirichlet_group_init(G, 13);
dirichlet_char_init(chi, G);
dirichlet_char_log(chi, G, 2);
acb_set_d(s, 0.5);
acb_dirichlet_l_jet(L, s, G, chi, 0, 2, prec);
flint_printf("L(1/2, chi) = "); acb_printn(L, 20, 0); flint_printf("\n");
flint_printf("L'(1/2, chi) = "); acb_printn(L + 1, 20, 0); flint_printf("\n");
acb_dirichlet_root_number(eps, G, chi, prec);
flint_printf("epsilon = "); acb_printn(eps, 20, 0); flint_printf("\n");
dirichlet_char_clear(chi);
dirichlet_group_clear(G);
acb_clear(s);
acb_clear(eps);
_acb_vec_clear(L, 2);
return 0;
}L(1, chi_4) = [0.785398163397448309615660845820 +/- 1.25e-31] L(1/2, chi) = [1.3468137049240637212 +/- 3.29e-20] + [0.75459682860501534409 +/- 4.17e-21]*I L'(1/2, chi) = [-0.038182523834367601160 +/- 3.96e-22] + [-0.45987153676368484477 +/- 3.13e-21]*I epsilon = [0.52216611241417884070 +/- 2.28e-21] + [0.85284380225587800538 +/- 3.36e-21]*I
The FLINT team, “Evaluating Dirichlet L-functions (acb_dirichlet.h),” FLINT: Fast Library for Number Theory, documentation, version 3.7.0-dev, 2026. https://flintlib.org/doc/acb_dirichlet/l-functions.html (generated 2026-11-02).
@misc{flint-doc-acb-dirichlet-l-functions,
author = {{The FLINT team}},
title = {{Evaluating Dirichlet L-functions (acb\_dirichlet.h)}},
howpublished = {FLINT: Fast Library for Number Theory, documentation, version 3.7.0-dev},
year = {2026},
url = {https://flintlib.org/doc/acb_dirichlet/l-functions.html},
note = {Generated 2026-11-02}
}