2
$\begingroup$

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??

$\endgroup$

2 Answers 2

8
$\begingroup$

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}$

$\endgroup$
0
6
$\begingroup$

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}]
$\endgroup$
1
  • 2
    $\begingroup$ @experimentX and of course many other similar ways like Times @@ Sin@Array[# Degree &, 90] or Times @@ Sin /@ (Range[90] Degree) $\endgroup$ Jun 16, 2012 at 20:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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