Fourier Series involving the Jacobi Symbol We know that the Fourier Series $$s(x)=\sum_{k\neq0}\frac{1}{k}\exp\left(2\pi ik x\right)$$ corresponds to the sawtooth function, $s(x)=\left\{x\right\} -\frac{1}{2}$.  Suppose that $\left(\frac{k}{d}\right)$ is the Jacobi Symbol, which is zero when $(d,k)>1$.  

My question is: What is the function $f_d(x)$ corresponding the the Fourier Series $$f_d(x)=\sum_{k\neq0}\left(\frac{k}{d}\right)\frac{1}{k}\exp\left(2\pi ikx\right),$$ and how can we find this function?

Thank you,
 A: For any primitive character $\chi$ mod $N$, the finite sum $\sum_{a\;mod\;N} \;\chi(a)\,s(x+{a\over N})$ produces your sum, multiplied by the corresponding Gauss sum.
Edit: in response to comment/question, I don't think there is a simpler expression for the sum over $a$ mod $N$, exactly because of the assumption that the character has conductor $N$. In the opposite case(s), e.g., that the character $\chi$ is trivial, indeed there is cancellation. But with the primitivity assumption, the riff is that $\sum_a \chi(a)\,e^{2\pi i na/N} = \overline{\chi}(n)\,\sum_a \chi(a)\,e^{2\pi i a/N}$ for $n$ prime to $N$. In fact, since for (odd!) quadratic characters this essentially gives the class number (by computing $L(1,\chi)$, any serious simplification would have to give striking new information on class numbers, which is a non-trivial issue (see Siegel, Heegner, Stark, Goldfeld, et alia).
Further edit: yes, indeed, setting $x=0$ in the Fourier expansion literally gives (up to some constants and normalizations) $L(1,\chi)$ for odd $\chi$. We must believe that the Fourier series converges pointwise away from the discontinuities at integers, and it does: the usual Dirichlet kernel argument proves convergence for finitely-piecewise continuous functions at points where the function is once-continuously-differentiable. 
Edit: @J.M., about whether the quadratic symbol should be a Jacobi symbol or Kronecker, ... the real point is that $k\rightarrow (k/d)_2$ should be a primitive character mod $N$. So, no, the "d" need not be prime (which is the earlier, "Jacobi" sense), but can be composite (the later, "Kronecker" sense).
