Ask Your Question

Revision history [back]

Note that the parent of 6/3 is the Rational Field:

sage: a = 6/3
sage: a.parent()
Rational Field

So, when you write (6/3).is_prime(), you ask whether 6/3 is prime as a rational number, see the documentation:

sage: a.is_prime?
A *prime* element is a non-zero, non-unit element p such that,
whenever p divides ab for some a and b, then p divides a or p
divides b.

So, since 6/3 is a unit in QQ, the answer should be False

sage: a.is_unit()
True
sage: a.is_prime()
False

Note that the parent of 6/3 is the Rational Field:

sage: a = 6/3
sage: a.parent()
Rational Field

So, when you write (6/3).is_prime(), you ask whether 6/3 is prime as a rational number, not as an integer, see the documentation:

sage: a.is_prime?
A *prime* element is a non-zero, non-unit element p such that,
whenever p divides ab for some a and b, then p divides a or p
divides b.

So, since 6/3 is a unit in QQ, the answer should be False

sage: a.is_unit()
True
sage: a.is_prime()
False

To see if 6/3 is prime as an integer, just do:

sage: ZZ(6/3).is_prime()
True

Note that the parent of 6/3 is the Rational Field:

sage: a = 6/3
sage: a.parent()
Rational Field

So, when you write (6/3).is_prime(), you ask whether 6/3 is prime as a rational number, number, not as an integer, see the documentation:

sage: a.is_prime?
A *prime* element is a non-zero, non-unit element p such that,
whenever p divides ab for some a and b, then p divides a or p
divides b.

So, since 6/3 is a unit in QQ, the answer should be False

sage: a.is_unit()
True
sage: a.is_prime()
False

To see if 6/3 is prime as an integer, just do:

sage: ZZ(6/3).is_prime()
True

Note that the parent of 6/3 is the Rational Field:

sage: a = 6/3
sage: a.parent()
Rational Field

So, when you write (6/3).is_prime(), you ask whether 6/3 is prime as a rational number, not as an integer, see the documentation:

sage: a.is_prime?
A *prime* element is a non-zero, non-unit element p such that,
whenever p divides ab for some a and b, then p divides a or p
divides b.

So, since 6/3 is a unit in QQ, the answer should be False

sage: a.is_unit()
True
sage: a.is_prime()
False

To see if 6/3 is prime as an integer, just do:

sage: ZZ(6/3).is_prime()
True

So, it is very important in mathematics and in Sage to know where your elements are living. For example the polynomial x^2-2 can not be factorized in $\mathbb{Q}[x]$, but it does in $\overline{\mathbb{Q}}[x]$:

sage: x = polygen(QQ)
sage: (x^2-2).is_irreducible()
True
sage: x = polygen(QQbar)
sage: (x^2-2).is_irreducible()
False