First time here? Check out the FAQ!

Ask Your Question
3

Simplify trigonometric expression

asked 10 years ago

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)
Preview: (hide)

2 Answers

Sort by » oldest newest most voted
1

answered 10 years ago

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
Preview: (hide)
link

Comments

rws gravatar imagerws ( 10 years ago )
1

answered 10 years ago

AndreWin gravatar image

updated 10 years ago

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.

Preview: (hide)
link

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 ( 10 years ago )

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: 10 years ago

Seen: 1,789 times

Last updated: Sep 26 '14