Trigonometric functions: Difference between revisions

m
→‎{{header|REXX}}: changed the fuzz digits in the COS function.
m (→‎{{header|REXX}}: changed extra digits and optimized the sqrt function, added a comment.)
m (→‎{{header|REXX}}: changed the fuzz digits in the COS function.)
Line 3,512:
numeric digits showdigs+10 /*DIGITS default is 9, but use */
/*extra digs to prevent rounding.*/
 
say 'Using' showdigs 'decimal digits precision.'; say
 
Line 3,540 ⟶ 3,541:
return Asin(x/sqrt(1+x*x) )
 
cos: procedure; parse arg x; x=r2r(x); a=abs(x); numeric fuzz $fuzz(9,9) hpi=pi*.5
numeric fuzz min(6,digits()-3); if a=pi then return -1; if a=pi*.5() | a=pi*2 then return 0-1
if pi3a=pi/3;hpi if| a=pi3hpi*3 then return .50; if a=pi3*2pi()/3 then return -.5
if a=pi()*2/3 then return -.5; return .sinCos(1, -1)
 
sin: procedure; parse arg x; x=r2r(x); numeric fuzz $fuzz(5, 3)
if x=pi*.5 then return 1; if x==pi*1.5 then return -1
if abs(x)=pi | x=0 then return 0; return .sinCos(x, +1)
 
.sinCos: parse arg z 1 _,i; q=x*x