ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Mon, 03 Dec 2018 04:22:20 +0100Sage doesn't simplify a fraction if it's multiplied by 2https://ask.sagemath.org/question/44544/sage-doesnt-simplify-a-fraction-if-its-multiplied-by-2/Hello, for some reason sage doesn't simplify a trigonometric expression:
sage: ( 2 * (1-cos(x)) / sqrt(1-cos(x)) ).simplify_full()
-2*(cos(x) - 1)/sqrt(-cos(x) + 1)
while I'd expect `sqrt(1-cos(x))`.
I also tried a nice `simplify_chain_real` function (thanks eric_g for [the hint](https://ask.sagemath.org/question/44414/canonicalize_radical-produces-incorrect-result/?answer=44421#post-id-44421)) but I've got the same result:
sage: from sage.manifolds.utilities import simplify_chain_real
sage: simplify_chain_real( 2 * (1-cos(x)) / sqrt(1-cos(x)) )
-2*(cos(x) - 1)/sqrt(-cos(x) + 1)
The weird thing is that it works without the `2*` part:
sage: ( (1-cos(x)) / sqrt(1-cos(x)) ).simplify_full()
sqrt(-cos(x) + 1)
And even replacing `-` with `+` makes it working:
sage: ( 2*(1+cos(x))/sqrt(1+cos(x)) ).simplify_full()
2*sqrt(cos(x) + 1)
I mean, obviously, it can do that kind of simplification. But I can't make it simplify the `2*(1-cos(x))/sqrt(1-cos(x))` expression. What do I miss?sagenoviceMon, 03 Dec 2018 04:22:20 +0100https://ask.sagemath.org/question/44544/.canonicalize_radical() produces incorrect resulthttps://ask.sagemath.org/question/44414/canonicalize_radical-produces-incorrect-result/I'm trying to simplify some trigonometric expressions using sage, and I noticed that .simplify_full() doesn't optimize those, unless a .canonicalize_radical() is used (thanks slelievre for [the hint](https://ask.sagemath.org/question/44391/simplify_full-doesnt-simplify-an-obvious-trigonometric-expression/?answer=44392#post-id-44392)). But that yields incorrect results for some expressions. For example:
sage: y = sqrt(sin(x)^2 + 4*sin(x) + 4) - sqrt(sin(x)^2 - 4*sin(x) + 4)
sage: y.simplify_full()
sqrt(sin(x)^2 + 4*sin(x) + 4) - sqrt(sin(x)^2 - 4*sin(x) + 4)
.canonicalize_radical() simplifies it further:
sage: y.canonicalize_radical()
4
But that is wrong! The answer should be `2*sin(x)`. Obviously it selected an incorrect sign for the second sqrt(...).
Is there a way to make .canonicalize_radical() smarter? Or any other way to simplify an expression like this correctly?sagenoviceSat, 24 Nov 2018 16:01:17 +0100https://ask.sagemath.org/question/44414/