simplify and sqrt

43 views
Skip to first unread message

xl...@free.fr

unread,
Jan 26, 2011, 2:41:46 AM1/26/11
to sage-s...@googlegroups.com

Hello,

Version: sage 4.6.1
I'm quite a newbie with Sage but I'm really impressed by this powerful software.
Since an hour, I'm on a stupid problem:

sage: sqrt(2)*sqrt(3)
sqrt(2)*sqrt(3)
sage: sqrt(2)*sqrt(3)-sqrt(6)
sqrt(2)*sqrt(3)-sqrt(6)

I would expect results sqrt(6) and 0...
I try with the command simplify() but it doesn't do anything.

That's very odd because:

sage: sqrt(75)+2*sqrt(48)
13*sqrt(3)

(Here it simplifies the operation)
Can anyone help me ?

Thanks in advance

lo�c

Message has been deleted

Johan Grönqvist

unread,
Jan 26, 2011, 5:44:13 AM1/26/11
to sage-s...@googlegroups.com
2011-01-26 09:14, Minh Nguyen skrev:

> On Wed, Jan 26, 2011 at 6:41 PM,<xl...@free.fr> wrote:
>> sage: sqrt(2)*sqrt(3)-sqrt(6)
>> sqrt(2)*sqrt(3)-sqrt(6)
>>
>> I would expect results sqrt(6) and 0...
>> I try with the command simplify() but it doesn't do anything.

> In the above Sage session, you declared two symbolic expressions. So
> it is possible to use methods defined on symbolic expressions other
> than simplify(). In the present case, you want to use the
> simplify_radical() method to simplify radicals:

Thanks.
However...

I am surprised that simplify is sufficient on symbolic variables
denoting positive numbers:

sage: assume(x>0, y>0)
sage: (sqrt(x)*sqrt(y)-sqrt(x*y)).simplify()
0
sage: (sqrt(2)*sqrt(3)-sqrt(2*3)).simplify()
sqrt(2)*sqrt(3) - sqrt(6)


I am particularly surprised by:

sage: (sqrt(x)*sqrt(y)-sqrt(x*y)).subs(x=2)
0
sage: (sqrt(x)*sqrt(y)-sqrt(x*y)).subs(x=2, y=3).simplify()
sqrt(2)*sqrt(3) - sqrt(6)

(We did not even need the call to simplify when substituting only x=2.)

Is it reasonable to consider the last example a bug?

Of course, the answer sage gives is correct, but it is certainly not the
behaviour I would expect.

Regards

Johan

Reply all
Reply to author
Forward
0 new messages