# 基本环¶

• 负整数合称整数 {{..., -1, 0, 1, 2, ...}} ，叫做 ZZ 在萨奇。

• 有理数——即整数的分数或比率——称为 QQ 在萨奇。

• 实数，叫做 RR 在萨奇。

• 复数，叫做 CC 在萨奇。

sage: ratpoly.<t> = PolynomialRing(QQ)
sage: realpoly.<z> = PolynomialRing(RR)


sage: factor(t^2-2)
t^2 - 2
sage: factor(z^2-2)
(z - 1.41421356237310) * (z + 1.41421356237310)


sage: i  # square root of -1
I
sage: i in QQ
False


sage: reset('i')


sage: i = CC(i)       # floating point complex number
sage: i == CC.0
True
sage: a, b = 4/3, 2/3
sage: z = a + b*i
sage: z
1.33333333333333 + 0.666666666666667*I
sage: z.imag()        # imaginary part
0.666666666666667
sage: z.real() == a   # automatic coercion before comparison
True
sage: a + b
2
sage: 2*b == a
True
sage: parent(2/3)
Rational Field
sage: parent(4/2)
Rational Field
sage: 2/3 + 0.1       # automatic coercion before addition
0.766666666666667
sage: 0.1 + 2/3       # coercion rules are symmetric in SAGE
0.766666666666667


sage: RationalField()
Rational Field
sage: QQ
Rational Field
sage: 1/2 in QQ
True


sage: 1.2 in QQ
True
sage: pi in QQ
False
sage: pi in RR
True
sage: sqrt(2) in QQ
False
sage: sqrt(2) in CC
True


sage: GF(3)
Finite Field of size 3
sage: GF(27, 'a')  # need to name the generator if not a prime field
Finite Field in a of size 3^3
sage: Zp(5)
5-adic Ring with capped relative precision 20
sage: sqrt(3) in QQbar # algebraic closure of QQ
True