Ask Your Question

Revision history [back]

A solution is to use simplify_sqrt_real, which assumes that x lies in the real domain:

sage: y = sqrt(sin(x)^2 + 4*sin(x) + 4) - sqrt(sin(x)^2 - 4*sin(x) + 4)
sage: from sage.manifolds.utilities import simplify_sqrt_real
sage: simplify_sqrt_real(y)
2*sin(x)

More generally, you can use simplify_chain_real, which applies a chain of simplifications (including simplify_sqrt_real) valid in the real domain:

sage: from sage.manifolds.utilities import simplify_chain_real
sage: simplify_chain_real(y)
2*sin(x)