# .simplify_full() doesn't simplify an obvious trigonometric expression

Hello, I'm trying to simplify a trigonometric expression, and it didn't work as I expected. The original example was larger, but I reproduced the issue with a smaller one:

sage: y = (sin(x)+2) * sqrt( sin(x) / (sin(x)^2 + 4*sin(x) + 4) )
sage: y.simplify_full()
sqrt(sin(x)/(sin(x)^2 + 4*sin(x) + 4))*(sin(x) + 2)


Why doesn't that turn into sqrt(sin(x))? What do I miss?

edit retag close merge delete

Sort by » oldest newest most voted

This is because simplify_full does not attack square roots.

There is another method for doing that, which is called canonicalize_radical.

sage: y = (sin(x) + 2) * sqrt(sin(x) / (sin(x)^2 + 4 * sin(x) + 4))
sqrt(sin(x))

more

Ah, thank you! I've just read canonicalize_radical docs and it looks unsafe to use blindly. I experimented with it a little and reproduced a problem: ( (sin(x)-2) * sqrt( sin(x) / (sin(x)^2 - 4*sin(x) + 4) ) ).canonicalize_radical() becomes "sqrt(sin(x))" while it should be "-sqrt(sin(x))". I wonder if there's a way to tell it the sign to simplify sqrt()... But that should probably be another question. Thanks for your answer!

1

Yes, I think the "unsafe to use blindly" aspect was one reason for removing "canonicalize_radical" (which at the time was called "simplify_radical") from "simplify_full", in Sage Trac ticket 12737.

The sign issue is a recurring discussion which every time leads to a debate about what "sqrt" stands for: a multivalued function from the complex numbers to the complex numbers, or a single-valued function from the non-negative reals to the non-negative reals.

Thanks for the link and details! Personally I'd say sqrt() is a single-valued conditional function, and its symbolic representation depends on the sign of its argument, like, sqrt(x^2) = {x if x>=0; -x if x<0 }. It's just in my case the sign was known, so I hoped sage would guess that... Anyway, I posted that as a separate "canonicalize_radical produces incorrect result" question. I hope it makes sense.