2 deleted 17 characters in body edited Jun 7 '13 at 10:34 J. M. is away♦ 100k1010 gold badges317317 silver badges474474 bronze badges The only trick I can see is a trivial one: if $$x$$ is the square of a rational, it is also a rational. That's because of the $$x = (a/b)^2 = a^2/b^2$$. So, I'd write a function testing the rationality, which returns either True, False, or Null (if rationality cannot be established): isRational[x_] := If[Simplify[x \[Element]∈ Rationals], True, False, Null]  which works like this: In[30]:= isRational /@ {1/3, \[Pi]π, EulerGamma} Out[30]= {True, False, Null}  And then simply use it by first checking if the number itself is known to be rational: isSqrRational[x_] := If[isRational[x], isRational[Sqrt[x]], False, isRational[Sqrt[x]]]  which gives: In[33]:= isSqrRational /@ {1/3, 1/4, \[Pi]π, EulerGamma} Out[33]= {False, True, False, Null}  The only trick I can see is a trivial one: if $$x$$ is the square of a rational, it is also a rational. That's because of the $$x = (a/b)^2 = a^2/b^2$$. So, I'd write a function testing the rationality, which returns either True, False, or Null (if rationality cannot be established): isRational[x_] := If[Simplify[x \[Element] Rationals], True, False, Null]  which works like this: In[30]:= isRational /@ {1/3, \[Pi], EulerGamma} Out[30]= {True, False, Null}  And then simply use it by first checking if the number itself is known to be rational: isSqrRational[x_] := If[isRational[x], isRational[Sqrt[x]], False, isRational[Sqrt[x]]]  which gives: In[33]:= isSqrRational /@ {1/3, 1/4, \[Pi], EulerGamma} Out[33]= {False, True, False, Null}  The only trick I can see is a trivial one: if $$x$$ is the square of a rational, it is also a rational. That's because of the $$x = (a/b)^2 = a^2/b^2$$. So, I'd write a function testing the rationality, which returns either True, False, or Null (if rationality cannot be established): isRational[x_] := If[Simplify[x ∈ Rationals], True, False, Null]  which works like this: In[30]:= isRational /@ {1/3, π, EulerGamma} Out[30]= {True, False, Null}  And then simply use it by first checking if the number itself is known to be rational: isSqrRational[x_] := If[isRational[x], isRational[Sqrt[x]], False, isRational[Sqrt[x]]]  which gives: In[33]:= isSqrRational /@ {1/3, 1/4, π, EulerGamma} Out[33]= {False, True, False, Null}  1 answered Mar 20 '12 at 15:24 F'x 8,33222 gold badges4545 silver badges8787 bronze badges The only trick I can see is a trivial one: if $$x$$ is the square of a rational, it is also a rational. That's because of the $$x = (a/b)^2 = a^2/b^2$$. So, I'd write a function testing the rationality, which returns either True, False, or Null (if rationality cannot be established): isRational[x_] := If[Simplify[x \[Element] Rationals], True, False, Null]  which works like this: In[30]:= isRational /@ {1/3, \[Pi], EulerGamma} Out[30]= {True, False, Null}  And then simply use it by first checking if the number itself is known to be rational: isSqrRational[x_] := If[isRational[x], isRational[Sqrt[x]], False, isRational[Sqrt[x]]]  which gives: In[33]:= isSqrRational /@ {1/3, 1/4, \[Pi], EulerGamma} Out[33]= {False, True, False, Null}