Ask Your Question
3

Simplify trigonometric expression

asked 2014-05-06 11:21:47 +0100

emiliocba gravatar image

How can I do to obtain 0 in place of:

-1/2*sin(1/16*pi)*sin(3/16*pi)*sin(5/16*pi)*sin(7/16*pi) -
1/2*sin(1/8*pi)*sin(3/8*pi)*sin(5/8*pi)*sin(7/8*pi) -
1/2*sin(3/16*pi)*sin(9/16*pi)*sin(15/16*pi)*sin(21/16*pi) -
1/2*sin(5/16*pi)*sin(15/16*pi)*sin(25/16*pi)*sin(35/16*pi) -
1/2*sin(3/8*pi)*sin(9/8*pi)*sin(15/8*pi)*sin(21/8*pi) -
1/2*sin(7/16*pi)*sin(21/16*pi)*sin(35/16*pi)*sin(49/16*pi) -
1/2*sin(9/16*pi)*sin(27/16*pi)*sin(45/16*pi)*sin(63/16*pi) -
1/2*sin(5/8*pi)*sin(15/8*pi)*sin(25/8*pi)*sin(35/8*pi) -
1/2*sin(11/16*pi)*sin(33/16*pi)*sin(55/16*pi)*sin(77/16*pi) -
1/2*sin(13/16*pi)*sin(39/16*pi)*sin(65/16*pi)*sin(91/16*pi) -
1/2*sin(7/8*pi)*sin(21/8*pi)*sin(35/8*pi)*sin(49/8*pi) -
1/2*sin(15/16*pi)*sin(45/16*pi)*sin(75/16*pi)*sin(105/16*pi) +
1/2*cos(1/16*pi)*cos(3/16*pi)*cos(5/16*pi)*cos(7/16*pi) +
1/2*cos(1/8*pi)*cos(3/8*pi)*cos(5/8*pi)*cos(7/8*pi) +
1/2*cos(3/16*pi)*cos(9/16*pi)*cos(15/16*pi)*cos(21/16*pi) +
1/2*cos(5/16*pi)*cos(15/16*pi)*cos(25/16*pi)*cos(35/16*pi) +
1/2*cos(3/8*pi)*cos(9/8*pi)*cos(15/8*pi)*cos(21/8*pi) +
1/2*cos(7/16*pi)*cos(21/16*pi)*cos(35/16*pi)*cos(49/16*pi) +
1/2*cos(9/16*pi)*cos(27/16*pi)*cos(45/16*pi)*cos(63/16*pi) +
1/2*cos(5/8*pi)*cos(15/8*pi)*cos(25/8*pi)*cos(35/8*pi) +
1/2*cos(11/16*pi)*cos(33/16*pi)*cos(55/16*pi)*cos(77/16*pi) +
1/2*cos(13/16*pi)*cos(39/16*pi)*cos(65/16*pi)*cos(91/16*pi) +
1/2*cos(7/8*pi)*cos(21/8*pi)*cos(35/8*pi)*cos(49/8*pi) +
1/2*cos(15/16*pi)*cos(45/16*pi)*cos(75/16*pi)*cos(105/16*pi)
edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
1

answered 2014-09-26 21:15:23 +0100

nbruin gravatar image

FWIW, maxima does have a routine "trigrat" that simplifies the expression to 0. It just doesn't seem to be tried by default from sage at present:

sage: res =  (-1/2*sin(1/16*pi)* ...
sage: maxima_calculus(A).trigrat()
0
edit flag offensive delete link more

Comments

rws gravatar imagerws ( 2014-09-30 15:52:31 +0100 )edit
1

answered 2014-05-08 09:36:26 +0100

AndreWin gravatar image

updated 2014-05-08 09:40:33 +0100

Hm... Its very strange for me but answer is following:

res = -1/2*sin(1/16*pi)*... # expression in your question
import sympy
sympy.simplify(res) # you will get 0

The strange moment is that next code won't get you 0:

res = -1/2*sin(1/16*pi)*... # expression in your question
res.simplify_full().n() # you will get 6.52256026967279e-16 in Sagemathcloud

I checked all code in Sagemathcloud. In my opinion the difference is because in 2nd way Maxima is used as backend. But now I don't know how to check when you should use Maxima via Sage functions and when - Sympy.

edit flag offensive delete link more

Comments

res.simplify_full().n() will just compute a floating point approximation to the value of the expression. You're just seeing the limited precision at work here. If you call res.simplify_full().n(100) (i.e. use more binary digits) you'll get a smaller value.

nbruin gravatar imagenbruin ( 2014-09-26 21:13:41 +0100 )edit

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: 2014-05-06 11:21:47 +0100

Seen: 1,761 times

Last updated: Sep 26 '14