Re: C's trig functions



John Smith <JSmith@xxxxxxxx> writes:
> I just broke up with my girlfriend, so, to sublimate my sexual
> tensions, I began reading this:
>
> http://forensics.calcinfo.com/
>
> This guy has developed a method that he uses to determine chip lineage
> in old calculators (he needs a girlfriend too). Various chips will
> produce various results when you make this calculation:
>
> n = sin(cos(tan(atan(acos(asin(9.0)))))) in degrees.

What do you expect asin(9.0) to do? asin() expects an argument in the
range -1.0 to +1.0, and returns an angle (normally in radians); it
fails if its argument is outside that range. Converting asin()'s
argument from degrees to radians makes no mathematical sense; if you
want to work in degrees, you need to convert the *result* from radians
to degrees.

> With the Windows calculator I get the following results starting with
> sin(9.0)in degree mode:
[...]

Starting with sin(9.0) is inconsistent with the expression above. I
suspect what you mean is:

n = asin(acos(atan(tan(cos(sin(9.0))))))

(where 9.0 is in degrees).

As you know, unlike most interactive calculators, C's trig functions
have no "degree mode", which is why you need to do the conversions
manually. The C equivalent of sin(x), where x is expressed in
degrees, would be sin(DEG2RAD(x)). The C equivalent of asin(x), where
the result is to be expressed in degrees, would be RAD2DEG(asin(x)).

--
Keith Thompson (The_Other_Keith) kst-u@xxxxxxx <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
.



Relevant Pages

  • Re: SIN and COS Functions
    ... > calculators and tresult in excell is not correct. ... Is there a fix? ... As stated in XL Help, XL's trig functions operate in Radians, not ...
    (microsoft.public.mac.office.excel)
  • Re: sin/sind
    ... > among the surveying community especially in Europe and North ... > Africa. ... trick to play on other pupil's calculators when I was in school. ... work in radians, the answers would be obviously 'wrong' (if you thought ...
    (comp.lang.fortran)
  • Re: cos cos cos
    ... In view, select scientific and radians. ... Now press cos about 190 times until the number stops changing. ... Other calculators give me the same number: ...
    (sci.math)
  • Re: cos cos cos
    ... In view, select scientific and radians. ... Now press cos about 190 times until the number stops changing. ... Other calculators give me the same number: ...
    (sci.math)