bug with simplify_radical

5 views
Skip to first unread message

Loïc

unread,
Jan 27, 2011, 12:38:40 PM1/27/11
to sage-support
Hi list,

I found a problem with simplify_radical()

sage: f(x)=asin(2*x/(x^2+1))
sage: g=f.derivative();g
x |--> -2*(2*x^2/(x^2 + 1)^2 - 1/(x^2 + 1))/sqrt(-4*x^2/(x^2 + 1)^2 +
1)
sage: g.simplify_radical()
x |--> -2/(x^2 + 1)

The last answer should be:

x |--> -2/(x^2 + 1)* (x^2-1)/abs(x^2-1)

or easier

x |--> -2/(x^2 + 1)*sign(x^2-1)

Best,

kcrisman

unread,
Jan 27, 2011, 3:55:41 PM1/27/11
to sage-support
Hmm, I'm not sure that's exactly a bug. Well, at least I don't know
that the Maxima people would say so. But here's a simpler example.

sage: h = (2*x^2/(x^2+1)-1)/sqrt(-4*x^2/(x^2+1)^2+1)
sage: h.simplify_radical()
1
sage: h = ((2*x^2-x^2-1)/(x^2+1))/sqrt((x^2-1)^2/(x^2+1)^2) # same as
the other one, but common denominators gotten
sage: h.simplify_radical()
(x^2 - 1)/abs(x^2 - 1)

So I think that Maxima is treating these two expressions differently
in that it might be factoring something out of the square root first
which removes the abs() piece. Simplification does simplify, after
all.

Also, FYI, If you look at the documentation, you'll see "DETAILS: This
uses the Maxima radcan() command." And it does


from sage.calculus.calculus import maxima
maxima.eval('domain: real$')
res = self.parent()(self._maxima_().radcan())
maxima.eval('domain: complex$')
return res

But maybe it should be treated as a bug after all; I'm starting to
think so. In which case we'd want to check it in a newer version of
Maxima.

- kcrisman

Loïc

unread,
Jan 27, 2011, 4:19:36 PM1/27/11
to sage-support
Thanks for your reply,

what you show is very surprising.

Another example in which abs() is corrrectly applied (with no common
denominator)

sage: h=((x^2-1)*x/(x^2+1)^2-x/(x^2+1))/sqrt(-(x^2-1)^2/(x^2 + 1)^2 +
1)
sage: h.simplify_radical()
-x/((x^2 + 1)*abs(x))

Best
Loïc

kcrisman

unread,
Jan 27, 2011, 4:41:59 PM1/27/11
to sage-support
Hmm.

Maxima 5.22.1 http://maxima.sourceforge.net
using Lisp ECL 10.4.1
Distributed under the GNU Public License. See the file COPYING.
Dedicated to the memory of William Schelter.
The function bug_report() provides bug reporting information.
(%i1) radcan((2*x^2/(x^2+1)-1)/sqrt(-4*x^2/(x^2+1)^2+1) );
(%o1) 1
(%i2) radcan(((2*x^2-x^2-1)/(x^2+1))/sqrt((x^2-1)^2/(x^2+1)^2));
2
x - 1
(%o2) --------
! 2 !
!x - 1!
(%i3) radcan(((x^2-1)*x/(x^2+1)^2-x/(x^2+1))/sqrt(-(x^2-1)^2/(x^2 +
1)^2 + 1) );
x
(%o3) - ---------------
2
(x + 1) abs(x)


I don't have access to a current Maxima, but if someone could check
this out in 5.23.2 or whatever the latest is, that would be really
great. Then we'd have to file a bug report there. Certainly the
behavior should be similar for these.

- kcrisman

Loïc

unread,
Jan 28, 2011, 10:38:31 AM1/28/11
to sage-support
With maxima 5.23.2:

(%i1) radcan((2*x^2/(x^2+1)-1)/sqrt(-4*x^2/(x^2+1)^2+1) );
(%o1)
1
radcan(((2*x^2-x^2-1)/(x^2+1))/sqrt((x^2-1)^2/(x^2+1)^2));


2

x - 1
(%o2)
--------
!
2 !
!
x - 1!
radcan(((x^2-1)*x/(x^2+1)^2-x/(x^2+1))/sqrt(-(x^2-1)^2/(x^2 +
1)^2 + 1) );

x
(%o3)
- ---------------

2

(x + 1) abs(x)

same results

Thus, where reporting this bug?

On 27 jan, 22:41, kcrisman <kcris...@gmail.com> wrote:
> Hmm.
>
> Maxima 5.22.1http://maxima.sourceforge.net

kcrisman

unread,
Jan 28, 2011, 11:11:35 AM1/28/11
to sage-support
Reply all
Reply to author
Forward
0 new messages