I say slightly because it is related to a Math problem.  But the problem
may have more to do with the Palm than math.  Don't know.  I'm sure
others have seen this.

I use MathLib for Trig functions.  Sin and Tan seem to work fine.  But
Cos has a quirk.  cos(0)=1 but cos(90)=2.8328e-16.  Now I know that is
headed toward zero but it's not zero.  I have looked at many Palm
calculator applications and find that this is consistent on every calc
that I have tested.  One reports cos(90) as 6.123e-17 another 2.8328e-16
one with 8.9e-15.  I did find one that reported zero.

At first I wondered if it was in the DoubleToAscii conversion or in the
MathLib calculation.  So, I tested the answer before it was converted to
a string and it was NOT zero.  So, I guess this leaves the problem
either in the MathLib calculation or rounding in the input parameter
before it is sent to MathLib->cos.  

MathLib expects radians so I use: (double) param*pi/180.00 to convert an
angle (90) to radians.  That might be where the rounding comes in.  I
have pi as 3.14159265358979311600L.  Is there a more accurate
representation of pi?

ACos seems to work fine: acos(1)=0, acos(0)=90.

What I am wondering is:
1) Anyone know what causes this?
2) Is there a fix?

I have tested very small changes up to and just past 90 degrees and the
sign is always correct.  It just seems that there is some reason that it
does not get to zero.

Would it be bad math to just check for multiple of 90 and report 0
without calling the MathLib cos function?

I would appreciate it if anyone can help me with a solution to this
problem.

Thanks

----------------------------------------------------
Shoot-to-Win

Protect the 2nd Amendment
----------------------------------------------------

Reply via email to