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 think the symbolic square root does pick a particular root:
sage: sqrt(3).n()
1.73205080756888
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).
Jason
--
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