Ask Your Question

Why is_prime(6/3) results as False?

asked 2015-03-06 19:46:49 +0200

logomath gravatar image

updated 2015-03-06 20:50:51 +0200

tmonteil gravatar image
sage: (6/3).is_integer()

sage: (6/3).is_prime()
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2015-03-06 20:39:12 +0200

tmonteil gravatar image

updated 2015-03-06 20:48:22 +0200

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()
sage: a.is_prime()

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

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

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()
sage: x = polygen(QQbar)
sage: (x^2-2).is_irreducible()
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2015-03-06 19:46:49 +0200

Seen: 2,112 times

Last updated: Mar 06 '15