Illustrations from the argument that τ(χ)τ((OverBar[χ]))=χ(-1)N for a primitive character

Multiplicative character, primitive mod 15

chi[n_]:=Module[
{c1,c2},
c1=Switch[Mod[n,3],
0,0,
1,1,
2,-1];
c2=Switch[Mod[n,5],
0,0,
1,1,
2,I,
3,-I,
4,-1];
c1 c2];
chibar[n_]:=Conjugate[chi[n]];
(*For[n=0,n<15,n++,Print[n,"  ",chi[n]]];*)

Gauss sum of the character, modulus 15c: nonzero for c=1, zero for c>1 because the character is no longer primitive

c=1;
M=15c;

tau[chi]:=Sum[chi[n]Exp[2Pi I n/M],{n,0,M-1}];
tau[chibar]:=Sum[chibar[n]Exp[2Pi I n/M],{n,0,M-1}];

Print["τ(χ) = ",tau[chi]];
Print["τ(χ) = ",FullSimplify[tau[chi]]];
Print["τ((OverBar[χ])) = ",tau[chibar]];
Print["τ((OverBar[χ])) = ",FullSimplify[tau[chibar]]];

Print["τ(χ)τ((OverBar[χ])) = ",FullSimplify[tau[chi]tau[chibar]]];

Print["χ(-1)",M," = ",chi[-1]M];

Both versions of τ(χ)τ((OverBar[χ])) work, but summing over all of Z/NZ is amenable to the orthogonality of the additive characters

Two versions of the inner sum

M=15;s1[m_]:=Sum[Exp[2Pi I(m+1)n/M],{n,0,M-1}];
s2[m_]:=Sum[If[GCD[n,M]===1,Exp[2Pi I(m+1)n/M],0],{n,0,M-1}];

The two inner sums are not the same, but the two double sums are

Print["Values of first sum, second sum, weighted second sum"];
For[m=0,m<M,m++,
If[GCD[m,M]===1,
Print[m,":  ",FullSimplify[s1[m]],",  ",FullSimplify[s2[m]],",  ",chi[m]FullSimplify[s2[m]]]
]
];
t1:=Sum[chi[m]s1[m],{m,0,M-1}];
t2:=Sum[If[GCD[m,M]===1,chi[m]s2[m],0],{m,0,M-1}];

Print["First double sum: ",FullSimplify[t1]];
Print["Second double sum: ",FullSimplify[t2]];