# why won't simplify multiply out square roots? I was trying to remove half angles in an expression. And it seems simplify() does not like to multiply out square root.

sage:theta=var('theta')
sage:assume(theta,'real')
sage:assume(theta>0)
sage:assume(theta<pi)
sage:m=((sin((1/2)*theta)*cos((1/2)*theta)).trig_expand(half_angles=True))
sage:view(m.simplify_full())


The output I get is $\frac{1}{2}\sqrt{-\cos\left(\theta\right) + 1} \sqrt{\cos\left(\theta\right) + 1}$

Is there a way I can make sage multiply out the the expression and give me $(1/2)sin \theta$

edit retag close merge delete

Hi, I've formatted the code part a bit. The input actually accepts simple formatting called Markdown. For code every line must be indented by four spaces, it can also be done by selecting a range and then hitting "format code" button in the editor that has numbers written on it

Sort by » oldest newest most voted

In general, multi-valued functions shouldn't be simplified "nicely" by default. It should be possible to get Maxima to do something like this using radexpand:True, I think, but I don't believe Sage has this wrapped. It is also NOT obvious in the Maxima documentation what to do unless you really dig...

sage: maxima_console()
(%i1) exp:1/2*sqrt(-cos(theta) + 1)*sqrt(cos(theta) + 1);
sqrt(1 - cos(theta)) sqrt(cos(theta) + 1)
(%o1)              -----------------------------------------
2
(%i2) trigsimp(rootscontract(exp));
abs(sin(theta))
(%o2)                           ---------------
2


There is currently not a consensus on just how much customization should be available through Sage commands. However, the maxima_methods() command allows access to pretty much all of them.

sage: exp = 1/2*sqrt(-cos(theta) + 1)*sqrt(cos(theta) + 1)
sage: exp = exp.maxima_methods().rootscontract(); exp
1/2*sqrt(-cos(theta)^2 + 1)
sage: exp.simplify_full()
1/2*abs(sin(theta))


There are a number of things that the Maxima assumption framework (which Sage uses) doesn't interact with, so perhaps the part where you are trying to ensure sin is positive is one of those things...

more

Probably not what you're looking for, but the best I could do:

sage: sqrt(m^2).simplify_full()
1/2*abs(sin(theta))

more