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.
asked 2012-10-13 11:00:30 +0100
Anonymous
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.
Convert 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
Please start posting anonymously - your entry will be published after you log in or create a new account.
Asked: 2012-10-13 11:00:30 +0100
Seen: 2,033 times
Last updated: Oct 13 '12
Counting number of trues in a 1000 line answer
check if the result is a real number
Why is 3e1 not equivalent to 30?
Converting string into number does not work properly
What are the different real numbers in Sage ?
What are the differences between RealDoubleField() and RealField(53) ?
Get Sage to display the 2nd x value, when function is set to 0?