> I am having some difficulty with the tan() function in Mathlib (April 13
> 1999 version) which seems to be returning incorrect values.
I use MathLib and tan returns .57056112. I suspect that it is
because you are losing some accuracy in the conversion factor of
0.017453. The number pi/180 is not exactly 0.017453.
> Code I am using to demonstrate this is as follows -- essentially it just
> takes a value in degrees and calculates the equivalent in radians and the
> tangent:
> ------------------------------------------------------
> #define radians(angle) ((float) ((angle) * 0.017453))
> #define DBGSAYF(s, x, p) StrCopy(diagmsg, s); \
> StringFToA(diagmsg + StrLen(diagmsg), x, p); \
> ErrNonFatalDisplayIf(true, diagmsg);
>
> // code to calculate x
> DBGSAYF("x: ", (float) x, 5);
> DBGSAYF("radians(x): ", radians(x), 5);
> DBGSAYF("tan(x): ", (float) tan(radians(x)), 5);
> ------------------------------------------------------
>
> Typical results are:
>
> x: 209.70740
> radians(x): 3.66002
> tan(radians(x)): 0.57048 <<<<< should be 0.57056
>
> x: 93.56614
> radians(x): 1.63301
> tan(radians(x)): -16.05292 <<<<< should be -16.04586
>
> Given the time that Mathlib has been around, I expect that the error is
> something I am doing rather than the program but can't see what it is.
> Grateful if anyone could throw any light on the subject.
>
--
-----------------------------------------------------------------
Discussion Group: http://www.halcyon.com/ipscone/wwwboard/
Protect your constitutional rights. Your favorite one may be next!
-----------------------------------------------------------------