ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Sat, 13 Oct 2012 12:00:07 +0200How to check if a square root is irrationalhttps://ask.sagemath.org/question/9417/how-to-check-if-a-square-root-is-irrational/What's the easiest way in sage to check if the square root of a given rational number (for example 1,671 or 2,56) is irrational.
Sat, 13 Oct 2012 11:00:30 +0200https://ask.sagemath.org/question/9417/how-to-check-if-a-square-root-is-irrational/Answer by John Palmieri for <p>What's the easiest way in sage to check if the square root of a given rational number (for example 1,671 or 2,56) is irrational.</p>
https://ask.sagemath.org/question/9417/how-to-check-if-a-square-root-is-irrational/?answer=14025#post-id-14025Convert your numbers to explicit rationals and ask whether their square root is in **Q**:
sage: sqrt(1671/1000) in QQ
False
sage: sqrt(256/100) in QQ
True
sage: sqrt(2) in QQ
False
Or you can do the conversions this way:
sage: sqrt(QQ(1.671)) in QQ
False
Sat, 13 Oct 2012 12:00:07 +0200https://ask.sagemath.org/question/9417/how-to-check-if-a-square-root-is-irrational/?answer=14025#post-id-14025