def __init__(self, K, ainvs): self.__base_ring = K self.__ainvs = tuple(map(K, ainvs)) self.a, self.d = self.__ainvs P2 = ProjectiveSpace(2, K, names='xyz') x, y, z = P2.coordinate_ring().gens() a, d = self.ainvs() f = a*x**2*z**2 + y**2*z**2 - z**4 - d*x**2*y**2 ProjectiveCurve_generic.__init__(self, P2, f)
def base_extend(self, S): r""" Returns the conic over ``S`` given by the same equation as ``self``. EXAMPLES:: sage: c = Conic([1, 1, 1]); c Projective Conic Curve over Rational Field defined by x^2 + y^2 + z^2 sage: c.has_rational_point() False sage: d = c.base_extend(QuadraticField(-1, 'i')); d Projective Conic Curve over Number Field in i with defining polynomial x^2 + 1 defined by x^2 + y^2 + z^2 sage: d.rational_point(algorithm = 'rnfisnorm') (i : 1 : 0) """ if S in _Fields: B = self.base_ring() if B == S: return self if not S.has_coerce_map_from(B): raise ValueError, "No natural map from the base ring of self " \ "(= %s) to S (= %s)" % (self, S) from constructor import Conic con = Conic([S(c) for c in self.coefficients()], \ self.variable_names()) if self._rational_point != None: pt = [S(c) for c in Sequence(self._rational_point)] if not pt == [0,0,0]: # The following line stores the point in the cache # if (and only if) there is no point in the cache. pt = con.point(pt) return con return ProjectiveCurve_generic.base_extend(self, S)
def point(self, v, check=True): r""" Constructs a point on ``self`` corresponding to the input ``v``. If ``check`` is True, then checks if ``v`` defines a valid point on ``self``. If no rational point on ``self`` is known yet, then also caches the point for use by ``self.rational_point()`` and ``self.parametrization()``. EXAMPLES :: sage: c = Conic([1, -1, 1]) sage: c.point([15, 17, 8]) (15/8 : 17/8 : 1) sage: c.rational_point() (15/8 : 17/8 : 1) sage: d = Conic([1, -1, 1]) sage: d.rational_point() (1 : 1 : 0) """ if is_Vector(v): v = Sequence(v) p = ProjectiveCurve_generic.point(self, v, check=check) if self._rational_point is None: self._rational_point = p return p
def point(self, v, check=True): r""" Constructs a point on ``self`` corresponding to the input ``v``. If ``check`` is True, then checks if ``v`` defines a valid point on ``self``. If no rational point on ``self`` is known yet, then also caches the point for use by ``self.rational_point()`` and ``self.parametrization()``. EXAMPLES :: sage: c = Conic([1, -1, 1]) sage: c.point([15, 17, 8]) (15/8 : 17/8 : 1) sage: c.rational_point() (15/8 : 17/8 : 1) sage: d = Conic([1, -1, 1]) sage: d.rational_point() (-1 : 1 : 0) """ if is_Vector(v): v = Sequence(v) p = ProjectiveCurve_generic.point(self, v, check=check) if self._rational_point is None: self._rational_point = p return p
def base_extend(self, S): r""" Returns the conic over ``S`` given by the same equation as ``self``. EXAMPLES:: sage: c = Conic([1, 1, 1]); c Projective Conic Curve over Rational Field defined by x^2 + y^2 + z^2 sage: c.has_rational_point() False sage: d = c.base_extend(QuadraticField(-1, 'i')); d Projective Conic Curve over Number Field in i with defining polynomial x^2 + 1 defined by x^2 + y^2 + z^2 sage: d.rational_point(algorithm = 'rnfisnorm') (i : 1 : 0) """ if S in _Fields: B = self.base_ring() if B == S: return self if not S.has_coerce_map_from(B): raise ValueError("No natural map from the base ring of self " \ "(= %s) to S (= %s)" % (self, S)) from constructor import Conic con = Conic([S(c) for c in self.coefficients()], \ self.variable_names()) if self._rational_point is not None: pt = [S(c) for c in Sequence(self._rational_point)] if not pt == [0,0,0]: # The following line stores the point in the cache # if (and only if) there is no point in the cache. pt = con.point(pt) return con return ProjectiveCurve_generic.base_extend(self, S)
def __init__(self, A, f): r""" See ``Conic`` for full documentation. EXAMPLES: :: sage: c = Conic([1, 1, 1]); c Projective Conic Curve over Rational Field defined by x^2 + y^2 + z^2 """ ProjectiveCurve_generic.__init__(self, A, f) self._coefficients = [f[(2, 0, 0)], f[(1, 1, 0)], f[(1, 0, 1)], f[(0, 2, 0)], f[(0, 1, 1)], f[(0, 0, 2)]] self._parametrization = None self._diagonal_matrix = None self._rational_point = None
def __init__(self, A, f): r""" See ``Conic`` for full documentation. EXAMPLES: :: sage: c = Conic([1, 1, 1]); c Projective Conic Curve over Rational Field defined by x^2 + y^2 + z^2 """ ProjectiveCurve_generic.__init__(self, A, f) self._coefficients = [f[(2,0,0)], f[(1,1,0)], f[(1,0,1)], f[(0,2,0)], f[(0,1,1)], f[(0,0,2)]] self._parametrization = None self._diagonal_matrix = None self._rational_point = None
def hom(self, x, Y=None): r""" Return the scheme morphism from ``self`` to ``Y`` defined by ``x``. Here ``x`` can be a matrix or a sequence of polynomials. If ``Y`` is omitted, then a natural image is found if possible. EXAMPLES: Here are a few Morphisms given by matrices. In the first example, ``Y`` is omitted, in the second example, ``Y`` is specified. :: sage: c = Conic([-1, 1, 1]) sage: h = c.hom(Matrix([[1,1,0],[0,1,0],[0,0,1]])); h Scheme morphism: From: Projective Conic Curve over Rational Field defined by -x^2 + y^2 + z^2 To: Projective Conic Curve over Rational Field defined by -x^2 + 2*x*y + z^2 Defn: Defined on coordinates by sending (x : y : z) to (x + y : y : z) sage: h([-1, 1, 0]) (0 : 1 : 0) sage: c = Conic([-1, 1, 1]) sage: d = Conic([4, 1, -1]) sage: c.hom(Matrix([[0, 0, 1/2], [0, 1, 0], [1, 0, 0]]), d) Scheme morphism: From: Projective Conic Curve over Rational Field defined by -x^2 + y^2 + z^2 To: Projective Conic Curve over Rational Field defined by 4*x^2 + y^2 - z^2 Defn: Defined on coordinates by sending (x : y : z) to (1/2*z : y : x) ``ValueError`` is raised if the wrong codomain ``Y`` is specified: :: sage: c = Conic([-1, 1, 1]) sage: c.hom(Matrix([[0, 0, 1/2], [0, 1, 0], [1, 0, 0]]), c) Traceback (most recent call last): ... ValueError: The matrix x (= [ 0 0 1/2] [ 0 1 0] [ 1 0 0]) does not define a map from self (= Projective Conic Curve over Rational Field defined by -x^2 + y^2 + z^2) to Y (= Projective Conic Curve over Rational Field defined by -x^2 + y^2 + z^2) """ if is_Matrix(x): from constructor import Conic y = x.inverse() A = y.transpose()*self.matrix()*y im = Conic(A) if Y == None: Y = im else: q = Y.defining_polynomial()/im.defining_polynomial() if not (q.numerator().is_constant() and q.denominator().is_constant()): raise ValueError, "The matrix x (= %s) does not define a " \ "map from self (= %s) to Y (= %s)" % \ (x, self, Y) x = Sequence(x*vector(self.ambient_space().gens())) return self.Hom(Y)(x, check = False) return ProjectiveCurve_generic.hom(self, x, Y)
def hom(self, x, Y=None): r""" Return the scheme morphism from ``self`` to ``Y`` defined by ``x``. Here ``x`` can be a matrix or a sequence of polynomials. If ``Y`` is omitted, then a natural image is found if possible. EXAMPLES: Here are a few Morphisms given by matrices. In the first example, ``Y`` is omitted, in the second example, ``Y`` is specified. :: sage: c = Conic([-1, 1, 1]) sage: h = c.hom(Matrix([[1,1,0],[0,1,0],[0,0,1]])); h Scheme morphism: From: Projective Conic Curve over Rational Field defined by -x^2 + y^2 + z^2 To: Projective Conic Curve over Rational Field defined by -x^2 + 2*x*y + z^2 Defn: Defined on coordinates by sending (x : y : z) to (x + y : y : z) sage: h([-1, 1, 0]) (0 : 1 : 0) sage: c = Conic([-1, 1, 1]) sage: d = Conic([4, 1, -1]) sage: c.hom(Matrix([[0, 0, 1/2], [0, 1, 0], [1, 0, 0]]), d) Scheme morphism: From: Projective Conic Curve over Rational Field defined by -x^2 + y^2 + z^2 To: Projective Conic Curve over Rational Field defined by 4*x^2 + y^2 - z^2 Defn: Defined on coordinates by sending (x : y : z) to (1/2*z : y : x) ``ValueError`` is raised if the wrong codomain ``Y`` is specified: :: sage: c = Conic([-1, 1, 1]) sage: c.hom(Matrix([[0, 0, 1/2], [0, 1, 0], [1, 0, 0]]), c) Traceback (most recent call last): ... ValueError: The matrix x (= [ 0 0 1/2] [ 0 1 0] [ 1 0 0]) does not define a map from self (= Projective Conic Curve over Rational Field defined by -x^2 + y^2 + z^2) to Y (= Projective Conic Curve over Rational Field defined by -x^2 + y^2 + z^2) """ if is_Matrix(x): from constructor import Conic y = x.inverse() A = y.transpose()*self.matrix()*y im = Conic(A) if Y is None: Y = im else: q = Y.defining_polynomial()/im.defining_polynomial() if not (q.numerator().is_constant() and q.denominator().is_constant()): raise ValueError("The matrix x (= %s) does not define a " \ "map from self (= %s) to Y (= %s)" % \ (x, self, Y)) x = Sequence(x*vector(self.ambient_space().gens())) return self.Hom(Y)(x, check = False) return ProjectiveCurve_generic.hom(self, x, Y)
def hom(self, x, Y=None): r""" Return the scheme morphism from ``self`` to ``Y`` defined by ``x``. Here ``x`` can be a matrix or a sequence of polynomials. If ``Y`` is omitted, then a natural image is found if possible. EXAMPLES: Here are a few Morphisms given by matrices. In the first example, ``Y`` is omitted, in the second example, ``Y`` is specified. :: sage: c = Conic([-1, 1, 1]) sage: h = c.hom(Matrix([[1,1,0],[0,1,0],[0,0,1]])); h Scheme morphism: From: Projective Conic Curve over Rational Field defined by -x^2 + y^2 + z^2 To: Projective Conic Curve over Rational Field defined by -x^2 + 2*x*y + z^2 Defn: Defined on coordinates by sending (x : y : z) to (x + y : y : z) sage: h([-1, 1, 0]) (0 : 1 : 0) sage: c = Conic([-1, 1, 1]) sage: d = Conic([4, 1, -1]) sage: c.hom(Matrix([[0, 0, 1/2], [0, 1, 0], [1, 0, 0]]), d) Scheme morphism: From: Projective Conic Curve over Rational Field defined by -x^2 + y^2 + z^2 To: Projective Conic Curve over Rational Field defined by 4*x^2 + y^2 - z^2 Defn: Defined on coordinates by sending (x : y : z) to (1/2*z : y : x) ``ValueError`` is raised if the wrong codomain ``Y`` is specified: :: sage: c = Conic([-1, 1, 1]) sage: c.hom(Matrix([[0, 0, 1/2], [0, 1, 0], [1, 0, 0]]), c) Traceback (most recent call last): ... ValueError: The matrix x (= [ 0 0 1/2] [ 0 1 0] [ 1 0 0]) does not define a map from self (= Projective Conic Curve over Rational Field defined by -x^2 + y^2 + z^2) to Y (= Projective Conic Curve over Rational Field defined by -x^2 + y^2 + z^2) The identity map between two representations of the same conic: :: sage: C = Conic([1,2,3,4,5,6]) sage: D = Conic([2,4,6,8,10,12]) sage: C.hom(identity_matrix(3), D) Scheme morphism: From: Projective Conic Curve over Rational Field defined by x^2 + 2*x*y + 4*y^2 + 3*x*z + 5*y*z + 6*z^2 To: Projective Conic Curve over Rational Field defined by 2*x^2 + 4*x*y + 8*y^2 + 6*x*z + 10*y*z + 12*z^2 Defn: Defined on coordinates by sending (x : y : z) to (x : y : z) An example not over the rational numbers: :: sage: P.<t> = QQ[] sage: C = Conic([1,0,0,t,0,1/t]) sage: D = Conic([1/t^2, 0, -2/t^2, t, 0, (t + 1)/t^2]) sage: T = Matrix([[t,0,1],[0,1,0],[0,0,1]]) sage: C.hom(T, D) Scheme morphism: From: Projective Conic Curve over Fraction Field of Univariate Polynomial Ring in t over Rational Field defined by x^2 + t*y^2 + 1/t*z^2 To: Projective Conic Curve over Fraction Field of Univariate Polynomial Ring in t over Rational Field defined by 1/t^2*x^2 + t*y^2 + (-2/t^2)*x*z + ((t + 1)/t^2)*z^2 Defn: Defined on coordinates by sending (x : y : z) to (t*x + z : y : z) """ if is_Matrix(x): from constructor import Conic y = x.inverse() A = y.transpose() * self.matrix() * y im = Conic(A) if Y is None: Y = im elif not Y == im: raise ValueError("The matrix x (= %s) does not define a " \ "map from self (= %s) to Y (= %s)" % \ (x, self, Y)) x = Sequence(x * vector(self.ambient_space().gens())) return self.Hom(Y)(x, check=False) return ProjectiveCurve_generic.hom(self, x, Y)
def hom(self, x, Y=None): r""" Return the scheme morphism from ``self`` to ``Y`` defined by ``x``. Here ``x`` can be a matrix or a sequence of polynomials. If ``Y`` is omitted, then a natural image is found if possible. EXAMPLES: Here are a few Morphisms given by matrices. In the first example, ``Y`` is omitted, in the second example, ``Y`` is specified. :: sage: c = Conic([-1, 1, 1]) sage: h = c.hom(Matrix([[1,1,0],[0,1,0],[0,0,1]])); h Scheme morphism: From: Projective Conic Curve over Rational Field defined by -x^2 + y^2 + z^2 To: Projective Conic Curve over Rational Field defined by -x^2 + 2*x*y + z^2 Defn: Defined on coordinates by sending (x : y : z) to (x + y : y : z) sage: h([-1, 1, 0]) (0 : 1 : 0) sage: c = Conic([-1, 1, 1]) sage: d = Conic([4, 1, -1]) sage: c.hom(Matrix([[0, 0, 1/2], [0, 1, 0], [1, 0, 0]]), d) Scheme morphism: From: Projective Conic Curve over Rational Field defined by -x^2 + y^2 + z^2 To: Projective Conic Curve over Rational Field defined by 4*x^2 + y^2 - z^2 Defn: Defined on coordinates by sending (x : y : z) to (1/2*z : y : x) ``ValueError`` is raised if the wrong codomain ``Y`` is specified: :: sage: c = Conic([-1, 1, 1]) sage: c.hom(Matrix([[0, 0, 1/2], [0, 1, 0], [1, 0, 0]]), c) Traceback (most recent call last): ... ValueError: The matrix x (= [ 0 0 1/2] [ 0 1 0] [ 1 0 0]) does not define a map from self (= Projective Conic Curve over Rational Field defined by -x^2 + y^2 + z^2) to Y (= Projective Conic Curve over Rational Field defined by -x^2 + y^2 + z^2) The identity map between two representations of the same conic: :: sage: C = Conic([1,2,3,4,5,6]) sage: D = Conic([2,4,6,8,10,12]) sage: C.hom(identity_matrix(3), D) Scheme morphism: From: Projective Conic Curve over Rational Field defined by x^2 + 2*x*y + 4*y^2 + 3*x*z + 5*y*z + 6*z^2 To: Projective Conic Curve over Rational Field defined by 2*x^2 + 4*x*y + 8*y^2 + 6*x*z + 10*y*z + 12*z^2 Defn: Defined on coordinates by sending (x : y : z) to (x : y : z) An example not over the rational numbers: :: sage: P.<t> = QQ[] sage: C = Conic([1,0,0,t,0,1/t]) sage: D = Conic([1/t^2, 0, -2/t^2, t, 0, (t + 1)/t^2]) sage: T = Matrix([[t,0,1],[0,1,0],[0,0,1]]) sage: C.hom(T, D) Scheme morphism: From: Projective Conic Curve over Fraction Field of Univariate Polynomial Ring in t over Rational Field defined by x^2 + t*y^2 + 1/t*z^2 To: Projective Conic Curve over Fraction Field of Univariate Polynomial Ring in t over Rational Field defined by 1/t^2*x^2 + t*y^2 + (-2/t^2)*x*z + ((t + 1)/t^2)*z^2 Defn: Defined on coordinates by sending (x : y : z) to (t*x + z : y : z) """ if is_Matrix(x): from constructor import Conic y = x.inverse() A = y.transpose() * self.matrix() * y im = Conic(A) if Y is None: Y = im elif not Y == im: raise ValueError( "The matrix x (= %s) does not define a " "map from self (= %s) to Y (= %s)" % (x, self, Y) ) x = Sequence(x * vector(self.ambient_space().gens())) return self.Hom(Y)(x, check=False) return ProjectiveCurve_generic.hom(self, x, Y)