02-26-2024, 02:28 PM
Definition
The Dedekind Sum is defined as follows:
Let P and Q be relatively prime integers, that is GCD(P, Q) = 1.
Then S is the Dedekind sum as:
S = Σ( ((I ÷ Q)) × ((P × I ÷ Q)), for I=1 to Q)
The double parenthesis around the terms I ÷ Q and P × I ÷ Q signify a custom function:
(( X )) =
0, if X is an integer
X – FLOOR(X) – 1/2, if X is not an integer
If X is positive, X – INTG(X) – 1/2
HP Prime: DEDEKIND
P = 2, Q = 17: 0.4705882353
P =14, Q = 57: -0.8187134503
Sources
Shipp, R. Dale. “Table of Dedekind Sums” Journal of Research of the National Bureau of Standards-B. Mathematics and Mathematical Physics Vol. 69B, No 4, October-December 1965 https://nvlpubs.nist.gov/nistpubs/jres/6...59_A1b.pdf
Retrieved February 21, 2024
Weisstein, Eric W. "Dedekind Sum." From MathWorld--A Wolfram Web Resource. https://mathworld.wolfram.com/DedekindSum.html
Retrieved February 18, 2024
The Dedekind Sum is defined as follows:
Let P and Q be relatively prime integers, that is GCD(P, Q) = 1.
Then S is the Dedekind sum as:
S = Σ( ((I ÷ Q)) × ((P × I ÷ Q)), for I=1 to Q)
The double parenthesis around the terms I ÷ Q and P × I ÷ Q signify a custom function:
(( X )) =
0, if X is an integer
X – FLOOR(X) – 1/2, if X is not an integer
If X is positive, X – INTG(X) – 1/2
HP Prime: DEDEKIND
Code:
EXPORT DEDEKIND(p,q)
BEGIN
// 2024-02-21 EWS
LOCAL s,i,a,b;
// Calculation
IF CAS.gcd(p,q)==1 THEN
s:=0;
FOR i FROM 1 TO q DO
a:=i/q;
IF FP(a)==0 THEN
a:=0;
ELSE
a:=a-FLOOR(a)-0.5;
END;
b:=p*i/q;
IF FP(b)==0 THEN
b:=0;
ELSE
b:=b-FLOOR(b)-0.5;
END;
s:=s+a*b;
END;
RETURN s;
ELSE
RETURN "p and q are not relatively prime.";
END;
END;
P = 2, Q = 17: 0.4705882353
P =14, Q = 57: -0.8187134503
Sources
Shipp, R. Dale. “Table of Dedekind Sums” Journal of Research of the National Bureau of Standards-B. Mathematics and Mathematical Physics Vol. 69B, No 4, October-December 1965 https://nvlpubs.nist.gov/nistpubs/jres/6...59_A1b.pdf
Retrieved February 21, 2024
Weisstein, Eric W. "Dedekind Sum." From MathWorld--A Wolfram Web Resource. https://mathworld.wolfram.com/DedekindSum.html
Retrieved February 18, 2024