Possible Sqrt Simplification Bug

35 views
Skip to first unread message

Zak V

unread,
Oct 29, 2014, 4:06:00 AM10/29/14
to sage-s...@googlegroups.com
Hello,
    I believe I found a bug in how radicals are simplified.  The general idea is that sqrt(x^2)=abs(x), but sage simplifies sqrt(x^2) to x instead, even if x is negative.  I've included a simple example below.  

sage: x = var('x')
sage: assume(x<0)
sage: expr = sqrt(x^2)
sage: simp_expr=expr.simplify_radical()
sage: eqn = expr==simp_expr
sage: print eqn
sqrt(x^2) == x
sage: print eqn.subs(x=-1) #Clearly this is wrong
1 == -1
sage: abs(x).simplify() #However, Sage knows how to deal with abs(x) for x<0
-x

I've never used the Sage Trac system before, so I thought posting this to here might instead might be a good idea.  Hope this is helpful.

Cheers,
Zak

kcrisman

unread,
Oct 29, 2014, 8:32:21 AM10/29/14
to sage-s...@googlegroups.com
For more or less this reason, simplify_radical was removed from simplify_full.  However, it is still useful.  See http://www.sagemath.org/doc/reference/calculus/sage/symbolic/expression.html#sage.symbolic.expression.Expression.simplify_radical for some specifics on exactly what it claims (and doesn't claim) to do.  In particular, one can have arbitrarily long arguments (and we have) about exactly what the underlying Maxima "radcan" really "should" do.  I don't think this counts as a bug, but rather as user beware - simplifications sometimes are indeed simplifications, like x^2/x = x.

Or, if it's because of the assumption, I think that Maxima's simplification methods do not take that into account.   The method simplify() just sends to Maxima and back, and for that it does take it into account.

- kcrisman

Reply all
Reply to author
Forward
0 new messages