fmpq_dedekind_sum, fmpq_dedekind_sum_naive
#include <flint/fmpq.h>Set s to s(h, k), for any integers h and k. The naive version evaluates the defining sum with k terms. fmpq_dedekind_sum uses the continued fraction of k/h and costs about as much as an extended GCD.
By the reciprocity law s(h,k) + s(k,h) = (h/k + k/h + 1/(hk))/12 - 1/4 for coprime h, k > 0, the sum telescopes along the Euclidean algorithm [Hickerson1977]. With the partial quotients a_1, \ldots, a_n of k/(h \bmod k), the convergent matrix \prod_i \left(\begin{smallmatrix} a_i & 1 \\ 1 & 0 \end{smallmatrix}\right) = \left(\begin{smallmatrix} m_{11} & m_{12} \\ m_{21} & m_{22} \end{smallmatrix}\right) and the alternating sum t = a_1 - a_2 + \cdots \pm a_n,
The function evaluates this in machine words when k fits in a slong and with the half-GCD continued fraction code otherwise. Writing s(h,k) = p/q in lowest terms, |s| < k/12 and q \mid 6k.
References#
- [Hickerson1977] D. Hickerson, "Continued fractions and density results for Dedekind sums", Journal für die reine und angewandte Mathematik 290 (1977), 113–116.
The FLINT team, “fmpq_dedekind_sum, fmpq_dedekind_sum_naive (fmpq.h),” FLINT: Fast Library for Number Theory, documentation, version 3.7.0-dev, 2026. https://flintlib.org/doc/fmpq/fmpq_dedekind_sum.html (generated 2026-10-20).
@misc{flint-doc-fmpq-fmpq-dedekind-sum,
author = {{The FLINT team}},
title = {{fmpq\_dedekind\_sum, fmpq\_dedekind\_sum\_naive (fmpq.h)}},
howpublished = {FLINT: Fast Library for Number Theory, documentation, version 3.7.0-dev},
year = {2026},
url = {https://flintlib.org/doc/fmpq/fmpq_dedekind_sum.html},
note = {Generated 2026-10-20}
}