Ask Your Question
5

why won't simplify multiply out square roots?

asked 2010-12-02 10:06:54 -0500

Shashank gravatar image

updated 2010-12-02 12:46:39 -0500

Evgeny gravatar image

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 flag offensive close merge delete

Comments

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

Evgeny gravatar imageEvgeny ( 2010-12-02 12:49:07 -0500 )edit

2 answers

Sort by ยป oldest newest most voted
4

answered 2010-12-02 14:53:45 -0500

kcrisman gravatar image

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...

edit flag offensive delete link more
0

answered 2010-12-02 14:30:33 -0500

Jason Bandlow gravatar image

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

sage: sqrt(m^2).simplify_full()
1/2*abs(sin(theta))
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2010-12-02 10:06:54 -0500

Seen: 2,230 times

Last updated: Dec 02 '10