code / alex / psage / build / lib.linux-x86_64-2.7 / psage / modform / hilbert / sqrt5 / sqrt5_fast_python.py
241874 views1#######################################################################################2# Compute local splitting at 2 by successive lifting argument.3#######################################################################################4"""5This is on pages 9-10 of my research notes on 2010-11-07.67The mod-2 splitting must be done differently because I,J do *not*8generate the icosian ring over O_F, because of the 2's in the9denominator.1011The icosian ring has generators given above, call them w0,w1,w2,w3. Using linear algebra12we find that w0^2=w0-1, w1^2=-1, w2^2=-1, w3^2=-1. Moreover, and most importantly, we have13letting g=(1+sqrt(5))/2, that1415w0 = (g-1)*(2*g*w3 - w1 - w2 - w1*w2)16w3 = g*w0 + w2*w11718Thus mod 2, w0 and w3 are completely determined by w1 and w2.19Also, because of the 2 coefficient of w3 in the first equation,20modulo 2^i, w0 and w3 are completely determined if we know w1, w2, and w3 mod 2^(i-1).2122We have several functions below. The one called find_mod2_splitting iterates23through all of M_2(O/2O) finding the possibilities for w1 and w2, i.e., matrices24with square minus 1. For each, we let w0 and w3 be the corresponding matrices25given by the above formulas, verify that we get four independent matrices, and26that the minpoly conditions on w0 and w3 hold. We thus construct a matrix27algebra Alg over F_4 satisfying all the above relations, and get a map R -->> Alg.2829[[I have some worry though -- what if somehow not *all* the right relations hold?!]]3031Next we lift from mod p^(i-1) to mod p^i. This uses the following algebra.32Suppose A^2 = -1 (mod 2^(i-1)) and (A+2^(i-1)*B)^2 = -1 (mod 2^i).33Then A^2+2^(i-1)(AB+BA) + 2^(2(i-1))*B^2=-1 (mod 2^i).34Thus (-1+2^(i-1)*C) + 2^i*(AB+BA) = -1 (mod 2^i)35So we need C + AB + BA = 0 (mod 2), where C = (A^2+1)/2^i in Mat(O/2O).3637To find the B's with this property, we just loop through Mat(O/2O), and test38the condition C+AB+BA in Mat(O/2O).3940TODO: This implementation is slow. This is since matrix arithmetic is41generic, and generic matrix arithmetic is double dog slow (100 times42too slow). I think the algorithm itself is solid.43"""4445from sqrt5_fast import ResidueRing46from sage.matrix.all import MatrixSpace, matrix47from sqrt5 import F, B, icosian_ring_gens48from sage.misc.all import cached_function4950@cached_function51def find_mod2_splitting():52P = F.primes_above(2)[0]53k = P.residue_field()54M = MatrixSpace(k,2)55V = k**456g = k.gen() # image of golden ratio5758m1 = M(-1)59sqrt_minus_1 = [(w, V(w.list())) for w in M if w*w == m1]60one = M(1)61v_one = V(one.list())62for w1, v1 in sqrt_minus_1:63for w2, v2 in sqrt_minus_1:64w0 = (g-1)*(w1+w2 - w1*w2)65w3 = g*w0 + w2*w166if w0*w0 != w0 - 1:67continue68if w3*w3 != -1:69continue70if V.span([w0.list(),v1,v2,w3.list()]).dimension() == 4:71return w0, w1, w2, w37273def matrix_lift(A):74R = A.base_ring()75return matrix(A.nrows(),A.ncols(),[R.lift(x) for x in A.list()])7677@cached_function78def find_mod2pow_splitting(i):79P = F.primes_above(2)[0]80if i == 1:81R = ResidueRing(P, 1)82M = MatrixSpace(R,2)83return [M(matrix_lift(a).list()) for a in find_mod2_splitting()]8485R = ResidueRing(P, i)86M = MatrixSpace(R,2)87# arbitrary lift88wbar = [M(matrix_lift(a).list()) for a in find_mod2pow_splitting(i-1)]8990# Find lifts of wbar[1] and wbar[2] that have square -191k = P.residue_field()92Mk = MatrixSpace(k, 2)9394t = 2**(i-1)95s = M(t)9697L = []98for j in [1,2]:99C = Mk(matrix_lift(wbar[j]**2 + M(1)) / t)100A = Mk(matrix_lift(wbar[j]))101# Find all matrices B in Mk such that AB+BA=C.102L.append([wbar[j]+s*M(matrix_lift(B)) for B in Mk if A*B + B*A == C])103104g = M(F.gen())105t = M(t)106two = M(2)107ginv = M(F.gen()**(-1))108for w1 in L[0]:109for w2 in L[1]:110w0 = ginv*(two*g*wbar[3] -w1 -w2 - w1*w2)111w3 = g*w0 + w2*w1112if w0*w0 != w0 - M(1):113continue114if w3*w3 != M(-1):115continue116return w0, w1, w2, w3117118raise ValueError119120121122123124125