## Which DirichletCharacter is KroneckerSymbol?

5

2

If $d$ is a fundamental discriminant, KroneckerSymbol[d,n] is a Dirichlet character modulo $|d|$. Which one is it? If $d>0$ is a prime $\equiv 1\bmod 4$, then it's DirichletCharacter[d,(d+1)/2,n], and similarly if $d<0$, with prime $-d\equiv 3\bmod 4$ it is DirichletCharacter[-d,(1-d)/2,n].

In general, there is a function which, on input a fundamental discriminant $d$ outputs $j$ such that KroneckerSymbol[d,n] is equal to DirichletCharacter[Abs[d],j,n] for all $n$ relatively prime to $|d|$. The ability to compute such $j$ easily would allow one to use the built in DirichletL to compute the Dirichlet series attached to the Kronecker symbol.

Of course one can build a table of values of KroneckerSymbol[d,n] and of all DirichletCharacter[Abs[d],k,n] for k=1,2,... EulerPhi[Abs[d]], and then look for a match. I'm looking for something smarter and more efficient than that, for use with large composite d.

1A warning note for anyone working on this. The documentation for DirichletCharacter[] (version 8) reads "Real Dirichlet characters modulo $k$ have index $1$ or $\phi(k)/2+1$." THIS IS FALSE. There are $4$ Dirichlet characters modulo $8$ and all of them are real. It looks like the true statement is that the Dirichlet characters of index $1$ and $\phi(k)/2+1$ are real, but so are some other ones. (Run Table[DirichletCharacter[8, j, Range[8]], {j, 1, 4}] if you'd like to see for yourself.) – David E Speyer – 2013-03-12T16:11:45.317

Does this help? (It's documentation from version 9. A colleague suggested it might apply.)

– Daniel Lichtblau – 2013-03-12T21:00:40.657

I think the thing that confuses me, being a long way removed from number theory, is that you seem to answer your own question? Or are you looking for something like DirichletCharacter[Abs[d], (1 + Abs[d])/2, n]? – Brett Champion – 2012-03-05T04:14:48.577

9

I wrote this answer as I was figuring things out. If you just want the answer, copy the definitions of fundQ, Ast, ksFactors, foo, makeOneIndex and magicJ out of the code blocks below. You should have

DirichletCharacter[d, magicJ[d], n] == KroneckerSymbol[d, n]


Disclaimer 1: This answer is based on plausible interpretations of things not quite said in the DirichletCharacter documentation and tested for $-120 \leq d \leq 120$. To be sure it's right, you would have to actually look inside DirichletCharacter or find better documentation.

Disclaimer 2: $\newcommand{\KS}[2]{\left( \frac{#1}{#2} \right)}$ The set up of this question assumes that $d$ is a fundamental discriminant. I really need that. For $s$ odd, we have $\KS{-1}{2^b s} = (-1)^{(s-1)/2}$, so $\KS{-1}{n}$ is not periodic in $n$, and DirichletCharacter[k,j,n] is always periodic modulo $k$. So not all Kronecker symbols can be expressed as Dirichlet characters. Fortunately, the fundamental discriminants can. If you run magicJ[] on something which is not a fundamental discriminant, it objects. If you run the internal helper functions on something which is not a fundamental discriminant, I make no promises as to what will happen.

Here is a function to test whether $d$ is a fundamental discriminant:

fundQ[d_] := Switch[Mod[d, 4], 1, SquareFreeQ[d],
0, SquareFreeQ[d/4] && (Mod[d/4, 4] == 2 || Mod[d/4, 4] == 3),
_,  False]

discs = Select[Range[-120, 120], fundQ]
(* Out={-120, -119, -116, -115, -111, -107, -104, -103, -95, -91, -88, -87,
-84, -83, -79, -71, -68, -67, -59, -56, -55, -52, -51, -47, -43, -40,
-39, -35, -31, -24, -23, -20, -19, -15, -11, -8, -7, -4, -3, 1, 5, 8,
12, 13, 17, 21, 24, 28, 29, 33, 37, 40, 41, 44, 53, 56, 57, 60, 61,
65, 69, 73, 76, 77, 85, 88, 89, 92, 93, 97, 101, 104, 105, 109, 113, 120}


For any odd prime $p$, define $p^{\ast} = (-1)^{(p-1)/2} p$. Let $d = u 2^b (p_1^{\ast})^{a_1} (p_2^{\ast})^{a_2} \cdots (p_r^{\ast})^{a_r}$ with $u = \pm 1$ and $p_i$ distinct odd primes listed in increasing order. If $d$ is a fundamental discriminant then all the $a_i$ are $1$ and $u 2^b$ is one of $1$, $-4$, $8$ or $8$ so we will assume this from now on.

Here is some code to perform the above computations

 Ast[p_] := (-1)^((p-1)/2) p;

ksFactors[d_] :=
If[fundQ[d], Module[{facts = FactorInteger[d], primes},
primes =Map[Ast, Select[Map[First, facts], (# != -1 && # != 2)&]];
Prepend[primes, d/Product[p, {p, primes}]]],
"Error: Not a fundamental discriminant"]

ksFactors[120]
(* Out={-8,-3,5} *)


Then we have $$\KS{d}{n} = \KS{u 2^b}{n} \prod \KS{p_i^{\ast}}{n}^{a_i}$$

For any odd prime $p$, the character $\KS{p^{\ast}}{n}$ is the unique nontrivial real Dirichlet character modulo $|p|$. According to the documentation, the real characters modulo $p$ will be in positions $1$ and $\phi(p)/2+1$, and the one in position $1$ will be trivial.

Actually, the documentation (version 8) says "Real Dirichlet characters modulo k have index $1$ or $\phi(k)/2+1$", which would seem to say that those are the only two real Dirichlet characters. That can't be true since, in many cases, there are more than two real Dirichlet characters. However, it does appear to be true that the characters in those positions are always real.

In any case, when $p$ is prime, there is only one nontrivial real Dirichlet character, namely $\KS{p^{\ast}}{n}$, and it appears in index $\phi(p)/2+1$. Also, for $p$ prime, $\phi(p)/2+1$ simplifies to $(p+1)/2$. Let's check that we're right so far:

Table[KroneckerSymbol[Ast[p], Range[4p]] == DirichletCharacter[p,(p+1)/2,Range[4p]],
{p,Prime[Range[2,20]]}]]

(* Out = {True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True} *)


Now, let's deal with the $\KS{u 2^b}{n}$ term. By trial and error, I found

KroneckerSymbol[1,n]==DirichletCharacter[1,1,n]
KroneckerSymbol[-4,n]==DirichletCharacter[4,2,n]
KroneckerSymbol[-8, n] == DirichletCharacter[8, 4, n]
KroneckerSymbol[8, n] == DirichletCharacter[8, 2, n]


Let's define a function to handle what we know so far

foo[x_] :=
If[PrimeQ[Abs[x]] && Mod[x, 4] == 1, {Abs[x], (Abs[x] + 1)/2}];
foo[1] = {1, 1};
foo[-4] = {4, 2};
foo[-8] = {8, 4};
foo[8] = {8, 2};

map[foo, ksFactors[120]]
(* Out = {{8, 4}, {3, 2}, {5, 3}} *)

thing1 = Table[DirichletCharacter[8, 4, n]*DirichletCharacter[3, 2, n]*DirichletCharacter[5, 3, n], {n, 1, 120}];

thing2 = KroneckerSymbol[120, Range[120]];

thing1 == thing2
(* Out = True *)


We now need to combine all of those DirichletCharacters into a single term.

Look at the documentation of DirichletCharacter and scroll down to the portion of Properties and Relations beginning "A character modulo $k$ can be written as a product of characters modulo prime powers...". I've cut off the last bit of the quote because it is misleading; they say "prime powers of $k$" but they mean "prime power factors of $k$".

The documentation doesn't quite say the following, but it appears to be true: If $d=\prod_{i=1}^r p_i^{a_i}$, where the $p_i$ are primes listed in increasing order, and $$j = 1+\sum_{i=1}^r (j_i-1) \cdot \phi\left( \prod_{k=i+1}^r p_i^{a_i} \right)$$ then DirichletCharacter[d,j,n] is the product of the terms DirichletCharacter[p[i]^a[i], j[i],n].

Let's write some code to do this:

makeOneIndex[jList_] :=
1 + Sum[
(Last[jList[[i]]] - 1)*
EulerPhi[Product[
First[jList[[k]]],
{k, i + 1, Length[jList]}]],
{i, 1, Length[jList]}]

magicJ[d_]:=
If[fundQ[d], makeOneIndex[Map[foo, ksFactors[d]]], "Not a fundamental discriminant"]


And let's test it:

Table[DirichletCharacter[d, magicJ[d], Range[d]] == KroneckerSymbol[d, Range[d]], {d, discs}]

(* Out = {True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True} *)


Thank you for putting the time into this; I really appreciate it! – stopple – 2013-03-12T19:41:56.557