/**************************************************************************
thickness.m
William Stein
December 12, 1999

There is a computation that might be easy for you to make, that might
shed light on whether or not the topological closure of the set of modular
Galois representations (in the universal deformation space) contains an
open set. Tell me whether or not this is feasible. Start, say, with the
Fourier expansion mod 3 of the newform of weight two of level 11 (call it
w) but I want to ignore the Euler factor at 3, i.e., I want to ignore the
Fourier coefficents a_n where n is divisible by 3. Now look for eigenforms
of arbitrary weight, of level 33, whose Fourier coefficients are in Z_3 and
are congruent to those of w modulo 3 (ignoring the Fourier coefficents a_n
where n is divisible by 3). Every time you find one, RECORD its Fourier
expansion modulo 9 (again ignoring the Fourier coefficents a_n where n is
divisible by 3). Count the number of these ( Fourier expansion modulo 9
ignoring the Fourier coefficents a_n where n is divisible by 3)  that you
get. Do you get 27 of them?

***********************************************************************/

/*
Step 1: Start, say, with the
Fourier expansion mod 3 of the newform of weight two of level 11 (call it
w) but I want to ignore the Euler factor at 3, i.e., I want to ignore the
Fourier coefficents a_n where n is divisible by 3.
*/

prec := 37;
"Precision: ", prec;

: n in [1..Degree(g)]];
end function;

"w = ", w;

/*
Step 2:  Now look for eigenforms
of arbitrary weight, of level 33, whose Fourier coefficients are in Z_3 and
are congruent to those of w modulo 3 (ignoring the Fourier coefficents a_n
where n is divisible by 3).
*/

function ValPrimeTo(f,p)
if f eq 0 then
return 99999999999;
end if;
v, pos := Min([Valuation(Coefficient(f,i)) : i in [1..Degree(f)]
| (i mod p ne 0) and Valuation(Coefficient(f,i)) ne 0]);
return v;
end function;

function IsCongruentToW(f)
return ValPrimeTo(f-w,3) ge 1;
end function;

function pDeprive(f,p)
R<q> := Parent(f);
for i in [1..Ceiling(Degree(f)/3)] do
f -:= Coefficient(f,3*i)*q^(3*i);
end for;
return f;
end function;

function Level33Search(k1, k2)
R9 := PowerSeriesRing(Integers(9));
RZ := PowerSeriesRing(Integers());
nearby_forms := [R9|];
for k in [w : w in [k1..k2] | IsEven(w)] do
"k = ",k;
v := ZpRationalNewforms(11,k,3,prec)
cat ZpRationalNewforms(33,k,3,prec);
"v = ", v;
for f in v do
if IsCongruentToW(f) then
g := pDeprive(R9!(RZ!f),3);
Append(~nearby_forms, g);
"g = ",g;
end if;
end for;
end for;
return nearby_forms;
end function;