Trigonometric functions: Difference between revisions
Content deleted Content added
m →{{header|REXX}}: added further normalization for degrees to radians that was omitted. |
m →{{header|REXX}}: expanded some subroutine source code to the original, changed some wording in comments. |
||
Line 2,017: | Line 2,017: | ||
return z |
return z |
||
Atan: procedure; arg x; if abs(x)=1 then return pi() |
Atan: procedure; arg x; if abs(x)=1 then return pi()*.25*sign(x) |
||
return Asin(x/sqrt(1+x* |
return Asin(x/sqrt(1+x*x)) |
||
cos: procedure; arg x; x=r2r(x); a=abs(x); numeric fuzz min(9,digits()-9) |
cos: procedure; arg x; x=r2r(x); a=abs(x); numeric fuzz min(9,digits()-9) |
||
if a=pi() then return -1; if a=pi()*.5 | a=pi()*2 then return 0 |
if a=pi() then return -1; if a=pi()*.5 | a=pi()*2 then return 0 |
||
pi3=pi()/3; if a=pi3 then return .5; if a=2*pi3 then return -.5 |
|||
return .sinCos(1,1,-1) |
return .sinCos(1,1,-1) |
||
Line 2,039: | Line 2,039: | ||
e: return, |
e: return, |
||
2.7182818284590452353602874713526624977572470936999595749669676277240766303535 |
2.7182818284590452353602874713526624977572470936999595749669676277240766303535 |
||
/*Note: the |
/*Note: the actual E subroutine returns E's accuracy that */ |
||
/*matches the current NUMERIC DIGITS, up to 1 million digits.*/ |
/*matches the current NUMERIC DIGITS, up to 1 million digits.*/ |
||
/*If more than 1 million digits are required, be patient. */ |
/*If more than 1 million digits are required, be patient. */ |
||
Line 2,049: | Line 2,049: | ||
pi: return, /*a bit of overkill, but hey !! */ |
pi: return, /*a bit of overkill, but hey !! */ |
||
3.1415926535897932384626433832795028841971693993751058209749445923078164062862 |
3.1415926535897932384626433832795028841971693993751058209749445923078164062862 |
||
/*Note: |
/*Note: the actual PI subroutine returns PI's accuracy that */ |
||
/*matches the current NUMERIC DIGITS, up to 1 million digits.*/ |
/*matches the current NUMERIC DIGITS, up to 1 million digits.*/ |
||
/*John Machin's formula is used for calculating more digits. */ |
/*John Machin's formula is used for calculating more digits. */ |