pds = load("../../ComputeLines/Scripts/Input/AllPds_signed_ordered_permutedCols.sobj") # A list of variables d_1, ..., d_6 for the coefficients ds = [var("d%s"%i) for i in range(1,7)] # A list of variables E_1, ..., E_6 Es = [var("E%s"%i) for i in range(1,7)] # A list of variables F_12, ..., F_56 Fs = [var("F%s%s"%(i,j)) for i in range(1,7) for j in range(1,7) if i < j] # A list of variables E_1, ..., E_6 Gs = [var("G%s"%i) for i in range(1,7)] # A list of variables X_12, ..., X_65 Xs = [var("X%s%s"%(i,j)) for i in range(1,7) for j in range(1,7) if i != j] # A list of variables Yoshida_0, ..., Yoshida_39 def VectorToYoshida(v): return prod([roots[i]^v[i] for i in range(0,len(v))]) Yoshidas = [var("Yoshida%s"%i) for i in range(0,40)] YM = load("../../Yoshida/Output/Yoshida_matrix.sobj") #Yoshidas = [VectorToYoshida(YM[i]) for i in range(0,40)] YRing = PolynomialRing(QQ, Yoshidas) YField = FractionField(YRing) # A list of variables Y_123456, ..., Y_162534 Ys = [var("Y%s%s%s%s%s%s"%(i,j,k,l,m,n)) for i in range(1,7) for j in range(1,7) for k in range(1,7) for l in range(1,7) for m in range(1,7) for n in range(1,7) if i values[1][0]: # monomial = values[1][1] else: monomial = values[1][1] #Could have picked either one linear_form = linear_form + e*monomial else: print "Got more than a binomial. Abort???" return linear_form # The previous function also works when there is a tie on the valuations and no cancellations on the valuations of the binomials, but fails when there is a cancellation (don't know what to expect in terms of valuations) # This function inputs a matrix with Yoshida coordinates and computes the matrix of expected valuations, not recording any potential ties. def tropical_matrix(pds, cone, keys): tropical_matrix = [[yoshida_to_trop_yoshida(pd[k], cone) for k in keys] for pd in pds] return tropical_matrix ############################################################################################ # Functions that incorporates "None" entries as an indication of an unknown true valuation # ############################################################################################ #The following function computes the true valuation of a polynomial in the Yoshida functions given the vector of valuations of the vector of valuations of the 40 Yoshida functions or returns "none" whenever the valuation cannot be determined due to ties on the terms with lowest valuation that could yield a cancellation of initial coefficients, and hence a higher valuation than the expected one for the binomial. # Input: c = product of yoshida monomials or binomials, cone is a polyhedron in whose interior the binomials have a definite min. # Output: linear function which tropicalizes c def yoshida_to_trop_yoshida_with_nones(c, cone): if c == 0: return +Infinity c = YField(expand(c)).factor() linear_form = 0 interior_point = sum([vector(r) for r in cone.rays()]) for (f,e) in c: if len(YRing(f).monomials()) == 1: linear_form = linear_form + e*f elif len(YRing(f).monomials()) == 2: values = [(interior_point[Yoshidas.index(m)], m) for m in YRing(f).monomials()] if values[0][0] < values[1][0]: monomial = values[0][1] elif values[0][0] > values[1][0]: monomial = values[1][1] else: # monomial = values[1][1] print "Not a definite sign " + str(YRing(f)) return None linear_form = linear_form + e*monomial else: print "Got more than a binomial. Abort???" return linear_form #This function inputs a matrix with Yoshida coordinates and computes the matrix of the corresponding valuations, only recording a value (real or infinity) whenever the valuation can be computed. Whenever there are ties that might lead to a potential cancellation and a non-expected valuation, we write "none" for the corresponding entry. def tropical_matrix_with_nones(pds, cone, keys): tropical_matrix = [[yoshida_to_trop_yoshida_with_nones(pd[k], cone) for k in keys] for pd in pds] return tropical_matrix ############################ # Functions for the Origin # ############################ origin = vector(ZZ,{39:0}) ############################################################################## # Functions that compute tropicalizations according to an expected valuation # ############################################################################## #The following function computes the expected valuation of a polynomial in the Yoshida functions given the vector of valuations of the vector of valuations of the 40 Yoshida functions. # Input: c = product of yoshida monomials or binomials, cone is a polyhedron in whose interior the binomials need not have a definite min. We record the binomials when there is a tie # Output: piecewise linear function which tropicalizes c (with respect to MIN) def yoshida_to_trop_yoshida_origin(c): if c == 0: return +Infinity c = YField(expand(c)).factor() linear_form = 0 interior_point = origin #sum([origin]) print interior_point for (f,e) in c: if len(YRing(f).monomials()) == 1: linear_form = linear_form + e*f elif len(YRing(f).monomials()) == 2: values = [(interior_point[Yoshidas.index(m)], m) for m in YRing(f).monomials()] if values[0][0] < values[1][0]: monomial = values[0][1] # elif values[0][0] > values[1][0]: # monomial = values[1][1] else: monomial = values[1][1] #Could have picked either one linear_form = linear_form + e*monomial else: print "Got more than a binomial. Abort???" return linear_form # The previous function also works when there is a tie on the valuations and no cancellations, but fails when there is a cancellation (don't know what to expect in terms of valuations) # This function inputs a matrix with Yoshida coordinates and computes the matrix of expected valuations, not recording any potential ties. def tropical_matrix_origin(pds, keys): tropical_matrix = [[yoshida_to_trop_yoshida_origin(pd[k]) for k in keys] for pd in pds] return tropical_matrix ############################################################################################ # Functions that incorporates "None" entries as an indication of an unknown true valuation # ############################################################################################ #The following function computes the true valuation of a polynomial in the Yoshida functions given the vector of valuations of the vector of valuations of the 40 Yoshida functions or returns "none" whenever the valuation cannot be determined due to ties on the terms with lowest valuation that could yield a cancellation of initial coefficients, and hence a higher valuation than the expected one for the binomial. # Input: c = product of yoshida monomials or binomials, cone is a polyhedron in whose interior the binomials have a definite min. # Output: linear function which tropicalizes c def yoshida_to_trop_yoshida_with_nones_origin(c): if c == 0: return +Infinity c = YField(expand(c)).factor() linear_form = 0 interior_point = origin for (f,e) in c: if len(YRing(f).monomials()) == 1: linear_form = linear_form + e*f elif len(YRing(f).monomials()) == 2: values = [(interior_point[Yoshidas.index(m)], m) for m in YRing(f).monomials()] if values[0][0] < values[1][0]: monomial = values[0][1] elif values[0][0] > values[1][0]: monomial = values[1][1] else: # monomial = values[1][1] print "Not a definite sign " + str(YRing(f)) return None linear_form = linear_form + e*monomial else: print "Got more than a binomial. Abort???" return linear_form #This function inputs a matrix with Yoshida coordinates and computes the matrix of the corresponding valuations, only recording a value (real or infinity) whenever the valuation can be computed. Whenever there are ties that might lead to a potential cancellation and a non-expected valuation, we write "none" for the corresponding entry. def tropical_matrix_with_nones_origin(pds, keys): tropical_matrix = [[yoshida_to_trop_yoshida_with_nones_origin(pd[k]) for k in keys] for pd in pds] return tropical_matrix