Пример #1
0
def eqn_list_to_curve_plot(L, rat_pts):
    xpoly_rng = PolynomialRing(QQ, 'x')
    poly_tup = [xpoly_rng(tup) for tup in L]
    f = poly_tup[0]
    h = poly_tup[1]
    g = f + h**2 / 4
    if len(g.real_roots()) == 0 and g(0) < 0:
        return text(r"$X(\mathbb{R})=\emptyset$", (1, 1), fontsize=50)
    X0 = [real(z[0]) for z in g.base_extend(CC).roots()
          ] + [real(z[0]) for z in g.derivative().base_extend(CC).roots()]
    a, b = inflate_interval(min(X0), max(X0), 1.5)
    groots = [a] + g.real_roots() + [b]
    if b - a < 1e-7:
        a = -3
        b = 3
        groots = [a, b]
    ngints = len(groots) - 1
    plotzones = []
    npts = 100
    for j in range(ngints):
        c = groots[j]
        d = groots[j + 1]
        if g((c + d) / 2) < 0:
            continue
        (c, d) = inflate_interval(c, d, 1.1)
        s = (d - c) / npts
        u = c
        yvals = []
        for i in range(npts + 1):
            v = g(u)
            if v > 0:
                v = sqrt(v)
                w = -h(u) / 2
                yvals.append(w + v)
                yvals.append(w - v)
            u += s
        (m, M) = inflate_interval(min(yvals), max(yvals), 1.2)
        plotzones.append((c, d, m, M))
    x = var('x')
    y = var('y')
    plot = sum(
        implicit_plot(y**2 + y * h(x) - f(x), (x, R[0], R[1]), (y, R[2], R[3]),
                      aspect_ratio='automatic',
                      plot_points=500,
                      zorder=1) for R in plotzones)
    xmin = min([R[0] for R in plotzones])
    xmax = max([R[1] for R in plotzones])
    ymin = min([R[2] for R in plotzones])
    ymax = max([R[3] for R in plotzones])
    for P in rat_pts:
        (x, y, z) = P
        z = ZZ(z)
        if z:  # Do not attempt to plot points at infinity
            x = ZZ(x) / z
            y = ZZ(y) / z**3
            if x >= xmin and x <= xmax and y >= ymin and y <= ymax:
                plot += point((x, y), color='red', size=40, zorder=2)
    return plot
Пример #2
0
def eqn_list_to_curve_plot(L,rat_pts):
    xpoly_rng = PolynomialRing(QQ,'x')
    poly_tup = [xpoly_rng(tup) for tup in L]
    f = poly_tup[0]
    h = poly_tup[1]
    g = f+h**2/4
    if len(g.real_roots())==0 and g(0)<0:
        return text("$X(\mathbb{R})=\emptyset$",(1,1),fontsize=50)
    X0 = [real(z[0]) for z in g.base_extend(CC).roots()]+[real(z[0]) for z in g.derivative().base_extend(CC).roots()]
    a,b = inflate_interval(min(X0),max(X0),1.5)
    groots = [a]+g.real_roots()+[b]
    if b-a<1e-7:
        a=-3
        b=3
        groots=[a,b]
    ngints = len(groots)-1
    plotzones = []
    npts = 100
    for j in range(ngints):
        c = groots[j]
        d = groots[j+1]
        if g((c+d)/2)<0:
            continue
        (c,d) = inflate_interval(c,d,1.1)
        s = (d-c)/npts
        u = c
        yvals = []
        for i in range(npts+1):
            v = g(u)
            if v>0:
                v = sqrt(v)
                w = -h(u)/2
                yvals.append(w+v)
                yvals.append(w-v)
            u += s
        (m,M) = inflate_interval(min(yvals),max(yvals),1.2)
        plotzones.append((c,d,m,M))
    x = var('x')
    y = var('y')
    plot=sum(implicit_plot(y**2 + y*h(x) - f(x), (x,R[0],R[1]),(y,R[2],R[3]), aspect_ratio='automatic', plot_points=500, zorder=1) for R in plotzones)
    xmin=min([R[0] for R in plotzones])
    xmax=max([R[1] for R in plotzones])
    ymin=min([R[2] for R in plotzones])
    ymax=max([R[3] for R in plotzones])
    for P in rat_pts:
    	(x,y,z)=eval(P.replace(':',','))
        z=ZZ(z)
     	if z: # Do not attempt to plot points at infinity
      		x=ZZ(x)/z
      		y=ZZ(y)/z**3
      		if x >= xmin and x <= xmax and y >= ymin and y <= ymax:
       			plot += point((x,y),color='red',size=40,zorder=2)
    return plot
Пример #3
0
def eqn_list_to_curve_plot(L):
    xpoly_rng = PolynomialRing(QQ, 'x')
    poly_tup = [xpoly_rng(tup) for tup in L]
    f = poly_tup[0]
    h = poly_tup[1]
    g = f + h**2 / 4
    if len(g.real_roots()) == 0 and g(0) < 0:
        return text("$X(\mathbb{R})=\emptyset$", (1, 1), fontsize=50)
    X0 = [real(z[0]) for z in g.base_extend(CC).roots()
          ] + [real(z[0]) for z in g.derivative().base_extend(CC).roots()]
    a, b = inflate_interval(min(X0), max(X0), 1.5)
    groots = [a] + g.real_roots() + [b]
    if b - a < 1e-7:
        a = -3
        b = 3
        groots = [a, b]
    ngints = len(groots) - 1
    plotzones = []
    npts = 100
    for j in range(ngints):
        c = groots[j]
        d = groots[j + 1]
        if g((c + d) / 2) < 0:
            continue
        (c, d) = inflate_interval(c, d, 1.1)
        s = (d - c) / npts
        u = c
        yvals = []
        for i in range(npts + 1):
            v = g(u)
            if v > 0:
                v = sqrt(v)
                w = -h(u) / 2
                yvals.append(w + v)
                yvals.append(w - v)
            u += s
        (m, M) = inflate_interval(min(yvals), max(yvals), 1.2)
        plotzones.append((c, d, m, M))
    x = var('x')
    y = var('y')
    return sum(
        implicit_plot(y**2 + y * h(x) - f(x), (x, R[0], R[1]), (y, R[2], R[3]),
                      aspect_ratio='automatic',
                      plot_points=500) for R in plotzones)
Пример #4
0
def eqn_list_to_curve_plot(L):
    xpoly_rng = PolynomialRing(QQ,'x')
    poly_tup = [xpoly_rng(tup) for tup in L]
    f = poly_tup[0]
    h = poly_tup[1]
    g = f+h**2/4
    if len(g.real_roots())==0 and g(0)<0:
        return text("$X(\mathbb{R})=\emptyset$",(1,1),fontsize=50)
    X0 = [real(z[0]) for z in g.base_extend(CC).roots()]+[real(z[0]) for z in g.derivative().base_extend(CC).roots()]
    a,b = inflate_interval(min(X0),max(X0),1.5)
    groots = [a]+g.real_roots()+[b]
    if b-a<1e-7:
        a=-3
        b=3
        groots=[a,b]
    ngints = len(groots)-1
    plotzones = []
    npts = 100
    for j in range(ngints):
        c = groots[j]
        d = groots[j+1]
        if g((c+d)/2)<0:
            continue
        (c,d) = inflate_interval(c,d,1.1)
        s = (d-c)/npts
        u = c
        yvals = []
        for i in range(npts+1):
            v = g(u)
            if v>0:
                v = sqrt(v)
                w = -h(u)/2
                yvals.append(w+v)
                yvals.append(w-v)
            u += s
        (m,M) = inflate_interval(min(yvals),max(yvals),1.2)
        plotzones.append((c,d,m,M))
    x = var('x')
    y = var('y')
    return sum(implicit_plot(y**2 + y*h(x) - f(x), (x,R[0],R[1]),
        (y,R[2],R[3]), aspect_ratio='automatic', plot_points=500) for R in
        plotzones)
Пример #5
0
    def dimension(self,k,ignore=False, debug = 0):
        if k < 2 and not ignore:
            raise NotImplementedError("k has to >= 2")
        s = self._signature
        if not (2*k in ZZ):
            raise ValueError("k has to be integral or half-integral")
        if (2*k+s)%4 != 0 and not ignore:
            raise NotImplementedError("2k has to be congruent to -signature mod 4")
        if self._v2.has_key(0):
            v2 = self._v2[0]
        else:
            v2 = 1

        if self._g != None:
            if not self._aniso_formula:
                vals = self._g.values()
            #else:
                #print "using aniso_formula"
            M = self._g
        else:
            vals = self._M.values()
            M = self._M
            
        prec = ceil(max(log(M.order(),2),52)+1)+17
        #print prec
        RR = RealField(prec)
        CC = ComplexField(prec)
        d = self._d
        m = self._m
        if debug > 0: print d,m
            
        if self._alpha3 == None:
            if self._aniso_formula:
                self._alpha4 = 1
                self._alpha3 = -sum([BB(a)*mm for a,mm in self._v2.iteritems() if a != 0])
                #print self._alpha3
                self._alpha3 += Integer(d) - Integer(1) - self._g.beta_formula()
                #print self._alpha3, self._g.a5prime_formula()
                self._alpha3 = self._alpha3/RR(2)
            else:
                self._alpha3 = sum([(1-a)*mm for a,mm in self._v2.iteritems() if a != 0])
                #print self._alpha3
                self._alpha3 += sum([(1-a)*mm for a,mm in vals.iteritems() if a != 0])
                #print self._alpha3
                self._alpha3 = self._alpha3 / Integer(2)
                self._alpha4 = 1/Integer(2)*(vals[0]+v2) # the codimension of SkL in MkL
        alpha3 = self._alpha3
        alpha4 = self._alpha4
        if debug > 0: print alpha3, alpha4
        g1=M.char_invariant(1)
        g1=CC(g1[0]*g1[1])
        #print g1
        g2=M.char_invariant(2)
        g2=RR(real(g2[0]*g2[1]))
        if debug > 0: print g2, g2.parent()
        g3=M.char_invariant(-3)
        g3=CC(g3[0]*g3[1])
        if debug > 0: print RR(d) / RR(4), sqrt(RR(m)) / RR(4), CC(exp(2 * CC.pi() * CC(0,1) * (2 * k + s) / Integer(8)))
        alpha1 = RR(d) / RR(4) - (sqrt(RR(m)) / RR(4)  * CC(exp(2 * CC.pi() * CC(0,1) * (2 * k + s) / Integer(8))) * g2)
        if debug > 0: print alpha1
        alpha2 = RR(d) / RR(3) + sqrt(RR(m)) / (3 * sqrt(RR(3))) * real(exp(CC(2 * CC.pi() * CC(0,1) * (4 * k + 3 * s - 10) / 24)) * (g1+g3))
        if debug > 0: print alpha1, alpha2, g1, g2, g3, d, k, s
        dim = real(d + (d * k / Integer(12)) - alpha1 - alpha2 - alpha3)
        if debug > 0:
            print "dimension:", dim
        if abs(dim-round(dim)) > 1e-6:
            raise RuntimeError("Error ({0}) too large in dimension formula for {1} and k={2}".format(abs(dim-round(dim)), self._M if self._M is not None else self._g, k))
        dimr = dim
        dim = Integer(round(dim))
        if k >=2 and dim < 0:
            raise RuntimeError("Negative dimension (= {0}, {1})!".format(dim, dimr))
        return dim
Пример #6
0
    def dimension(self, k, ignore=False, debug=0):
        if k < 2 and not ignore:
            raise NotImplementedError("k has to >= 2")
        s = self._signature
        if not (2 * k in ZZ):
            raise ValueError("k has to be integral or half-integral")
        if (2 * k + s) % 4 != 0 and not ignore:
            raise NotImplementedError(
                "2k has to be congruent to -signature mod 4")
        if self._v2.has_key(0):
            v2 = self._v2[0]
        else:
            v2 = 1

        if self._g != None:
            if not self._aniso_formula:
                vals = self._g.values()
            #else:
            #print "using aniso_formula"
            M = self._g
        else:
            vals = self._M.values()
            M = self._M

        prec = ceil(max(log(M.order(), 2), 52) + 1) + 17
        #print prec
        RR = RealField(prec)
        CC = ComplexField(prec)
        d = self._d
        m = self._m
        if debug > 0: print d, m

        if self._alpha3 == None:
            if self._aniso_formula:
                self._alpha4 = 1
                self._alpha3 = -sum(
                    [BB(a) * mm for a, mm in self._v2.iteritems() if a != 0])
                #print self._alpha3
                self._alpha3 += Integer(d) - Integer(
                    1) - self._g.beta_formula()
                #print self._alpha3, self._g.a5prime_formula()
                self._alpha3 = self._alpha3 / RR(2)
            else:
                self._alpha3 = sum([(1 - a) * mm
                                    for a, mm in self._v2.iteritems()
                                    if a != 0])
                #print self._alpha3
                self._alpha3 += sum([(1 - a) * mm
                                     for a, mm in vals.iteritems() if a != 0])
                #print self._alpha3
                self._alpha3 = self._alpha3 / Integer(2)
                self._alpha4 = 1 / Integer(2) * (
                    vals[0] + v2)  # the codimension of SkL in MkL
        alpha3 = self._alpha3
        alpha4 = self._alpha4
        if debug > 0: print alpha3, alpha4
        g1 = M.char_invariant(1)
        g1 = CC(g1[0] * g1[1])
        #print g1
        g2 = M.char_invariant(2)
        g2 = RR(real(g2[0] * g2[1]))
        if debug > 0: print g2, g2.parent()
        g3 = M.char_invariant(-3)
        g3 = CC(g3[0] * g3[1])
        if debug > 0:
            print RR(d) / RR(4), sqrt(RR(m)) / RR(4), CC(
                exp(2 * CC.pi() * CC(0, 1) * (2 * k + s) / Integer(8)))
        alpha1 = RR(d) / RR(4) - (sqrt(RR(m)) / RR(4) * CC(
            exp(2 * CC.pi() * CC(0, 1) * (2 * k + s) / Integer(8))) * g2)
        if debug > 0: print alpha1
        alpha2 = RR(d) / RR(3) + sqrt(RR(m)) / (3 * sqrt(RR(3))) * real(
            exp(CC(2 * CC.pi() * CC(0, 1) * (4 * k + 3 * s - 10) / 24)) *
            (g1 + g3))
        if debug > 0: print alpha1, alpha2, g1, g2, g3, d, k, s
        dim = real(d + (d * k / Integer(12)) - alpha1 - alpha2 - alpha3)
        if debug > 0:
            print "dimension:", dim
        if abs(dim - round(dim)) > 1e-6:
            raise RuntimeError(
                "Error ({0}) too large in dimension formula for {1} and k={2}".
                format(abs(dim - round(dim)),
                       self._M if self._M is not None else self._g, k))
        dimr = dim
        dim = Integer(round(dim))
        if k >= 2 and dim < 0:
            raise RuntimeError("Negative dimension (= {0}, {1})!".format(
                dim, dimr))
        return dim
Пример #7
0
    def dimension(self, k, ignore=False, debug=0):
        if k < 2 and not ignore:
            raise NotImplementedError("k has to >= 2")
        s = self._signature
        if not (2 * k in ZZ):
            raise ValueError("k has to be integral or half-integral")
        if (2 * k + s) % 2 != 0:
            return 0
        m = self._m
        n2 = self._n2
        if self._v2.has_key(0):
            v2 = self._v2[0]
        else:
            v2 = 1

        if self._g != None:
            if not self._aniso_formula:
                vals = self._g.values()
            #else:
            #print "using aniso_formula"
            M = self._g
        else:
            vals = self._M.values()
            M = self._M

        if (2 * k + s) % 4 == 0:
            d = Integer(1) / Integer(2) * (
                m + n2
            )  # |dimension of the Weil representation on even functions|
            self._d = d
            self._alpha4 = 1 / Integer(2) * (vals[0] + v2
                                             )  # the codimension of SkL in MkL
        else:
            d = Integer(1) / Integer(2) * (
                m - n2
            )  # |dimension of the Weil representation on odd functions|
            self._d = d
            self._alpha4 = 1 / Integer(2) * (vals[0] - v2
                                             )  # the codimension of SkL in MkL

        prec = ceil(max(log(M.order(), 2), 52) + 1) + 17
        #print prec
        RR = RealField(prec)
        CC = ComplexField(prec)

        if debug > 0: print "d, m = {0}, {1}".format(d, m)
        eps = exp(2 * CC.pi() * CC(0, 1) * (s + 2 * k) / Integer(4))
        eps = round(real(eps))
        if self._alpha3 is None or self._last_eps != eps:
            self._last_eps = eps
            if self._aniso_formula:
                self._alpha4 = 1
                self._alpha3 = -sum(
                    [BB(a) * mm for a, mm in self._v2.iteritems() if a != 0])
                #print self._alpha3
                self._alpha3 += Integer(d) - Integer(
                    1) - self._g.beta_formula()
                #print self._alpha3, self._g.a5prime_formula()
                self._alpha3 = self._alpha3 / RR(2)
            else:
                self._alpha3 = eps * sum(
                    [(1 - a) * mm for a, mm in self._v2.iteritems() if a != 0])
                if debug > 0: print "alpha3t = ", self._alpha3
                self._alpha3 += sum([(1 - a) * mm
                                     for a, mm in vals.iteritems() if a != 0])
                #print self._alpha3
                self._alpha3 = self._alpha3 / Integer(2)
        alpha3 = self._alpha3
        alpha4 = self._alpha4
        if debug > 0: print alpha3, alpha4
        g1 = M.char_invariant(1)
        g1 = CC(g1[0] * g1[1])
        #print g1
        g2 = M.char_invariant(2)
        g2 = CC(g2[0] * g2[1])
        if debug > 0: print g2, g2.parent()
        g3 = M.char_invariant(-3)
        g3 = CC(g3[0] * g3[1])
        if debug > 0: print "eps = {0}".format(eps)
        if debug > 0:
            print "d/4 = {0}, m/4 = {1}, e^(2pi i (2k+s)/8) = {2}".format(
                RR(d) / RR(4),
                sqrt(RR(m)) / RR(4),
                CC(exp(2 * CC.pi() * CC(0, 1) * (2 * k + s) / Integer(8))))
        if eps == 1:
            g2_2 = real(g2)
        else:
            g2_2 = imag(g2) * CC(0, 1)
        alpha1 = RR(d) / RR(4) - sqrt(RR(m)) / RR(4) * CC(
            exp(2 * CC.pi() * CC(0, 1) * (2 * k + s) / Integer(8)) * g2_2)
        if debug > 0: print alpha1
        alpha2 = RR(d) / RR(3) + sqrt(RR(m)) / (3 * sqrt(RR(3))) * real(
            exp(CC(2 * CC.pi() * CC(0, 1) * (4 * k + 3 * s - 10) / 24)) *
            (g1 + eps * g3))
        if debug > 0:
            print "alpha1 = {0}, alpha2 = {1}, alpha3 = {2}, g1 = {3}, g2 = {4}, g3 = {5}, d = {6}, k = {7}, s = {8}".format(
                alpha1, alpha2, alpha3, g1, g2, g3, d, k, s)
        dim = real(d + (d * k / Integer(12)) - alpha1 - alpha2 - alpha3)
        if debug > 0:
            print "dimension:", dim
        if abs(dim - round(dim)) > 1e-6:
            raise RuntimeError(
                "Error ({0}) too large in dimension formula for {1} and k={2}".
                format(abs(dim - round(dim)),
                       self._M if self._M is not None else self._g, k))
        dimr = dim
        dim = Integer(round(dim))
        if k >= 2 and dim < 0:
            raise RuntimeError("Negative dimension (= {0}, {1})!".format(
                dim, dimr))
        return dim
Пример #8
0
    def dimension(self,k,ignore=False, debug = 0):
        if k < 2 and not ignore:
            raise NotImplementedError("k has to >= 2")
        s = self._signature
        if not (2*k in ZZ):
            raise ValueError("k has to be integral or half-integral")
        if (2*k+s)%2 != 0:
            return 0
        m = self._m
        n2 = self._n2
        if self._v2.has_key(0):
            v2 = self._v2[0]
        else:
            v2 = 1

        if self._g != None:
            if not self._aniso_formula:
                vals = self._g.values()
            #else:
                #print "using aniso_formula"
            M = self._g
        else:
            vals = self._M.values()
            M = self._M

        if (2*k+s)%4 == 0:
            d = Integer(1)/Integer(2)*(m+n2) # |dimension of the Weil representation on even functions|
            self._d = d
            self._alpha4 = 1/Integer(2)*(vals[0]+v2) # the codimension of SkL in MkL
        else:
            d = Integer(1)/Integer(2)*(m-n2) # |dimension of the Weil representation on odd functions|
            self._d = d
            self._alpha4 = 1/Integer(2)*(vals[0]-v2) # the codimension of SkL in MkL
            
        prec = ceil(max(log(M.order(),2),52)+1)+17
        #print prec
        RR = RealField(prec)
        CC = ComplexField(prec)
        
        if debug > 0: print "d, m = {0}, {1}".format(d,m)
        eps = exp( 2 * CC.pi() * CC(0,1) * (s + 2*k) / Integer(4) )
        eps = round(real(eps))        
        if self._alpha3 is None or self._last_eps != eps:
            self._last_eps = eps
            if self._aniso_formula:
                self._alpha4 = 1
                self._alpha3 = -sum([BB(a)*mm for a,mm in self._v2.iteritems() if a != 0])
                #print self._alpha3
                self._alpha3 += Integer(d) - Integer(1) - self._g.beta_formula()
                #print self._alpha3, self._g.a5prime_formula()
                self._alpha3 = self._alpha3/RR(2)
            else:
                self._alpha3 = eps*sum([(1-a)*mm for a,mm in self._v2.iteritems() if a != 0])
                if debug>0: print "alpha3t = ", self._alpha3
                self._alpha3 += sum([(1-a)*mm for a,mm in vals.iteritems() if a != 0])
                #print self._alpha3
                self._alpha3 = self._alpha3 / Integer(2)
        alpha3 = self._alpha3
        alpha4 = self._alpha4
        if debug > 0: print alpha3, alpha4
        g1=M.char_invariant(1)
        g1=CC(g1[0]*g1[1])
        #print g1
        g2=M.char_invariant(2)
        g2=CC(g2[0]*g2[1])
        if debug > 0: print g2, g2.parent()
        g3=M.char_invariant(-3)
        g3=CC(g3[0]*g3[1])
        if debug > 0: print "eps = {0}".format(eps)
        if debug > 0: print "d/4 = {0}, m/4 = {1}, e^(2pi i (2k+s)/8) = {2}".format(RR(d) / RR(4), sqrt(RR(m)) / RR(4), CC(exp(2 * CC.pi() * CC(0,1) * (2 * k + s) / Integer(8))))
        if eps == 1:
            g2_2 = real(g2)
        else:
            g2_2 = imag(g2)*CC(0,1)
        alpha1 = RR(d) / RR(4) - sqrt(RR(m)) / RR(4)  * CC(exp(2 * CC.pi() * CC(0,1) * (2 * k + s) / Integer(8)) * g2_2)
        if debug > 0: print alpha1
        alpha2 = RR(d) / RR(3) + sqrt(RR(m)) / (3 * sqrt(RR(3))) * real(exp(CC(2 * CC.pi() * CC(0,1) * (4 * k + 3 * s - 10) / 24)) * (g1 + eps*g3))
        if debug > 0: print "alpha1 = {0}, alpha2 = {1}, alpha3 = {2}, g1 = {3}, g2 = {4}, g3 = {5}, d = {6}, k = {7}, s = {8}".format(alpha1, alpha2, alpha3, g1, g2, g3, d, k, s)
        dim = real(d + (d * k / Integer(12)) - alpha1 - alpha2 - alpha3)
        if debug > 0:
            print "dimension:", dim
        if abs(dim-round(dim)) > 1e-6:
            raise RuntimeError("Error ({0}) too large in dimension formula for {1} and k={2}".format(abs(dim-round(dim)), self._M if self._M is not None else self._g, k))
        dimr = dim
        dim = Integer(round(dim))
        if k >=2 and dim < 0:
            raise RuntimeError("Negative dimension (= {0}, {1})!".format(dim, dimr))
        return dim