def local_coordinates_at_infinity(self, prec=20, name='t'): """ For the genus `g` hyperelliptic curve `y^2 = f(x)`, return `(x(t), y(t))` such that `(y(t))^2 = f(x(t))`, where `t = x^g/y` is the local parameter at infinity INPUT: - ``prec`` -- desired precision of the local coordinates - ``name`` -- generator of the power series ring (default: ``t``) OUTPUT: `(x(t),y(t))` such that `y(t)^2 = f(x(t))` and `t = x^g/y` is the local parameter at infinity EXAMPLES:: sage: R.<x> = QQ['x'] sage: H = HyperellipticCurve(x^5-5*x^2+1) sage: x,y = H.local_coordinates_at_infinity(10) sage: x t^-2 + 5*t^4 - t^8 - 50*t^10 + O(t^12) sage: y t^-5 + 10*t - 2*t^5 - 75*t^7 + 50*t^11 + O(t^12) :: sage: R.<x> = QQ['x'] sage: H = HyperellipticCurve(x^3-x+1) sage: x,y = H.local_coordinates_at_infinity(10) sage: x t^-2 + t^2 - t^4 - t^6 + 3*t^8 + O(t^12) sage: y t^-3 + t - t^3 - t^5 + 3*t^7 - 10*t^11 + O(t^12) AUTHOR: - Jennifer Balakrishnan (2007-12) """ g = self.genus() pol = self.hyperelliptic_polynomials()[0] K = LaurentSeriesRing(self.base_ring(), name, default_prec=prec + 2) t = K.gen() L = PolynomialRing(K, 'x') x = L.gen() i = 0 w = (x**g / t)**2 - pol wprime = w.derivative(x) if pol.degree() == 2 * g + 1: x = t**-2 else: x = t**-1 for i in range((RR(log(prec + 2) / log(2))).ceil()): x = x - w(x) / wprime(x) y = x**g / t return x + O(t**(prec + 2)), y + O(t**(prec + 2))
def local_coordinates_at_infinity(self, prec = 20, name = 't'): """ For the genus `g` hyperelliptic curve `y^2 = f(x)`, return `(x(t), y(t))` such that `(y(t))^2 = f(x(t))`, where `t = x^g/y` is the local parameter at infinity INPUT: - ``prec`` -- desired precision of the local coordinates - ``name`` -- generator of the power series ring (default: ``t``) OUTPUT: `(x(t),y(t))` such that `y(t)^2 = f(x(t))` and `t = x^g/y` is the local parameter at infinity EXAMPLES:: sage: R.<x> = QQ['x'] sage: H = HyperellipticCurve(x^5-5*x^2+1) sage: x,y = H.local_coordinates_at_infinity(10) sage: x t^-2 + 5*t^4 - t^8 - 50*t^10 + O(t^12) sage: y t^-5 + 10*t - 2*t^5 - 75*t^7 + 50*t^11 + O(t^12) :: sage: R.<x> = QQ['x'] sage: H = HyperellipticCurve(x^3-x+1) sage: x,y = H.local_coordinates_at_infinity(10) sage: x t^-2 + t^2 - t^4 - t^6 + 3*t^8 + O(t^12) sage: y t^-3 + t - t^3 - t^5 + 3*t^7 - 10*t^11 + O(t^12) AUTHOR: - Jennifer Balakrishnan (2007-12) """ g = self.genus() pol = self.hyperelliptic_polynomials()[0] K = LaurentSeriesRing(self.base_ring(), name, default_prec=prec+2) t = K.gen() L = PolynomialRing(K,'x') x = L.gen() i = 0 w = (x**g/t)**2-pol wprime = w.derivative(x) x = t**-2 for i in range((RR(log(prec+2)/log(2))).ceil()): x = x - w(x)/wprime(x) y = x**g/t return x+O(t**(prec+2)) , y+O(t**(prec+2))
def rational_points_iterator(self): r""" Return a generator object for the rational points on this curve. INPUT: - ``self`` -- a projective curve OUTPUT: A generator of all the rational points on the curve defined over its base field. EXAMPLE:: sage: F = GF(37) sage: P2.<X,Y,Z> = ProjectiveSpace(F,2) sage: C = Curve(X^7+Y*X*Z^5*55+Y^7*12) sage: len(list(C.rational_points_iterator())) 37 :: sage: F = GF(2) sage: P2.<X,Y,Z> = ProjectiveSpace(F,2) sage: C = Curve(X*Y*Z) sage: a = C.rational_points_iterator() sage: next(a) (1 : 0 : 0) sage: next(a) (0 : 1 : 0) sage: next(a) (1 : 1 : 0) sage: next(a) (0 : 0 : 1) sage: next(a) (1 : 0 : 1) sage: next(a) (0 : 1 : 1) sage: next(a) Traceback (most recent call last): ... StopIteration :: sage: F = GF(3^2,'a') sage: P2.<X,Y,Z> = ProjectiveSpace(F,2) sage: C = Curve(X^3+5*Y^2*Z-33*X*Y*X) sage: b = C.rational_points_iterator() sage: next(b) (0 : 1 : 0) sage: next(b) (0 : 0 : 1) sage: next(b) (2*a + 2 : a : 1) sage: next(b) (2 : a + 1 : 1) sage: next(b) (a + 1 : 2*a + 1 : 1) sage: next(b) (1 : 2 : 1) sage: next(b) (2*a + 2 : 2*a : 1) sage: next(b) (2 : 2*a + 2 : 1) sage: next(b) (a + 1 : a + 2 : 1) sage: next(b) (1 : 1 : 1) sage: next(b) Traceback (most recent call last): ... StopIteration """ g = self.defining_polynomial() K = g.parent().base_ring() from sage.rings.polynomial.all import PolynomialRing R = PolynomialRing(K,'X') X = R.gen() one = K.one() zero = K.zero() # the point with Z = 0 = Y try: t = self.point([one,zero,zero]) yield(t) except TypeError: pass # points with Z = 0, Y = 1 g10 = R(g(X,one,zero)) if g10.is_zero(): for x in K: yield(self.point([x,one,zero])) else: for x in g10.roots(multiplicities=False): yield(self.point([x,one,zero])) # points with Z = 1 for y in K: gy1 = R(g(X,y,one)) if gy1.is_zero(): for x in K: yield(self.point([x,y,one])) else: for x in gy1.roots(multiplicities=False): yield(self.point([x,y,one]))
def rational_points_iterator(self): r""" Return a generator object for the rational points on this curve. INPUT: - ``self`` -- a projective curve OUTPUT: A generator of all the rational points on the curve defined over its base field. EXAMPLE:: sage: F = GF(37) sage: P2.<X,Y,Z> = ProjectiveSpace(F,2) sage: C = Curve(X^7+Y*X*Z^5*55+Y^7*12) sage: len(list(C.rational_points_iterator())) 37 :: sage: F = GF(2) sage: P2.<X,Y,Z> = ProjectiveSpace(F,2) sage: C = Curve(X*Y*Z) sage: a = C.rational_points_iterator() sage: a.next() (1 : 0 : 0) sage: a.next() (0 : 1 : 0) sage: a.next() (1 : 1 : 0) sage: a.next() (0 : 0 : 1) sage: a.next() (1 : 0 : 1) sage: a.next() (0 : 1 : 1) sage: a.next() Traceback (most recent call last): ... StopIteration :: sage: F = GF(3^2,'a') sage: P2.<X,Y,Z> = ProjectiveSpace(F,2) sage: C = Curve(X^3+5*Y^2*Z-33*X*Y*X) sage: b = C.rational_points_iterator() sage: b.next() (0 : 1 : 0) sage: b.next() (0 : 0 : 1) sage: b.next() (2*a + 2 : a : 1) sage: b.next() (2 : a + 1 : 1) sage: b.next() (a + 1 : 2*a + 1 : 1) sage: b.next() (1 : 2 : 1) sage: b.next() (2*a + 2 : 2*a : 1) sage: b.next() (2 : 2*a + 2 : 1) sage: b.next() (a + 1 : a + 2 : 1) sage: b.next() (1 : 1 : 1) sage: b.next() Traceback (most recent call last): ... StopIteration """ g = self.defining_polynomial() K = g.parent().base_ring() from sage.rings.polynomial.all import PolynomialRing R = PolynomialRing(K, 'X') X = R.gen() one = K.one_element() zero = K.zero_element() # the point with Z = 0 = Y try: t = self.point([one, zero, zero]) yield (t) except TypeError: pass # points with Z = 0, Y = 1 g10 = R(g(X, one, zero)) if g10.is_zero(): for x in K: yield (self.point([x, one, zero])) else: for x in g10.roots(multiplicities=False): yield (self.point([x, one, zero])) # points with Z = 1 for y in K: gy1 = R(g(X, y, one)) if gy1.is_zero(): for x in K: yield (self.point([x, y, one])) else: for x in gy1.roots(multiplicities=False): yield (self.point([x, y, one]))