Here is a few Pascal lines calculating sin() and cos() with using
singles precision.
If you need better like doubles, look up some other constants in "Hart
et al, Computer Approximations"
Function Sin(X: Single): Single;
var Sign: Boolean; xx: Single;
begin
Sign:=X<0; if Sign then X:=-X;
x:=X*2/pi; // 0->2pi => 0.000->3.999
x:=4.0*frac(x/4.0);
if x>=3.0 then x:=x-4.0 else if x>=1.0 then x:=2.0-x;
if Sign then x:=-x;
xx:=x*x;
Sin:=x*((((0.000151485129*xx-0.00467376661) // Hart et al, 3341
*xx+0.07968967895)
*xx-0.6459637106)*xx+1.57079631844);
end;
Function Cos(X: Single): Single;
begin
Cos:=Sin(Pi/2+x);
end;
--
Christen Fihl
http://HSPascal.Fihl.net
"Tancredi" <[EMAIL PROTECTED]> wrote in message
news:36212@palm-dev-forum...
I'm looking for a math library for a simple apllication.
How do you make sin and cos (calculator application?).
Thanks!
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palmos.com/dev/tech/support/forums/