Suppose I am given a machine that gives me the coefficients $a_1$, $a_2$, $a_3$, ... of a Dirichlet series $$\sum_1^{\infty} \frac{a_n}{n^s} $$ and assume that I know that this Dirichlet series is the Dedekind zeta function of a quadratic number field. Is there any kind of algorithm which allows me to determine whether the number field is real or imaginary?

2$\begingroup$ Not clear what you mean by an algorithm here. What is the input size? For example, you could divide your series by zeta, and get a Dirichlet Lfunction and then check to see if you can identify the period of those coefficients etc. Sounds like an interesting question, but it might need to be made more precise. $\endgroup$ – Lucia Feb 28 '16 at 15:53

8$\begingroup$ If you know the zetafunction of a number field $K$ "in full" then yes: this function knows the number of real and complex (i.e., nonreal) embeddings of $K$. Calling these $r_1$ and $2r_2$, the order of vanishing of $\zeta_K(s)$ at a negative integer $n$ is $r_2$ if $n$ is odd and $r_1 + r_2$ if $n$ is even. The order of vanishing at 0 is $r_1 + r_2  1$. In particular, if $K$ is quadratic then $\zeta_K(s)$ is nonzero at negative odd integers for real $K$ and it is zero at negative odd integers for imaginary $K$. Also $\zeta_K(0) = 0$ for real $K$ and $\zeta_K(0) \not= 0$ for imaginary $K$. $\endgroup$ – KConrad Feb 28 '16 at 15:53

3$\begingroup$ Sure, if you somehow give me access to values of $\zeta_K$ then I can do it, but the machine described by Andreas Holmstrom only spits out the coefficients one at a time. $\endgroup$ – Noam D. Elkies Feb 28 '16 at 15:55

$\begingroup$ @KConrad, thanks for the answer, but even if I can compute values of $\zeta_K$, I cannot know for sure that the value at 0 is precisely 0 and not, say $2^{500}$. Or do we have some additional knowledge about zeta functions of quadratic number fields which implies that if the value is smaller than some bound $b$, then it really is equal to zero? $\endgroup$ – Andreas Holmstrom Feb 28 '16 at 16:14

$\begingroup$ But maybe two values on either side of a negative even integer would work? If I compute say $\zeta_K(1.9)*\zeta_K(2.1)$, this should be strictly positive if K is real and strictly negative if K is imaginary. And in principle I can use interval arithmetic to know for sure which case we're in. But if I really want to do this, is it not a problem that I do not know the form of the functional equation? $\endgroup$ – Andreas Holmstrom Feb 28 '16 at 16:29
Not without an upper bound on the absolute value of the discriminant $\Delta$, because any finite list of $a_n$ amounts to a congruence condition on $\Delta$ that is satisfied by infinitely many $\Delta$ of either sign.

$\begingroup$ Thanks Noam! So if I have an upper bound B on the discriminant, how do I actually determine whether the field is real or imaginary? And is it possible to express (in terms of B) how many a_n (or how many Euler factors) I need? $\endgroup$ – Andreas Holmstrom Feb 28 '16 at 16:07

2$\begingroup$ Will Sawin addressed the "how many $a_n$" question. Under the RH for Dirichlet Lfunctions, there are much better bounds on the least quadratic nonresidue, and possibly there may be a much more efficient algorithm using partial Euler products to approximate values of $L(s,\chi)$ and decide which kind of function equation it satisfies. $\endgroup$ – Noam D. Elkies Feb 28 '16 at 20:31

$\begingroup$ [too late to edit: which kind of functional equation it satisfies.] $\endgroup$ – Noam D. Elkies Feb 29 '16 at 4:06
Asking in terms of $B$ how many $a_n$ are needed is equivalent to asking the following question:
What is the largest $N$ such that there exists two quadratic characters $\chi_1, \chi_2$ of conductor $<B$ with $\chi_1(n)=\chi_2(n)$ for $n<N$ but $\chi_1(1)\neq \chi_2(1)$?
An obvious approach is to note that then $\chi= \chi_1 \chi_2^{1}$ is a character of conductor $<B^2$ with $\chi(n)=1$ for $n<m$, which by the bound for the least quadratic nonresidue problem can only happen for $n< \left(B^2\right)^{1/4\sqrt{e}+o(1)}=B^{1/2\sqrt{e}+o(1)}$
Of course any improvement on this problem would also represent improvement on the least quadratic nonresidue problem, at least for residues modulo primes congruent to $3$ modulo $4$.
Given this many you could perform the algorithm of enumerating all the characters of conductor $<B$ and seeing which agree with your sequence.
The only efficient algorithm I see requires $B$ coefficients  you simply look to see for which primes $\chi(p)$ is $0$ (or $a_p$ is $0$ for the Dirichlet $L$function). These are precisely the ramified primes. If you check up to $B$ you find all the ramified primes. Knowing the ramified primes determines the Dirichlet character up to multiplication by a Dirichlet character modulo $8$, since $2$ is the only prime that can be ramified in multiple different ways. Simply check the four possibilities to see which one matches the first few coefficients of your sequence.