6

I noticed that MATLAB has a sin() and sind() functions. I learnt that sin() accepts the angle in radians and sind() accepts the angle in degrees. The only difference I know is sind(180) gives 0 but sin(pi) doesn't:

>> sin(pi)
ans =
  1.2246e-016
>> sind(180)
ans =
     0

What boggles me is whether there is any scenarios or guidelines to choose between using sin() or sind()?

Shai
  • 93,148
  • 34
  • 197
  • 325
barney
  • 131
  • 1
  • 2
  • 5
  • 3
    possible duplicate of [Is there any valid reason radians are used as the inputs to trig function in many modern languages?](http://stackoverflow.com/questions/5147235/is-there-any-valid-reason-radians-are-used-as-the-inputs-to-trig-function-in-man) – marsei Oct 17 '13 at 07:45
  • 1
    @Magla I do not feel this is a duplicate case: the questions are strongly related but are not the same. Question here is of practical nature. – Shai Oct 17 '13 at 08:06

1 Answers1

11

From the documentation of sind:

For integers n, sind(n*180) is exactly zero, whereas sin(n*pi) reflects the accuracy of the floating point value of pi.

So, if you are extremely troubled with the fact that sin( pi ) is not precisly zero, go ahead and use sind, but in practice it is just a wrap-around sin so you actually add a tini-tiny bit of overhead.

Personally, I prefer the elegance of radians and use sin.

Shai
  • 93,148
  • 34
  • 197
  • 325
  • 1
    I fear that kids that use MATLAB in highschool won't survive to graduation. – Eitan T Oct 17 '13 at 08:57
  • 1
    @EitanT I fear that kids that use dgrees instead of radians won't survive graduation... ;) – Shai Oct 17 '13 at 08:57
  • 1
    Why so much hatred for degrees? In some applications degrees are the norm, and make more sense than radians. I'm not sure why you feel the need to insult the intelligence of somebody who computes the sine of 8 degrees instead of 2*pi/45 radians. – nispio Oct 17 '13 at 11:49
  • @nispio try [Euler's identity](http://en.wikipedia.org/wiki/Euler's_identity) with degrees... Radians are of natural-physical nature, while degrees are artificail (why 360 degrees in a circle? why not 400 or 100 or...??). – Shai Oct 17 '13 at 11:57
  • The same class of arguments can be made against feet, inches, gallons, etc., but that does not mean that intelligent people never have to work with those units... – nispio Oct 17 '13 at 15:10