# Affine $$n$$ space over a ring#

sage.schemes.affine.affine_space.AffineSpace(n, R=None, names=None, ambient_projective_space=None, default_embedding_index=None)[source]#

Return affine space of dimension n over the ring R.

EXAMPLES:

The dimension and ring can be given in either order:

sage: AffineSpace(3, QQ, 'x')
Affine Space of dimension 3 over Rational Field
sage: AffineSpace(5, QQ, 'x')
Affine Space of dimension 5 over Rational Field
sage: A = AffineSpace(2, QQ, names='XY'); A
Affine Space of dimension 2 over Rational Field
sage: A.coordinate_ring()
Multivariate Polynomial Ring in X, Y over Rational Field

>>> from sage.all import *
>>> AffineSpace(Integer(3), QQ, 'x')
Affine Space of dimension 3 over Rational Field
>>> AffineSpace(Integer(5), QQ, 'x')
Affine Space of dimension 5 over Rational Field
>>> A = AffineSpace(Integer(2), QQ, names='XY'); A
Affine Space of dimension 2 over Rational Field
>>> A.coordinate_ring()
Multivariate Polynomial Ring in X, Y over Rational Field


Use the divide operator for base extension:

sage: AffineSpace(5, names='x')/GF(17)
Affine Space of dimension 5 over Finite Field of size 17

>>> from sage.all import *
>>> AffineSpace(Integer(5), names='x')/GF(Integer(17))
Affine Space of dimension 5 over Finite Field of size 17


The default base ring is $$\ZZ$$:

sage: AffineSpace(5, names='x')
Affine Space of dimension 5 over Integer Ring

>>> from sage.all import *
>>> AffineSpace(Integer(5), names='x')
Affine Space of dimension 5 over Integer Ring


There is also an affine space associated to each polynomial ring:

sage: R = GF(7)['x, y, z']
sage: A = AffineSpace(R); A
Affine Space of dimension 3 over Finite Field of size 7
sage: A.coordinate_ring() is R
True

>>> from sage.all import *
>>> R = GF(Integer(7))['x, y, z']
>>> A = AffineSpace(R); A
Affine Space of dimension 3 over Finite Field of size 7
>>> A.coordinate_ring() is R
True

class sage.schemes.affine.affine_space.AffineSpace_field(n, R, names, ambient_projective_space, default_embedding_index)[source]#
curve(F)[source]#

Return a curve defined by F in this affine space.

INPUT:

• F – a polynomial, or a list or tuple of polynomials in the coordinate ring of this affine space

EXAMPLES:

sage: A.<x,y,z> = AffineSpace(QQ, 3)
sage: A.curve([y - x^4, z - y^5])                                           # needs sage.schemes
Affine Curve over Rational Field defined by -x^4 + y, -y^5 + z

>>> from sage.all import *
>>> A = AffineSpace(QQ, Integer(3), names=('x', 'y', 'z',)); (x, y, z,) = A._first_ngens(3)
>>> A.curve([y - x**Integer(4), z - y**Integer(5)])                                           # needs sage.schemes
Affine Curve over Rational Field defined by -x^4 + y, -y^5 + z

line_through(p, q)[source]#

Return the line through p and q.

INPUT:

• p, q – distinct rational points of the affine space

EXAMPLES:

sage: # needs sage.libs.singular sage.schemes
sage: A3.<x,y,z> = AffineSpace(3, QQ)
sage: p1 = A3(1, 2, 3)
sage: p2 = A3(4, 5, 6)
sage: L = A3.line_through(p1, p2); L
Affine Curve over Rational Field defined by -1/6*x + 1/6*y - 1/6,
-1/6*x + 1/6*z - 1/3, -1/6*y + 1/6*z - 1/6, -1/6*x + 1/3*y - 1/6*z
sage: L(p1)
(1, 2, 3)
sage: L(p2)
(4, 5, 6)
sage: A3.line_through(p1, p1)
Traceback (most recent call last):
...
ValueError: not distinct points

>>> from sage.all import *
>>> # needs sage.libs.singular sage.schemes
>>> A3 = AffineSpace(Integer(3), QQ, names=('x', 'y', 'z',)); (x, y, z,) = A3._first_ngens(3)
>>> p1 = A3(Integer(1), Integer(2), Integer(3))
>>> p2 = A3(Integer(4), Integer(5), Integer(6))
>>> L = A3.line_through(p1, p2); L
Affine Curve over Rational Field defined by -1/6*x + 1/6*y - 1/6,
-1/6*x + 1/6*z - 1/3, -1/6*y + 1/6*z - 1/6, -1/6*x + 1/3*y - 1/6*z
>>> L(p1)
(1, 2, 3)
>>> L(p2)
(4, 5, 6)
>>> A3.line_through(p1, p1)
Traceback (most recent call last):
...
ValueError: not distinct points

points_of_bounded_height(**kwds)[source]#

Return an iterator of the points in this affine space of absolute height of at most the given bound.

Bound check is strict for the rational field. Requires this space to be affine space over a number field. Uses the Doyle-Krumm algorithm 4 (algorithm 5 for imaginary quadratic) for computing algebraic numbers up to a given height [DK2013].

The algorithm requires floating point arithmetic, so the user is allowed to specify the precision for such calculations. Additionally, due to floating point issues, points slightly larger than the bound may be returned. This can be controlled by lowering the tolerance.

INPUT:

kwds:

• bound – a real number

• tolerance – a rational number in (0,1] used in doyle-krumm algorithm-4

• precision – the precision to use for computing the elements of bounded height of number fields

OUTPUT:

• an iterator of points in self

EXAMPLES:

sage: A.<x,y> = AffineSpace(QQ, 2)
sage: list(A.points_of_bounded_height(bound=3))
[(0, 0), (1, 0), (-1, 0), (1/2, 0), (-1/2, 0), (2, 0), (-2, 0), (0, 1),
(1, 1), (-1, 1), (1/2, 1), (-1/2, 1), (2, 1), (-2, 1), (0, -1), (1, -1),
(-1, -1), (1/2, -1), (-1/2, -1), (2, -1), (-2, -1), (0, 1/2), (1, 1/2),
(-1, 1/2), (1/2, 1/2), (-1/2, 1/2), (2, 1/2), (-2, 1/2), (0, -1/2), (1, -1/2),
(-1, -1/2), (1/2, -1/2), (-1/2, -1/2), (2, -1/2), (-2, -1/2), (0, 2), (1, 2),
(-1, 2), (1/2, 2), (-1/2, 2), (2, 2), (-2, 2), (0, -2), (1, -2), (-1, -2),
(1/2, -2), (-1/2, -2), (2, -2), (-2, -2)]

>>> from sage.all import *
>>> A = AffineSpace(QQ, Integer(2), names=('x', 'y',)); (x, y,) = A._first_ngens(2)
>>> list(A.points_of_bounded_height(bound=Integer(3)))
[(0, 0), (1, 0), (-1, 0), (1/2, 0), (-1/2, 0), (2, 0), (-2, 0), (0, 1),
(1, 1), (-1, 1), (1/2, 1), (-1/2, 1), (2, 1), (-2, 1), (0, -1), (1, -1),
(-1, -1), (1/2, -1), (-1/2, -1), (2, -1), (-2, -1), (0, 1/2), (1, 1/2),
(-1, 1/2), (1/2, 1/2), (-1/2, 1/2), (2, 1/2), (-2, 1/2), (0, -1/2), (1, -1/2),
(-1, -1/2), (1/2, -1/2), (-1/2, -1/2), (2, -1/2), (-2, -1/2), (0, 2), (1, 2),
(-1, 2), (1/2, 2), (-1/2, 2), (2, 2), (-2, 2), (0, -2), (1, -2), (-1, -2),
(1/2, -2), (-1/2, -2), (2, -2), (-2, -2)]

sage: u = QQ['u'].0
sage: A.<x,y> = AffineSpace(NumberField(u^2 - 2, 'v'), 2)                   # needs sage.rings.number_field
sage: len(list(A.points_of_bounded_height(bound=2, tolerance=0.1)))         # needs sage.rings.number_field
529

>>> from sage.all import *
>>> u = QQ['u'].gen(0)
>>> A = AffineSpace(NumberField(u**Integer(2) - Integer(2), 'v'), Integer(2), names=('x', 'y',)); (x, y,) = A._first_ngens(2)# needs sage.rings.number_field
>>> len(list(A.points_of_bounded_height(bound=Integer(2), tolerance=RealNumber('0.1'))))         # needs sage.rings.number_field
529

translation(p, q=None)[source]#

Return the automorphism of the affine space translating p to the origin.

If q is given, the automorphism translates p to q.

INPUT:

• p – a rational point

• q – (default: None) a rational point

EXAMPLES:

sage: A.<x,y,z> = AffineSpace(QQ, 3)
sage: p = A(1,2,3)
sage: q = A(4,5,6)
sage: A.translation(p, q)
Scheme endomorphism of Affine Space of dimension 3 over Rational Field
Defn: Defined on coordinates by sending (x, y, z) to
(x + 3, y + 3, z + 3)
sage: phi = A.translation(p)
sage: psi = A.translation(A.origin(), q)
sage: psi * phi
Scheme endomorphism of Affine Space of dimension 3 over Rational Field
Defn: Defined on coordinates by sending (x, y, z) to
(x + 3, y + 3, z + 3)
sage: psi * phi == A.translation(p, q)
True

>>> from sage.all import *
>>> A = AffineSpace(QQ, Integer(3), names=('x', 'y', 'z',)); (x, y, z,) = A._first_ngens(3)
>>> p = A(Integer(1),Integer(2),Integer(3))
>>> q = A(Integer(4),Integer(5),Integer(6))
>>> A.translation(p, q)
Scheme endomorphism of Affine Space of dimension 3 over Rational Field
Defn: Defined on coordinates by sending (x, y, z) to
(x + 3, y + 3, z + 3)
>>> phi = A.translation(p)
>>> psi = A.translation(A.origin(), q)
>>> psi * phi
Scheme endomorphism of Affine Space of dimension 3 over Rational Field
Defn: Defined on coordinates by sending (x, y, z) to
(x + 3, y + 3, z + 3)
>>> psi * phi == A.translation(p, q)
True

weil_restriction()[source]#

Compute the Weil restriction of this affine space over some extension field.

If the field is a finite field, then this computes the Weil restriction to the prime subfield.

OUTPUT: Affine space of dimension d * self.dimension_relative() over the base field of self.base_ring().

EXAMPLES:

sage: # needs sage.rings.number_field
sage: R.<x> = QQ[]
sage: K.<w> = NumberField(x^5 - 2)
sage: AK.<x,y> = AffineSpace(K, 2)
sage: AK.weil_restriction()
Affine Space of dimension 10 over Rational Field
sage: R.<x> = K[]
sage: L.<v> = K.extension(x^2 + 1)
sage: AL.<x,y> = AffineSpace(L, 2)
sage: AL.weil_restriction()
Affine Space of dimension 4 over Number Field in w
with defining polynomial x^5 - 2

>>> from sage.all import *
>>> # needs sage.rings.number_field
>>> R = QQ['x']; (x,) = R._first_ngens(1)
>>> K = NumberField(x**Integer(5) - Integer(2), names=('w',)); (w,) = K._first_ngens(1)
>>> AK = AffineSpace(K, Integer(2), names=('x', 'y',)); (x, y,) = AK._first_ngens(2)
>>> AK.weil_restriction()
Affine Space of dimension 10 over Rational Field
>>> R = K['x']; (x,) = R._first_ngens(1)
>>> L = K.extension(x**Integer(2) + Integer(1), names=('v',)); (v,) = L._first_ngens(1)
>>> AL = AffineSpace(L, Integer(2), names=('x', 'y',)); (x, y,) = AL._first_ngens(2)
>>> AL.weil_restriction()
Affine Space of dimension 4 over Number Field in w
with defining polynomial x^5 - 2

class sage.schemes.affine.affine_space.AffineSpace_finite_field(n, R, names, ambient_projective_space, default_embedding_index)[source]#
class sage.schemes.affine.affine_space.AffineSpace_generic(n, R, names, ambient_projective_space, default_embedding_index)[source]#

Affine space of dimension $$n$$ over the ring $$R$$.

EXAMPLES:

sage: X.<x,y,z> = AffineSpace(3, QQ)
sage: X.base_scheme()
Spectrum of Rational Field
sage: X.base_ring()
Rational Field
sage: X.category()
Category of schemes over Rational Field
sage: X.structure_morphism()
Scheme morphism:
From: Affine Space of dimension 3 over Rational Field
To:   Spectrum of Rational Field
Defn: Structure map

>>> from sage.all import *
>>> X = AffineSpace(Integer(3), QQ, names=('x', 'y', 'z',)); (x, y, z,) = X._first_ngens(3)
>>> X.base_scheme()
Spectrum of Rational Field
>>> X.base_ring()
Rational Field
>>> X.category()
Category of schemes over Rational Field
>>> X.structure_morphism()
Scheme morphism:
From: Affine Space of dimension 3 over Rational Field
To:   Spectrum of Rational Field
Defn: Structure map


Loading and saving:

sage: loads(X.dumps()) == X
True

>>> from sage.all import *
>>> loads(X.dumps()) == X
True


We create several other examples of affine spaces:

sage: AffineSpace(5, PolynomialRing(QQ, 'z'), 'Z')
Affine Space of dimension 5 over Univariate Polynomial Ring in z over Rational Field

sage: AffineSpace(RealField(), 3, 'Z')                                          # needs sage.rings.real_mpfr
Affine Space of dimension 3 over Real Field with 53 bits of precision

sage: AffineSpace(Qp(7), 2, 'x')                                                # needs sage.rings.padics
Affine Space of dimension 2 over 7-adic Field with capped relative precision 20

>>> from sage.all import *
>>> AffineSpace(Integer(5), PolynomialRing(QQ, 'z'), 'Z')
Affine Space of dimension 5 over Univariate Polynomial Ring in z over Rational Field

>>> AffineSpace(RealField(), Integer(3), 'Z')                                          # needs sage.rings.real_mpfr
Affine Space of dimension 3 over Real Field with 53 bits of precision

>>> AffineSpace(Qp(Integer(7)), Integer(2), 'x')                                                # needs sage.rings.padics
Affine Space of dimension 2 over 7-adic Field with capped relative precision 20


Even 0-dimensional affine spaces are supported:

sage: AffineSpace(0)
Affine Space of dimension 0 over Integer Ring

>>> from sage.all import *
>>> AffineSpace(Integer(0))
Affine Space of dimension 0 over Integer Ring

change_ring(R)[source]#

Return an affine space over ring R and otherwise the same as this space.

INPUT:

• R – commutative ring or morphism.

OUTPUT: An affine space over R.

Note

There is no need to have any relation between R and the base ring of this space, if you want to have such a relation, use self.base_extend(R) instead.

EXAMPLES:

sage: A.<x,y,z> = AffineSpace(3, ZZ)
sage: AQ = A.change_ring(QQ); AQ
Affine Space of dimension 3 over Rational Field
sage: AQ.change_ring(GF(5))
Affine Space of dimension 3 over Finite Field of size 5

>>> from sage.all import *
>>> A = AffineSpace(Integer(3), ZZ, names=('x', 'y', 'z',)); (x, y, z,) = A._first_ngens(3)
>>> AQ = A.change_ring(QQ); AQ
Affine Space of dimension 3 over Rational Field
>>> AQ.change_ring(GF(Integer(5)))
Affine Space of dimension 3 over Finite Field of size 5

sage: K.<w> = QuadraticField(5)                                             # needs sage.rings.number_field
sage: A = AffineSpace(K, 2, 't')                                            # needs sage.rings.number_field
sage: A.change_ring(K.embeddings(CC)[1])                                    # needs sage.rings.number_field
Affine Space of dimension 2 over Complex Field with 53 bits of precision

>>> from sage.all import *
>>> K = QuadraticField(Integer(5), names=('w',)); (w,) = K._first_ngens(1)# needs sage.rings.number_field
>>> A = AffineSpace(K, Integer(2), 't')                                            # needs sage.rings.number_field
>>> A.change_ring(K.embeddings(CC)[Integer(1)])                                    # needs sage.rings.number_field
Affine Space of dimension 2 over Complex Field with 53 bits of precision

chebyshev_polynomial(n, kind='first', monic=False)[source]#

Generate an endomorphism of this affine line by a Chebyshev polynomial.

Chebyshev polynomials are a sequence of recursively defined orthogonal polynomials. Chebyshev of the first kind are defined as $$T_0(x) = 1$$, $$T_1(x) = x$$, and $$T_{n+1}(x) = 2xT_n(x) - T_{n-1}(x)$$. Chebyshev of the second kind are defined as $$U_0(x) = 1$$, $$U_1(x) = 2x$$, and $$U_{n+1}(x) = 2xU_n(x) - U_{n-1}(x)$$.

INPUT:

• n – a non-negative integer.

• kindfirst or second specifying which kind of chebyshev the user would like to generate. Defaults to first.

• monicTrue or False specifying if the polynomial defining the system should be monic or not. Defaults to False.

EXAMPLES:

sage: A.<x> = AffineSpace(QQ, 1)
sage: A.chebyshev_polynomial(5, 'first')                                    # needs sage.schemes
Dynamical System of Affine Space of dimension 1 over Rational Field
Defn: Defined on coordinates by sending (x) to (16*x^5 - 20*x^3 + 5*x)

>>> from sage.all import *
>>> A = AffineSpace(QQ, Integer(1), names=('x',)); (x,) = A._first_ngens(1)
>>> A.chebyshev_polynomial(Integer(5), 'first')                                    # needs sage.schemes
Dynamical System of Affine Space of dimension 1 over Rational Field
Defn: Defined on coordinates by sending (x) to (16*x^5 - 20*x^3 + 5*x)

sage: A.<x> = AffineSpace(QQ, 1)
sage: A.chebyshev_polynomial(3, 'second')                                   # needs sage.schemes
Dynamical System of Affine Space of dimension 1 over Rational Field
Defn: Defined on coordinates by sending (x) to (8*x^3 - 4*x)

>>> from sage.all import *
>>> A = AffineSpace(QQ, Integer(1), names=('x',)); (x,) = A._first_ngens(1)
>>> A.chebyshev_polynomial(Integer(3), 'second')                                   # needs sage.schemes
Dynamical System of Affine Space of dimension 1 over Rational Field
Defn: Defined on coordinates by sending (x) to (8*x^3 - 4*x)

sage: A.<x> = AffineSpace(QQ, 1)
sage: A.chebyshev_polynomial(3, 2)                                          # needs sage.schemes
Traceback (most recent call last):
...
ValueError: keyword 'kind' must have a value of either 'first' or 'second'

>>> from sage.all import *
>>> A = AffineSpace(QQ, Integer(1), names=('x',)); (x,) = A._first_ngens(1)
>>> A.chebyshev_polynomial(Integer(3), Integer(2))                                          # needs sage.schemes
Traceback (most recent call last):
...
ValueError: keyword 'kind' must have a value of either 'first' or 'second'

sage: A.<x> = AffineSpace(QQ, 1)
sage: A.chebyshev_polynomial(-4, 'second')
Traceback (most recent call last):
...
ValueError: first parameter 'n' must be a non-negative integer

>>> from sage.all import *
>>> A = AffineSpace(QQ, Integer(1), names=('x',)); (x,) = A._first_ngens(1)
>>> A.chebyshev_polynomial(-Integer(4), 'second')
Traceback (most recent call last):
...
ValueError: first parameter 'n' must be a non-negative integer

sage: A = AffineSpace(QQ, 2, 'x')
sage: A.chebyshev_polynomial(2)
Traceback (most recent call last):
...
TypeError: affine space must be of dimension 1

>>> from sage.all import *
>>> A = AffineSpace(QQ, Integer(2), 'x')
>>> A.chebyshev_polynomial(Integer(2))
Traceback (most recent call last):
...
TypeError: affine space must be of dimension 1

sage: A.<x> = AffineSpace(QQ, 1)
sage: A.chebyshev_polynomial(7, monic=True)                                 # needs sage.schemes
Dynamical System of Affine Space of dimension 1 over Rational Field
Defn: Defined on coordinates by sending (x) to (x^7 - 7*x^5 + 14*x^3 - 7*x)

>>> from sage.all import *
>>> A = AffineSpace(QQ, Integer(1), names=('x',)); (x,) = A._first_ngens(1)
>>> A.chebyshev_polynomial(Integer(7), monic=True)                                 # needs sage.schemes
Dynamical System of Affine Space of dimension 1 over Rational Field
Defn: Defined on coordinates by sending (x) to (x^7 - 7*x^5 + 14*x^3 - 7*x)

sage: F.<t> = FunctionField(QQ)
sage: A.<x> = AffineSpace(F, 1)
sage: A.chebyshev_polynomial(4, monic=True)                                 # needs sage.schemes
Dynamical System of Affine Space of dimension 1
over Rational function field in t over Rational Field
Defn: Defined on coordinates by sending (x) to (x^4 + (-4)*x^2 + 2)

>>> from sage.all import *
>>> F = FunctionField(QQ, names=('t',)); (t,) = F._first_ngens(1)
>>> A = AffineSpace(F, Integer(1), names=('x',)); (x,) = A._first_ngens(1)
>>> A.chebyshev_polynomial(Integer(4), monic=True)                                 # needs sage.schemes
Dynamical System of Affine Space of dimension 1
over Rational function field in t over Rational Field
Defn: Defined on coordinates by sending (x) to (x^4 + (-4)*x^2 + 2)

coordinate_ring()[source]#

Return the coordinate ring of this scheme, if defined.

EXAMPLES:

sage: R = AffineSpace(2, GF(9,'alpha'), 'z').coordinate_ring(); R           # needs sage.rings.finite_rings
Multivariate Polynomial Ring in z0, z1 over Finite Field in alpha of size 3^2
sage: AffineSpace(3, R, 'x').coordinate_ring()                              # needs sage.rings.finite_rings
Multivariate Polynomial Ring in x0, x1, x2 over Multivariate Polynomial Ring
in z0, z1 over Finite Field in alpha of size 3^2

>>> from sage.all import *
>>> R = AffineSpace(Integer(2), GF(Integer(9),'alpha'), 'z').coordinate_ring(); R           # needs sage.rings.finite_rings
Multivariate Polynomial Ring in z0, z1 over Finite Field in alpha of size 3^2
>>> AffineSpace(Integer(3), R, 'x').coordinate_ring()                              # needs sage.rings.finite_rings
Multivariate Polynomial Ring in x0, x1, x2 over Multivariate Polynomial Ring
in z0, z1 over Finite Field in alpha of size 3^2

ngens()[source]#

Return the number of generators of self, i.e. the number of variables in the coordinate ring of self.

EXAMPLES:

sage: AffineSpace(3, QQ).ngens()
3
sage: AffineSpace(7, ZZ).ngens()
7

>>> from sage.all import *
>>> AffineSpace(Integer(3), QQ).ngens()
3
>>> AffineSpace(Integer(7), ZZ).ngens()
7

origin()[source]#

Return the rational point at the origin of this affine space.

EXAMPLES:

sage: A.<x,y,z> = AffineSpace(QQ, 3)
sage: A.origin()
(0, 0, 0)
sage: _ == A(0,0,0)
True

>>> from sage.all import *
>>> A = AffineSpace(QQ, Integer(3), names=('x', 'y', 'z',)); (x, y, z,) = A._first_ngens(3)
>>> A.origin()
(0, 0, 0)
>>> _ == A(Integer(0),Integer(0),Integer(0))
True

projective_embedding(i=None, PP=None)[source]#

Return a morphism from this space into an ambient projective space of the same dimension.

INPUT:

• i – integer (default: dimension of self = last coordinate) determines which projective embedding to compute. The embedding is that which has a 1 in the i-th coordinate, numbered from 0.

• PP – (default: None) ambient projective space, i.e., codomain of morphism; this is constructed if it is not given.

EXAMPLES:

sage: AA = AffineSpace(2, QQ, 'x')
sage: pi = AA.projective_embedding(0); pi
Scheme morphism:
From: Affine Space of dimension 2 over Rational Field
To:   Projective Space of dimension 2 over Rational Field
Defn: Defined on coordinates by sending (x0, x1) to (1 : x0 : x1)
sage: z = AA(3, 4)
sage: pi(z)
(1/4 : 3/4 : 1)
sage: pi(AA(0,2))
(1/2 : 0 : 1)
sage: pi = AA.projective_embedding(1); pi
Scheme morphism:
From: Affine Space of dimension 2 over Rational Field
To:   Projective Space of dimension 2 over Rational Field
Defn: Defined on coordinates by sending (x0, x1) to (x0 : 1 : x1)
sage: pi(z)
(3/4 : 1/4 : 1)
sage: pi = AA.projective_embedding(2)
sage: pi(z)
(3 : 4 : 1)

>>> from sage.all import *
>>> AA = AffineSpace(Integer(2), QQ, 'x')
>>> pi = AA.projective_embedding(Integer(0)); pi
Scheme morphism:
From: Affine Space of dimension 2 over Rational Field
To:   Projective Space of dimension 2 over Rational Field
Defn: Defined on coordinates by sending (x0, x1) to (1 : x0 : x1)
>>> z = AA(Integer(3), Integer(4))
>>> pi(z)
(1/4 : 3/4 : 1)
>>> pi(AA(Integer(0),Integer(2)))
(1/2 : 0 : 1)
>>> pi = AA.projective_embedding(Integer(1)); pi
Scheme morphism:
From: Affine Space of dimension 2 over Rational Field
To:   Projective Space of dimension 2 over Rational Field
Defn: Defined on coordinates by sending (x0, x1) to (x0 : 1 : x1)
>>> pi(z)
(3/4 : 1/4 : 1)
>>> pi = AA.projective_embedding(Integer(2))
>>> pi(z)
(3 : 4 : 1)

sage: A.<x,y> = AffineSpace(ZZ, 2)
sage: A.projective_embedding(2).codomain().affine_patch(2) == A
True

>>> from sage.all import *
>>> A = AffineSpace(ZZ, Integer(2), names=('x', 'y',)); (x, y,) = A._first_ngens(2)
>>> A.projective_embedding(Integer(2)).codomain().affine_patch(Integer(2)) == A
True

rational_points(F=None)[source]#

Return the list of F-rational points on the affine space self, where F is a given finite field, or the base ring of self.

EXAMPLES:

sage: A = AffineSpace(1, GF(3))
sage: A.rational_points()
[(0), (1), (2)]
sage: A.rational_points(GF(3^2, 'b'))                                       # needs sage.rings.finite_rings
[(0), (b), (b + 1), (2*b + 1), (2), (2*b), (2*b + 2), (b + 2), (1)]

sage: AffineSpace(2, ZZ).rational_points(GF(2))
[(0, 0), (0, 1), (1, 0), (1, 1)]

>>> from sage.all import *
>>> A = AffineSpace(Integer(1), GF(Integer(3)))
>>> A.rational_points()
[(0), (1), (2)]
>>> A.rational_points(GF(Integer(3)**Integer(2), 'b'))                                       # needs sage.rings.finite_rings
[(0), (b), (b + 1), (2*b + 1), (2), (2*b), (2*b + 2), (b + 2), (1)]

>>> AffineSpace(Integer(2), ZZ).rational_points(GF(Integer(2)))
[(0, 0), (0, 1), (1, 0), (1, 1)]

subscheme(X, **kwds)[source]#

Return the closed subscheme defined by X.

INPUT:

• X – a list or tuple of equations.

EXAMPLES:

sage: A.<x,y> = AffineSpace(QQ, 2)
sage: X = A.subscheme([x, y^2, x*y^2]); X
Closed subscheme of Affine Space of dimension 2 over Rational Field defined by:
x,
y^2,
x*y^2

>>> from sage.all import *
>>> A = AffineSpace(QQ, Integer(2), names=('x', 'y',)); (x, y,) = A._first_ngens(2)
>>> X = A.subscheme([x, y**Integer(2), x*y**Integer(2)]); X
Closed subscheme of Affine Space of dimension 2 over Rational Field defined by:
x,
y^2,
x*y^2

sage: # needs sage.libs.singular
sage: X.defining_polynomials ()
(x, y^2, x*y^2)
sage: I = X.defining_ideal(); I
Ideal (x, y^2, x*y^2) of Multivariate Polynomial Ring in x, y over Rational Field
sage: I.groebner_basis()
[y^2, x]
sage: X.dimension()
0
sage: X.base_ring()
Rational Field
sage: X.base_scheme()
Spectrum of Rational Field
sage: X.structure_morphism()
Scheme morphism:
From: Closed subscheme of Affine Space of dimension 2 over Rational Field
defined by: x, y^2, x*y^2
To:   Spectrum of Rational Field
Defn: Structure map
sage: X.dimension()
0

>>> from sage.all import *
>>> # needs sage.libs.singular
>>> X.defining_polynomials ()
(x, y^2, x*y^2)
>>> I = X.defining_ideal(); I
Ideal (x, y^2, x*y^2) of Multivariate Polynomial Ring in x, y over Rational Field
>>> I.groebner_basis()
[y^2, x]
>>> X.dimension()
0
>>> X.base_ring()
Rational Field
>>> X.base_scheme()
Spectrum of Rational Field
>>> X.structure_morphism()
Scheme morphism:
From: Closed subscheme of Affine Space of dimension 2 over Rational Field
defined by: x, y^2, x*y^2
To:   Spectrum of Rational Field
Defn: Structure map
>>> X.dimension()
0

sage.schemes.affine.affine_space.is_AffineSpace(x)[source]#

Return True if x is an affine space.

EXAMPLES:

sage: from sage.schemes.affine.affine_space import is_AffineSpace
sage: is_AffineSpace(AffineSpace(5, names='x'))
doctest:warning...
DeprecationWarning: The function is_AffineSpace is deprecated; use 'isinstance(..., AffineSpace_generic)' instead.
See https://github.com/sagemath/sage/issues/38022 for details.
True
sage: is_AffineSpace(AffineSpace(5, GF(9, 'alpha'), names='x'))                 # needs sage.rings.finite_rings
True
sage: is_AffineSpace(Spec(ZZ))
False

>>> from sage.all import *
>>> from sage.schemes.affine.affine_space import is_AffineSpace
>>> is_AffineSpace(AffineSpace(Integer(5), names='x'))
doctest:warning...
DeprecationWarning: The function is_AffineSpace is deprecated; use 'isinstance(..., AffineSpace_generic)' instead.
See https://github.com/sagemath/sage/issues/38022 for details.
True
>>> is_AffineSpace(AffineSpace(Integer(5), GF(Integer(9), 'alpha'), names='x'))                 # needs sage.rings.finite_rings
True
>>> is_AffineSpace(Spec(ZZ))
False