Averages/Mean angle: Difference between revisions

m
→‎{{header|REXX}}: increased fuzz in COS function.
m (→‎{{header|REXX}}: added/changed whitespace and comments, simplified some functions.)
m (→‎{{header|REXX}}: increased fuzz in COS function.)
Line 1,325:
end /*select*/; return z
 
cos: procedure; parse arg x; x=r2r(x); numeric fuzz $fuzz(56, 3)
a=abs(x); if a=0 then return 1; 1; if a=pi then return -1
if a=pi*.5 | a=pi*1.5 then return 0; if a=pi/3 then return .5
if a=pi*2/3 then return -.5; return .sinCos(1, 1, -1)
Line 1,346:
 
sqrt: procedure; parse arg x; if x=0 then return 0; d=digits(); i=; m.=9
numeric digits 9; numeric form; h=d+6; if x<0 then do; x=-x; i='i'; end; numeric form; h=d+2
parse value format(x,2,1,,0) 'E0' with g 'E' _ .; g=g*.5'Ee'_%2
do j=0 while h>9; m.j=h; h=h%2+1; end /*j*/
do k=j+5 to 0 by -1; numeric digits m.k; g=.5*(g+x/g)*.5; end /*k*/
numeric digits d; return (g/1)i /*make complex if X < 0.*/</lang>
''output''' &nbsp; when using the default input:
<pre>