Trigonometric functions: Difference between revisions

Content added Content deleted
(→‎{{header|PARI/GP}}: added functional version)
m (→‎{{header|REXX}}: added further normalization for degrees to radians that was omitted.)
Line 1,982: Line 1,982:
│ than the desired digits, as specified by the SHOWDIGS variable. │
│ than the desired digits, as specified by the SHOWDIGS variable. │
└──────────────────────────────────────────────────────────────────────────┘</lang>
└──────────────────────────────────────────────────────────────────────────┘</lang>
Most math (POW, EXP, LOG, LN, GAMMA, etc.), trigonometic, and hyperbolic functions need only five extra digits, but ten
Most math (POW, EXP, LOG, LN, GAMMA, etc.), trigonometric, and hyperbolic functions need only five extra digits, but ten
<br>extra digits is safer in case the argument is close to an asymptotic point or a multiple or fractional part of pi or somesuch.
<br>extra digits is safer in case the argument is close to an asymptotic point or a multiple or fractional part of pi or somesuch.
<br>It should also be noted that both the '''pi''' and '''e''' constants have only around 77 decimal digits as included here, if more
<br>It should also be noted that both the '''pi''' and '''e''' constants have only around 77 decimal digits as included here, if more
Line 2,061: Line 2,061:
tan: procedure; arg x; _=cos(x); if _=0 then call tanErr; return sin(x)/_
tan: procedure; arg x; _=cos(x); if _=0 then call tanErr; return sin(x)/_
tanD: return tan(d2r(arg(1)))
tanD: return tan(d2r(arg(1)))
d2d: return arg(1)//360 /*normalize degrees►1 unit circle*/
d2d: return arg(1)//360 /*normalize degrees►1 unit circle*/
d2r: return r2r(arg(1)*pi()/180) /*convert degrees ──► radians. */
d2r: return r2r(d2d(arg(1))*pi()/180) /*convert degrees ──► radians. */
r2d: return d2d((arg(1)*180/pi())) /*convert radians ──► degrees. */
r2d: return d2d((arg(1)*180/pi())) /*convert radians ──► degrees. */
r2r: return arg(1)//(pi()*2) /*normalize radians►1 unit circle*/
r2r: return arg(1)//(pi()*2) /*normalize radians►1 unit circle*/
show: return left(left('',arg(1)>=0)format(arg(1),,showdigs)/1,showdigs)
show: return left(left('',arg(1)>=0)format(arg(1),,showdigs)/1,showdigs)
tellErr: say; say '*** error! ***'; say; say arg(1); say; exit 13
tellErr: say; say '*** error! ***'; say; say arg(1); say; exit 13