Advanced maths

Dedekind sum calculator with reciprocity verification

Classical Dedekind sums combine two sawtooth residue sequences into an exact rational value.

Your numbers

Calculated on your device. Your inputs aren’t sent to us.

Your result

Ready when you are

Enter your inputs and select Calculate.

Report an issue

Behind the numbers

How this calculation works

Classical Dedekind sums combine two sawtooth residue sequences into an exact rational value. This calculator uses the convention that the sawtooth function vanishes at integers, computes the finite sum and checks the classical reciprocity relation when the arguments are coprime. Noncoprime inputs remain valid sums without an invalid reciprocity claim.

THE FORMULAs(h,k)=Σ_(r=1)^(k−1) ((r/k))((hr/k)); ((integer))=0.

A worked example

For s(1,3), the two nonzero sawtooth values are −1/6 and 1/6. Their squared products sum to 1/36+1/36=1/18. The reversed sum s(3,1) is zero, and the coprime reciprocity right-hand side also equals 1/18.

Good to know

Positive integer h,k≤50,000, exact rational arithmetic. Reciprocity requires gcd(h,k)=1 and is omitted otherwise. This page uses classical rather than generalized or shifted Dedekind sums. Conventions at integer sawtooth arguments are explicitly fixed.

The sawtooth value at an integer is special

For a noninteger argument, the classical sawtooth is its fractional part minus one half. At an integer, its value is zero rather than minus one half. That convention affects terms when the numerator argument and denominator share factors, so it cannot be ignored simply because the coprime worked example has no such interior integer products.

The sum runs over denominator residues one through k minus one. Reducing the multiplied residue modulo k makes periodicity explicit and allows each product to be written with one common rational denominator. No trigonometric approximation or floating-point fractional-part test is needed to evaluate the supported classical sum.

Two sawtooth products give Dedekind sum one eighteenthr=1: (−1/6)²r=2: (1/6)²s(1,3) = 1/36 + 1/36 = 1/18s(3,1) = 0Coprime reciprocity verified exactly
For s(1,3), the two nonzero sawtooth values are −1/6 and 1/6. Their squared products sum to 1/36+1/36=1/18. The reversed sum s(3,1) is zero, and the coprime reciprocity right-hand side also equals 1/18.

The Floor sum calculator for arithmetic progressions covers the nearby task. A Dedekind sum multiplies sawtooth residues and has its own reciprocity law, beyond summing affine floors.

Residue arithmetic gives a rational answer

The numerator is accumulated as a big integer and then reduced to a canonical rational fraction. A displayed zero is therefore an exact cancellation, not a small decimal rounded away. Positive arguments are bounded so the direct finite sum remains manageable even when several terms cancel to a much smaller final value.

Changing h by a multiple of k preserves the residue-based sum, which is a useful independent test. The reciprocal expression, however, uses the actual positive arguments in its rational formula. The implementation handles those conventions consistently rather than comparing a partially reduced argument pair with a mismatched reciprocity right-hand side.

Reciprocity has a coprimality condition

Classical reciprocity in the printed form requires coprime positive h and k. The page verifies that condition before evaluating the reversed sum and asserting the identity. Noncoprime arguments still have a valid finite Dedekind sum, but they do not receive an unsupported coprime reciprocity certificate.

The 1,3 example exposes every term and its exact rational reduction. Reference tests compare direct residue products, established Dedekind-sum routines and valid reciprocity cases, including denominator one. Generalized shifted sums, signed-denominator extensions and modular-form applications require additional conventions and are not implied by this classical calculator.

Fix the sawtooth convention at integers

The classical sum is s(h,k)=Σr=1..k−1 ((r/k))((hr/k)), where ((x)) is fractional_part(x)−1/2 for nonintegers and zero at integers. That special integer value matters when h and k are not coprime. Replacing it everywhere by fractional_part(x)−1/2 would produce a different sum.

All calculations here use exact fractions. The parameter h can be reduced modulo k inside the periodic second factor without changing s(h,k), but the displayed positive arguments are also used for the reciprocity comparison when coprime. Keep the definition and input domain with the result when comparing tables of generalized or shifted Dedekind sums.

Evaluate s(1,3) and s(2,5) explicitly

For s(1,3), the two sawtooth values are −1/6 and 1/6. Their squares add to 1/36+1/36=1/18. This is the default rational result. For s(2,5), the r/k values give sawtooths −3/10,−1/10,1/10,3/10; the second factor gives −1/10,3/10,−3/10,1/10.

The four products are 3/100,−3/100,−3/100,3/100, which sum to zero. A zero answer can therefore reflect exact cancellation rather than an empty sum. For k=1 the summation range is empty and the result is zero for that different reason.

Verify reciprocity using exact rational arithmetic

For positive coprime h,k, reciprocity states s(h,k)+s(k,h)=−1/4+(h/k+k/h+1/(hk))/12. With h=1,k=3, s(3,1)=0 and the right side is −1/4+(1/3+3+1/3)/12=1/18, matching the direct sum.

With h=1,k=5, the right side is −1/4+(1/5+5+1/5)/12=1/5. These identities provide a second route to a value, but the coprimality condition is essential. If gcd(h,k)>1, the form still evaluates the defining sum and explicitly omits this classical reciprocity assertion.

Use symmetry without confusing variants

Changing h to h+k leaves the classical sum unchanged, while replacing h by its negative changes the sign under the same convention. For positive representatives, s(k−h,k)=−s(h,k). Such identities are useful checks on an implementation and explain why the values need not be positive.

Dedekind sums occur in deeper reciprocity and modular-form formulas, but this page computes only the finite classical definition and its stated reciprocity check. It does not evaluate an eta multiplier, generalized sum or modular transformation automatically. A decimal approximation can conceal exact zero or a small fraction, so retain the returned rational form when doing subsequent symbolic work.

A few questions, answered

What is the sawtooth at an integer?

Zero in this classical convention, rather than minus one half.

Is reciprocity asserted for noncoprime arguments?

No. The sum is computed but the coprime identity is not applied.

Does a noncoprime input make the sum undefined?

No. The finite classical sum remains defined. The particular coprime reciprocity identity is simply not asserted.

Why is the sawtooth zero at an integer?

That is the classical convention used here. Omitting the integer exception changes terms for noncoprime arguments and can change the result.

Find your calculator

Start typing to explore the library.