On Sun, Mar 4, 2012 at 2:35 AM, Chris Smith <smi...@gmail.com> wrote: > > > On Sun, Mar 4, 2012 at 10:39 AM, prateek papriwal > <papriwalprat...@gmail.com> wrote: >> >> so somehow we need to merge nsimplify() method into sqrt() method . >> >> in that case when we call sqrt(4.41) >> >> automatically sqrt(nsimplify(4.41,rational=True)) will be called . >> >> > > Since 4.41 is a Float, we don't assume that it is an exact number so the > conversion happens (as Aaron is noted) upon instantiation of the sqrt and > 2.1 is returned. If you know the 4.41 is exact you can enter it as a string > to Rational: > > >>> sqrt(Rational('4.41')) > 21/10 > > Also, it seems the following could be added to Pow: > > def _eval_is_rational(self): > p = self.func(*self.as_base_exp()) # in case it's unevaluated > if not p.is_Pow: > return p.is_rational > b, e = p.as_base_exp() > if e.is_Rational and not e.is_Integer and b.is_Rational: > return False > > This would allow False to be returned for sqrt(3).is_rational (or True for > is_irrational).
+1 to that. Aaron Meurer -- You received this message because you are subscribed to the Google Groups "sympy" group. To post to this group, send email to sympy@googlegroups.com. To unsubscribe from this group, send email to sympy+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sympy?hl=en.