2.11.1 Algebraic Geometry

You can define arbitrary algebraic varieties in Sage, but sometimes nontrivial functionality is limited to rings over $ \mathbf{Q}$ or finite fields. For example, we compute the union of two affine plane curves, then recover the curves as the irreducible components of the union.

sage: x, y = AffineSpace(2, QQ, 'xy').gens()
sage: C2 = Curve(x^2 + y^2 - 1)
sage: C3 = Curve(x^3 + y^3 - 1)
sage: D = C2 + C3
sage: D
Affine Curve over Rational Field defined by 
   x^5 + x^3*y^2 + x^2*y^3 + y^5 - x^3 - y^3 - x^2 - y^2 + 1
sage: D.irreducible_components()
[
Closed subscheme of Affine Space of dimension 2 over Rational Field defined 
by:  
  x^3 + y^3 - 1,
Closed subscheme of Affine Space of dimension 2 over Rational Field defined 
by:  
  x^2 + y^2 - 1
]

We can also find all points of intersection of the two curves by intersecting them and computing the irreducible components.

sage: V = C2.intersection(C3)
sage: V.irreducible_components()
[
Closed subscheme of Affine Space of dimension 2 over Rational Field defined 
by:
  x + y + 2
  2*y^2 + 4*y + 3,
Closed subscheme of Affine Space of dimension 2 over Rational Field defined 
by:
  y - 1
  x,
Closed subscheme of Affine Space of dimension 2 over Rational Field defined 
by:
  y
  x - 1
]
Thus, e.g., $ (1,0)$ and $ (0,1)$ are on both curves (visibly clear), as are certain (quadratic) points whose $ y$ coordinates satisfy $ 2y^2 + 4y + 3=0$ .

Sage can compute the toric ideal of the twisted cubic in projective 3 space:

sage: R.<a,b,c,d> = PolynomialRing(QQ, 4)
sage: I = ideal(b^2-a*c, c^2-b*d, a*d-b*c)
sage: F = I.groebner_fan(); F
Groebner fan of the ideal:
Ideal (b^2 - a*c, c^2 - b*d, -b*c + a*d) of Multivariate Polynomial Ring
in a, b, c, d over Rational Field
sage: F.reduced_groebner_bases ()
[[-c^2 + b*d, -b*c + a*d, -b^2 + a*c],
 [c^2 - b*d, -b*c + a*d, -b^2 + a*c],
 [c^2 - b*d, b*c - a*d, -b^2 + a*c, -b^3 + a^2*d],
 [c^2 - b*d, b*c - a*d, b^3 - a^2*d, -b^2 + a*c],
 [c^2 - b*d, b*c - a*d, b^2 - a*c],
 [-c^2 + b*d, b^2 - a*c, -b*c + a*d],
 [-c^2 + b*d, b*c - a*d, b^2 - a*c, -c^3 + a*d^2],
 [c^3 - a*d^2, -c^2 + b*d, b*c - a*d, b^2 - a*c]]
sage: F.polyhedralfan()
Polyhedral fan in 4 dimensions of dimension 4

See About this document... for information on suggesting changes.