Ask Your Question
0

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

asked 2017-03-12 06:00:03 +0100

Shamrock-Frost gravatar image

updated 2024-07-09 08:26:20 +0100

FrédéricC gravatar image

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
1

answered 2017-03-12 21:57:46 +0100

mforets gravatar image

updated 2017-03-12 21:59:14 +0100

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
0

answered 2017-03-12 18:52:14 +0100

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
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)
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: 2017-03-12 06:00:03 +0100

Seen: 516 times

Last updated: Mar 12 '17