Hi, On Mon, 03 May 2010 06:55:25 -0500 Jason Grout <jason-s...@creativetrax.com> wrote:
> On 05/03/2010 06:45 AM, Simon King wrote: > > Hi Maite, > > > > On May 3, 11:15 am, Maite Aranes<maite.al...@gmail.com> wrote: > >> Does sage use symbolic calculus if it has to compare two symbolic > >> expressions inside an "if" clause? > > > > I don't know much about the symbolic part of Sage, but I think that > > punch line is that the evaluation of a symbolic expression to a > > boolean returns False if it is not guaranteed to be True. In your > > case, I could imagine that the symbolic sqrt(...) does not choose > > one particular root (could be positive or negative), and so > > 1/3*sqrt(2/5)==2/3*sqrt(1/10) is indeed not necessarily true. > > > > When we ask a slightly different, but equivalent question: > > sage: (1/3*sqrt(2/5)-2/3*sqrt(1/10)).full_simplify() > 0 > > In general, symbolic computation (and seeing if expressions are > equal) is very hard. In this case, I think the problem is that not > enough simplification is done automatically to see if they are equal. I agree that symbolic comparison, especially the case where there are no variables in the expression, should be improved. Most of that code was written during the symbolics switch rush. AFAICT, at the moment we try to coerce to RIF. This works great for checking obvious inequalities, but doesn't help with proving an equality. <snip> > > But you can transform both sides of the equation into algebraic > > numbers, and they do compare equal (since the positive square root > > is picked): > > sage: QQbar(1/3*sqrt(2/5))==QQbar(2/3*sqrt(1/10)) > > True > > sage: QQbar(1/3*sqrt(2/5)) > > 0.2108185106778920? > > > > Transforming to QQbar is a good idea, if your expression can be > handled by QQbar (for example, if your expression had a pi in it, it > probably wouldn't work). This is indeed a good idea. I wonder how expensive it would be to put this check for equality if we fail to falsify the relation using interval arithmetic. Relevant code is in sage.symbolic.expression.Expression.test_relation(), if anybody wants to try this approach. Shall we open a ticket for this? Thanks. Burcin -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org