Extensions of number fields which are unramified at all finite primes Let $k$ be a totally real number field of degree $n$. 
I'd like to know how I can determine whether or not there exists a quadratic field extension $L$ of $k$ such that the extension $L/k$ is unramified at all finite primes and ramified at only at $n-1$ of the real primes of $k$. I assume that this can be determined by class field theory. For the application that I have in mind however, I'm going to need a computer algebra system like sage to be able to explicitly perform this test. How explicit can this be made?
Thanks.
 A: As you say, in principle the existence of such an extension can be determined using class field theory. There exists an extension of the type you need if and only if for some set $T$ consisting of $n-1$ real places, the ray class group modulo $T$ has order divisible by 2.
I don't know about sage, but ray class groups can be computed in MAGMA. Now, Magma costs money, but they have an online calculator for short computations, so if your field isn't too big, that might suffice for your purposes.
If you need more flexible solutions, it might be worth writing your own programs in some fast and powerful language, like C. A detailed discussion of algorithms for computing ray class groups can be found in H. Cohen, Advanced Topics in Computational Number Theory, GTM 193.
A: In pari/gp (probably built into sage somehow).
poly=x^7 - x^6 - 12*x^5 + 7*x^4 + 28*x^3 - 14*x^2 - 9*x - 1;
/* The roots of this polynomial define the degree 7 subfield K of Q(zeta_29).
*/
nf=nfinit(poly); /* This defines the number field K */
bnf=bnfinit(nf); /* This computes data associated to the number field K, like the unit group.*/
bnfcertify(bnf) /* This checks that the output of bnf is correct, and doesn't depend on GRH. The output should be $1$ */
bnrclass(bnf,[1,[1,1,1,1,1,1,0]]) /* This computes the ray class group of conductor m, where m has trivial finite place and contains 6 of the 7 infinite places. */
