home *** CD-ROM | disk | FTP | other *** search
- ********************
-
- FUNCTION Tangent
-
- * Written and contributed by ESSOR MASO
- *
- * For the input argument in the first eighth circle, degrees -45 <=arg <=45
- *
- * The error ABS(e(arg)) <= 2*10^(-8)
- * The value 2 is returned if either the argument or the D or R is missing,
- * or the ABS(arg) > 45.
- *
- * Correct form: TANGENT(arg,'D')
- *
- * National Bureau of Standards Handbook of Mathematical Functions
-
- PARAMETERS _tanwork, _tandeg
-
- IF TYPE("_tanwork") + TYPE("_tandeg") != "NC"
- RETURN(2)
- ENDIF
-
- SET DECIMAL TO 10
-
- PRIVATE _tanfirst, _tansqu, _tansign
-
- _tansign = (_tanwork < 0.000)
-
- IF ABS(IF(UPPER(_tandeg)#'D',_tanwork, _tanwork * 1.5707963268/90)) > .7853981634 .OR. PCOUNT() # 2
- RETURN(2)
- ENDIF
-
- STORE IF(UPPER(_tandeg)#'D', ABS(_tanwork), ABS(_tanwork) * 1.5707963268/90) TO _tanfirst
- STORE VAL(STR(_tanfirst * _tanfirst, 12, 10)) TO _tanwork, _tansqu
- _tanwork = .0029005250 + .0095168091 * _tansqu
- _tanwork = .0245650893 + _tanwork * _tansqu
- _tanwork = .0533740603 + _tanwork * _tansqu
- _tanwork = .1333923995 + _tanwork * _tansqu
- _tanwork = .3333314036 + _tanwork * _tansqu
- _tanwork = 1 + _tanwork * _tansqu
- _tanwork = ROUNDING(_tanfirst * _tanwork, 8)
- RETURN(IF(_tansign, -_tanwork, _tanwork))
-
- * End of File