But...

sage: eq = sqrt((pi-5)^2)
sage: eq.canonicalize_radical()
pi - 5

And as you can read from the documentation
"""
   Choose a canonical branch of the given expression. The square root,
   cube root, natural log, etc. functions are multi-valued. The
   "canonicalize_radical()" method will choose *one* of these values
   based on a heuristic.
"""

As Simon said, be careful if you start using canonicalize_radical
since it does not preserve equality

sage: eq = sqrt((pi-5)^2)
sage: eq.numerical_approx()
1.85840734641021
sage: eq.canonicalize_radical().numerical_approx()
-1.85840734641021

Vincent

2015-02-27 14:36 UTC+01:00, Simon King <simon.k...@uni-jena.de>:
> Hi Paul,
>
> On 2015-02-27, Paul Royik <distantjob...@gmail.com> wrote:
>> What is the way to consistently simplify square roots of squares?
>>
>> Examples:
>>
>> sqrt((x+1)^2) - > x+1
>> sqrt(cos(4*x)+1) -> sqrt(2)cos(2x)
>
> Simplification must not change the value of the expression. sqrt(x^2) is
> certainly not equal to x. Even under the additional assumption that x is
> real, you could only simplify it to abs(x)
>
> Best regards,
> Simon
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "sage-support" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to sage-support+unsubscr...@googlegroups.com.
> To post to this group, send email to sage-support@googlegroups.com.
> Visit this group at http://groups.google.com/group/sage-support.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To post to this group, send email to sage-support@googlegroups.com.
Visit this group at http://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/d/optout.

Reply via email to