def toPolynom(self,n):
        """
        Return a couple compoosed by a polynomial ring and the polynomial
        equal to the truncated series of degree n-1

        EXAMPLES::
            
           sage: 
           sage: L = u+v^2+3*w*z+w^2+u*v*z*w+u^2*v+w*z^4+v^6
           sage: (PolRing,PolL) = L.toPolynom(3)
           sage: PolL
           v^2 + w^2 + 3*w*z + u
           sage: PolRing
           Multivariate Polynomial Ring in u, v, w, z over Rational Field
        """        
        if n>0:
            from sage.rings.polynomial.all import PolynomialRing
            BR=self.parent().base_ring()
            R = PolynomialRing(BR,self.parent()._names)
            v = R.gens()
            pol = R(0)
            for i in range(n):
                l = self.coefficient(i)
                for (e,t) in l:
                    pol += e*reduce((lambda a,b:a*b),map((lambda a,b:a**b),v,t))
            return R,pol
        else:
            raise ValueError, "n must be a nonnegative integer"
Exemplo n.º 2
0
def compute_bd(f, b, df, r, alpha):
    """Determine the next integral basis element form those already computed."""
    # obtain the ring of Puiseux series in which the truncated series
    # live. these should already be such that the base ring is SR, the symbolic
    # ring. (below we will have to introduce symbolic indeterminants)
    R = f.parent()
    F = R.fraction_field()
    x,y = R.gens()

    # construct a list of indeterminants and a guess for the next integral
    # basis element. to make computations uniform in the univariate and
    # multivariate cases an additional generator of the underlying polynomial
    # ring is introduced.
    d = len(b)
    Q = PolynomialRing(QQbar, ['a%d'%n for n in range(d)] + ['dummy'])
    a = tuple(Q.gens())
    b = tuple(b)
    P = PuiseuxSeriesRing(Q, str(x))
    xx = P.gen()
    bd = F(y*b[-1])

    # XXX HACK
    for l in range(len(r)):
        for k in range(len(r[l])):
            r[l][k] = r[l][k].change_ring(Q)

    # sufficiently singularize the current integral basis element guess at each
    # of the singular points of df
    for l in range(len(df)):
        k = df[l]  # factor
        alphak = alpha[l]  # point at which the truncated series are centered
        rk = r[l]  # truncated puiseux series

        # singularize the current guess at the current point using each
        # truncated Puiseux seriesx
        sufficiently_singular = False
        while not sufficiently_singular:
            # from each puiseux series, rki, centered at alphak construct a
            # system of equations from the negative exponent terms appearing in
            # the expression A(x,rki))
            equations = []
            for rki in rk:
                #                A = sum(a[j] * b[j](xx,rki) for j in range(d))
                A = evaluate_A(a,b,xx,rki,d)
                A += bd(xx, rki)

                # implicit division by x-alphak, hence truncation to x^1
                terms = A.truncate(1).coefficients()
                equations.extend(terms)

            # attempt to solve this linear system of equations. if a (unique)
            # solution exists then the integral basis element is not singular
            # enough at alphak
            sols = solve_coefficient_system(Q, equations, a)
            if not sols is None:
                bdm1 = sum(F(sols[i][0])*b[i] for i in range(d))
                bd = F(bdm1 + bd)/ F(k)
            else:
                sufficiently_singular = True
    return bd
Exemplo n.º 3
0
def compute_bd(f, b, df, r, alpha):
    """Determine the next integral basis element form those already computed."""
    # obtain the ring of Puiseux series in which the truncated series
    # live. these should already be such that the base ring is SR, the symbolic
    # ring. (below we will have to introduce symbolic indeterminants)
    R = f.parent()
    F = R.fraction_field()
    x, y = R.gens()

    # construct a list of indeterminants and a guess for the next integral
    # basis element. to make computations uniform in the univariate and
    # multivariate cases an additional generator of the underlying polynomial
    # ring is introduced.
    d = len(b)
    Q = PolynomialRing(QQbar, ['a%d' % n for n in range(d)] + ['dummy'])
    a = tuple(Q.gens())
    b = tuple(b)
    P = PuiseuxSeriesRing(Q, str(x))
    xx = P.gen()
    bd = F(y * b[-1])

    # XXX HACK
    for l in range(len(r)):
        for k in range(len(r[l])):
            r[l][k] = r[l][k].change_ring(Q)

    # sufficiently singularize the current integral basis element guess at each
    # of the singular points of df
    for l in range(len(df)):
        k = df[l]  # factor
        alphak = alpha[l]  # point at which the truncated series are centered
        rk = r[l]  # truncated puiseux series

        # singularize the current guess at the current point using each
        # truncated Puiseux seriesx
        sufficiently_singular = False
        while not sufficiently_singular:
            # from each puiseux series, rki, centered at alphak construct a
            # system of equations from the negative exponent terms appearing in
            # the expression A(x,rki))
            equations = []
            for rki in rk:
                #                A = sum(a[j] * b[j](xx,rki) for j in range(d))
                A = evaluate_A(a, b, xx, rki, d)
                A += bd(xx, rki)

                # implicit division by x-alphak, hence truncation to x^1
                terms = A.truncate(1).coefficients()
                equations.extend(terms)

            # attempt to solve this linear system of equations. if a (unique)
            # solution exists then the integral basis element is not singular
            # enough at alphak
            sols = solve_coefficient_system(Q, equations, a)
            if not sols is None:
                bdm1 = sum(F(sols[i][0]) * b[i] for i in range(d))
                bd = F(bdm1 + bd) / F(k)
            else:
                sufficiently_singular = True
    return bd
Exemplo n.º 4
0
	def specialize(self):
		"""specializes to weight k -- i.e. projects to Sym^k"""
		k=self.weight
		if k==0:
			# R.<X,Y>=PolynomialRing(QQ,2)
			R = PolynomialRing(QQ,('X','Y'))
			X,Y = R.gens()
			P=0
			for j in range(0,k+1):
				P=P+binomial(k,j)*((-1)**j)*self.moment(j)*(X**j)*(Y**(k-j))
			return symk(k,P)	
Exemplo n.º 5
0
	def map(self,psi):
		"""psi is a map from the base_ring to Qp and this function applies psi to all polynomial coefficients and then lifts them to QQ"""
		#assert psi.domain()==self.base_ring
		k=self.weight
		# S.<X,Y>=PolynomialRing(QQ)
		S = PolynomialRing(QQ,('X','Y'))
		X,Y = S.gens()

		ans=0*X
		for j in range(k+1):
			ans=ans+psi(self.coef(j)).lift()*(X**j)*(Y**(k-j))
		temp=copy(self)
		temp.poly=ans
		temp.base_ring=psi.codomain()

		return temp
Exemplo n.º 6
0
	def __init__(self,k,poly=None,base_ring=QQ):
		"""A symk object is stored as a homogeneous polynomial of degree k

Inputs: 
	k -- weight 
	poly -- homogeneous of weight k in X and Y
	base_ring -- ring containing the coefficients of poly"""

		#assert (poly == None) or (poly == 0) or (k==0) or (poly.is_homogeneous()), "must enter a homogeneous polynomial"
		#if (poly != None) and (poly !=0) and (k<>0):
		#	assert poly.total_degree() == k, "the weight is incorrect"
		if poly != None:
			self.poly=poly
		else:
			# R.<X,Y>=PolynomialRing(base_ring,2)
			# self.poly=0*X
			R = PolynomialRing(base_ring,('X','Y'))
			self.poly=0*R.gens()[0]
		self.weight=k
		self.base_ring=base_ring
Exemplo n.º 7
0
    def local_coordinates(self, pt, n):
        r"""
        Return local coordinates to precision n at the given point.

            Behaviour is flaky - some choices of `n` are worst that
            others.


        INPUT:


        -  ``pt`` - an F-rational point on X which is not a
           point of ramification for the projection (x,y) - x.

        -  ``n`` - the number of terms desired


        OUTPUT: x = x0 + t y = y0 + power series in t

        EXAMPLES::

            sage: FF = FiniteField(5)
            sage: P2 = ProjectiveSpace(2, FF, names = ['x','y','z'])
            sage: x, y, z = P2.coordinate_ring().gens()
            sage: C = Curve(y^2*z^7-x^9-x*z^8)
            sage: pt = C([2,3,1])
            sage: C.local_coordinates(pt,9)     # todo: not implemented  !!!!
                  [2 + t, 3 + 3*t^2 + t^3 + 3*t^4 + 3*t^6 + 3*t^7 + t^8 + 2*t^9 + 3*t^11 + 3*t^12]
        """

        f = self.defining_polynomial()
        R = f.parent()
        F = self.base_ring()
        p = F.characteristic()
        x0 = F(pt[0])
        y0 = F(pt[1])
        astr = ["a"+str(i) for i in range(1,2*n)]
        x,y = R.gens()
        R0 = PolynomialRing(F,2*n+2,names = [str(x),str(y),"t"]+astr)
        vars0 = R0.gens()
        t = vars0[2]
        yt = y0*t**0 + add([vars0[i]*t**(i-2) for i in range(3,2*n+2)])
        xt = x0+t
        ft = f(xt,yt)
        S = singular
        S.eval('ring s = '+str(p)+','+str(R0.gens())+',lp;')
        S.eval('poly f = '+str(ft))
        cmd = 'matrix c = coeffs ('+str(ft)+',t)'
        S.eval(cmd)
        N = int(S.eval('size(c)'))
        b = ["c["+str(i)+",1]," for i in range(2,N/2-4)]
        b = ''.join(b)
        b = b[:len(b)-1] #to cut off the trailing comma
        cmd = 'ideal I = '+b
        S.eval(cmd)
        c = S.eval('slimgb(I)')
        d = c.split("=")
        d = d[1:]
        d[len(d)-1] += "\n"
        e = [x[:x.index("\n")] for x in d]
        vals = []
        for x in e:
            for y in vars0:
                if str(y) in x:
                    if len(x.replace(str(y),"")) != 0:
                        i = x.find("-")
                        if i>0:
                            vals.append([eval(x[1:i]),x[:i],F(eval(x[i+1:]))])
                        i = x.find("+")
                        if i>0:
                            vals.append([eval(x[1:i]),x[:i],-F(eval(x[i+1:]))])
                    else:
                        vals.append([eval(str(y)[1:]),str(y),F(0)])
        vals.sort()
        k = len(vals)
        v = [x0+t,y0+add([vals[i][2]*t**(i+1) for i in range(k)])]
        return v
Exemplo n.º 8
0
    def local_coordinates(self, pt, n):
        r"""
        Return local coordinates to precision n at the given point.

            Behaviour is flaky - some choices of `n` are worst that
            others.


        INPUT:


        -  ``pt`` - an F-rational point on X which is not a
           point of ramification for the projection (x,y) - x.

        -  ``n`` - the number of terms desired


        OUTPUT: x = x0 + t y = y0 + power series in t

        EXAMPLES::

            sage: FF = FiniteField(5)
            sage: P2 = ProjectiveSpace(2, FF, names = ['x','y','z'])
            sage: x, y, z = P2.coordinate_ring().gens()
            sage: C = Curve(y^2*z^7-x^9-x*z^8)
            sage: pt = C([2,3,1])
            sage: C.local_coordinates(pt,9)     # todo: not implemented  !!!!
                  [2 + t, 3 + 3*t^2 + t^3 + 3*t^4 + 3*t^6 + 3*t^7 + t^8 + 2*t^9 + 3*t^11 + 3*t^12]
        """

        f = self.defining_polynomial()
        R = f.parent()
        F = self.base_ring()
        p = F.characteristic()
        x0 = F(pt[0])
        y0 = F(pt[1])
        astr = ["a" + str(i) for i in range(1, 2 * n)]
        x, y = R.gens()
        R0 = PolynomialRing(F, 2 * n + 2, names=[str(x), str(y), "t"] + astr)
        vars0 = R0.gens()
        t = vars0[2]
        yt = y0 * t**0 + add(
            [vars0[i] * t**(i - 2) for i in range(3, 2 * n + 2)])
        xt = x0 + t
        ft = f(xt, yt)
        S = singular
        S.eval('ring s = ' + str(p) + ',' + str(R0.gens()) + ',lp;')
        S.eval('poly f = ' + str(ft))
        cmd = 'matrix c = coeffs (' + str(ft) + ',t)'
        S.eval(cmd)
        N = int(S.eval('size(c)'))
        b = ["c[" + str(i) + ",1]," for i in range(2, N / 2 - 4)]
        b = ''.join(b)
        b = b[:len(b) - 1]  #to cut off the trailing comma
        cmd = 'ideal I = ' + b
        S.eval(cmd)
        c = S.eval('slimgb(I)')
        d = c.split("=")
        d = d[1:]
        d[len(d) - 1] += "\n"
        e = [x[:x.index("\n")] for x in d]
        vals = []
        for x in e:
            for y in vars0:
                if str(y) in x:
                    if len(x.replace(str(y), "")) != 0:
                        i = x.find("-")
                        if i > 0:
                            vals.append(
                                [eval(x[1:i]), x[:i],
                                 F(eval(x[i + 1:]))])
                        i = x.find("+")
                        if i > 0:
                            vals.append(
                                [eval(x[1:i]), x[:i], -F(eval(x[i + 1:]))])
                    else:
                        vals.append([eval(str(y)[1:]), str(y), F(0)])
        vals.sort()
        k = len(vals)
        v = [x0 + t, y0 + add([vals[i][2] * t**(i + 1) for i in range(k)])]
        return v