home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 5 / 05.iso / a / a075 / 1.img / TOOLKIT1.EXE / SST148.PRG < prev    next >
Encoding:
Text File  |  1989-08-08  |  1.3 KB  |  45 lines

  1. ********************
  2.  
  3. FUNCTION Tangent
  4.  
  5.    * Written and contributed by ESSOR MASO
  6.    *
  7.    * For the input argument in the first eighth circle, degrees -45 <=arg <=45
  8.    *
  9.    * The error ABS(e(arg)) <= 2*10^(-8)
  10.    * The value 2 is returned if either the argument or the D or R is missing,
  11.    * or the ABS(arg) > 45.
  12.    *
  13.    * Correct form: TANGENT(arg,'D')
  14.    *
  15.    * National Bureau of Standards Handbook of Mathematical Functions
  16.  
  17.    PARAMETERS _tanwork, _tandeg
  18.  
  19.    IF TYPE("_tanwork") + TYPE("_tandeg") != "NC"
  20.       RETURN(2)
  21.    ENDIF
  22.  
  23.    SET DECIMAL TO 10
  24.  
  25.    PRIVATE _tanfirst, _tansqu, _tansign
  26.  
  27.    _tansign = (_tanwork < 0.000)
  28.  
  29.    IF ABS(IF(UPPER(_tandeg)#'D',_tanwork, _tanwork * 1.5707963268/90)) > .7853981634 .OR. PCOUNT() # 2
  30.       RETURN(2)
  31.    ENDIF
  32.  
  33.    STORE IF(UPPER(_tandeg)#'D', ABS(_tanwork), ABS(_tanwork) * 1.5707963268/90) TO _tanfirst
  34.    STORE VAL(STR(_tanfirst * _tanfirst, 12, 10)) TO _tanwork, _tansqu
  35.    _tanwork = .0029005250 + .0095168091 * _tansqu
  36.    _tanwork = .0245650893 + _tanwork * _tansqu
  37.    _tanwork = .0533740603 + _tanwork * _tansqu
  38.    _tanwork = .1333923995 + _tanwork * _tansqu
  39.    _tanwork = .3333314036 + _tanwork * _tansqu
  40.    _tanwork = 1 + _tanwork * _tansqu
  41.    _tanwork = ROUNDING(_tanfirst * _tanwork, 8)
  42.    RETURN(IF(_tansign, -_tanwork, _tanwork))
  43.  
  44. * End of File
  45.