Ask Your Question

How to get sage to simplify sin(pi/16)?

asked 2017-03-11 23:00:03 -0500

I'm trying to look at numbers of the form sin(pi/2^n), but when I ask for a list of the first 10, I get [0,1, 1/2sqrt(2), 1/2sqrt(-sqrt(2) + 2), sin(1/16pi), sin(1/32pi)...] Why are these not being reduced, even when I call sin(1/16*pi).simplify_full()? How can I make sage simplify them?

edit retag flag offensive close merge delete

2 answers

Sort by ยป oldest newest most voted

answered 2017-03-12 15:57:46 -0500

mforets gravatar image

updated 2017-03-12 15:59:14 -0500

Two extra ideas:

Try the method radical_expression():

sage: QQbar(sin(pi/16)).radical_expression()
sqrt(-1/2*sqrt(1/4*sqrt(2) + 1/2) + 1/2)

Try with the giac package:

sage: giac('norm(trig2exp(sin(pi/16)))')._sage_()
1/2*sqrt(-sqrt(sqrt(2) + 2) + 2)

(the expressions are the same).

edit flag offensive delete link more

answered 2017-03-12 12:52:14 -0500

calc314 gravatar image

I can't get Sage to do this directly either. Perhaps there is a way that I'm missing.

However, you can use SymPy to do it. The following code does the job.

import sympy as sp

However, the resulting object is not a Sage object. To get it in the appropriate ring for Sage computations, you can convert it to the Symbolic Ring as follows.

SR( sp.expand_trig(sin(pi/16)) )

The result will then have the type: sage.symbolic.expression.Expression.

You can check this by doing:

q = sp.expand_trig(sin(pi/16))
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


Asked: 2017-03-11 23:00:03 -0500

Seen: 57 times

Last updated: Mar 12