Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I was trying to evaluate this product $$ \sin (1^\circ) \sin (2^\circ) \sin (3^\circ) ... \sin (88^\circ) \sin (89^\circ) \sin (90^\circ) $$ But I think it got weird results with this Product[Sin[i], {i, pi/180, pi/2}] Can anyone suggest me something??

share|improve this question

2 Answers 2

up vote 8 down vote accepted

You just have to modify the syntax a little.

  • pi is not a predefined symbol. All predefined constants start with capital letters, and for the number $\pi$ that means you should enter Pi.
  • The Product syntax is probably also not what you want: with the previous correction you would have a range specification of {i, Pi/180, Pi/2}. But i here will still be incremented in integer steps, so there are only two terms in the product.
  • To get a product where i varies in discrete steps that are not integers, you have to add a fourth element to the range specification,

Example:

result = Product[Sin[i], {i, Pi/180, Pi/2, Pi/180}]
  • Finally, you may not be happy with the result of this line either, because it is printed with exact numbers in the arguments of the sine functions. This is because Mathematica tries to be as general as possible, and your input had only exact numbers in it.
  • Exact numbers are symbols like Pi but also the number 180 above. To get a numerical result you have to state somewhere that you want "floating-point" output.
  • This can be done by giving the input as floating-point numbers as in 180.0.
  • Alternatively, you can take the exact value result and convert it to a numerical answer using N,

example:

N[result]

$1.53268\times 10^{-26}$

share|improve this answer
    
thank you so much :) –  Santosh Linkha Jun 16 '12 at 19:20

In addition to Jens' answer, there is a built-in constant Degree which is equal to Degree == Pi/180 so you could simplify your code slightly by doing something like

result = Product[Sin[i Degree], {i,90}]
share|improve this answer
    
thank you too .. :D –  Santosh Linkha Jun 16 '12 at 19:50
2  
@experimentX and of course many other similar ways like Times @@ Sin@Array[# Degree &, 90] or Times @@ Sin /@ (Range[90] Degree) –  belisarius Jun 16 '12 at 20:46

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.