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

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

Sort by » oldest newest most voted

Two extra ideas:

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

more

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

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))
type(q)
more