In this case I have to agree with Richard. The problem is not for real domains, where it's possible to make a continuous choice of square root. But for complex input there's no nice way to choose which root you want. See http://en.wikipedia.org/wiki/Complex_plane#Multi-valued_relationships_and_branch_pointsfor example; any textbook on complex analysis will have more details. David
On Sun, Mar 11, 2012 at 11:01, Peter H. <peterh8...@gmail.com> wrote: > The mathematical square root is a function, which maps a given domain > value to exactly one range value. That is why textbooks drum into > students' heads that, for example, > 2^2 = (-2)^2 > however > sqrt(2^2) = sqrt((-2)^2) = 2. > Functions do not map one domain value to one range value half the time > and another range value half the time. > > If you change your original example to > f = -sqrt(x^2 + 2*x + 1) > f.full_simplify() > Sage does return > -x - 1 > > I'd say the two examples together show correct behavior. The Sage > user decides which value to assign to f, Sage and Maxima seem to > respect the standard mathematical definition of square root, and the > simplify returns the result that matches the user's assignment. That > may not be what the user wants, but it is correct. > > What your user seems to be looking for seems more like an operation to > show all possible factorizations. I'm new to Sage and haven't > explored all the factorization capability, but if there is such an > operation and Sage only returns positive factors of a square, that > would be a problem. > > On Mar 6, 1:17 pm, Michael Orlitzky <mich...@orlitzky.com> wrote: > > On 03/06/12 12:03, daniel.kho wrote: > > > > > > > > > > > > > > > > > > > > >> sage: f = sqrt(x^2 + 2*x + 1) > > >> sage: f.full_simplify() > > >> x + 1 > > > > >> I think the user should have to try *really* hard to ask us for this > > >> simplification. > > > > >> Right now, simplify() just sends an expression to maxima and back. > Full > > >> simplify does every simplification, including simplify_radical() which > > >> is to blame for the error above. > > > > > Wait a minute... isn't sqrt(x^2 + 2*x +1) = x + 1? > > > Sorry, my math could have turned rusty over the years and I'm *really* > > > new to sage, but I thought there was no error in the simplification? > > > > It is half the time. The other half it's -(x + 1). The Maxima 'domain' > > variable is supposed to control simplifications like this. From the > docs[1]: > > > > Option variable: domain > > > > Default value: real > > > > When domain is set to complex, sqrt (x^2) will remain sqrt (x^2) > > instead of returning abs(x). > > > > In sage, we set this to 'complex', so the sqrt should be left alone. > > However, full_simplify() calls Maxima's radcan() function, which just > > chooses one of the square roots and sticks with it regardless of the > > 'domain' setting. > > > > This is very wrong over the reals, where we *should* get abs(x+1) rather > > than choosing +(x+1) or -(x+1) randomly. > > > > [1]http://maxima.sourceforge.net/docs/manual/en/maxima_9.html > > -- > To post to this group, send an email to sage-devel@googlegroups.com > To unsubscribe from this group, send an email to > sage-devel+unsubscr...@googlegroups.com > For more options, visit this group at > http://groups.google.com/group/sage-devel > URL: http://www.sagemath.org > -- To post to this group, send an email to sage-devel@googlegroups.com To unsubscribe from this group, send an email to sage-devel+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-devel URL: http://www.sagemath.org