GENWiki

Premier IT Outsourcing and Support Services within the UK

User Tools

Site Tools


archive:science:trigfunc
                  TRIGONOMETRIC FUNCTIONS AND EQUIVALENTS
                             (TRIGFUNC.TXT)
      This is a summary of numerous functions and their equivalents
      necessary when working with the language limitations of BASIC
      and others which do not include pre-programmed functions beyond
      sine, cosine, tangent, arctangent and others.
      Many are uncommon and seldom encountered but nevertheless
      valuable under specialized conditions.  Indeed, some solutions
      are rarely mentioned in most references.
      Implementations here are presented in typical BASIC format but
      are readily translated to any other keeping in mind the
      nuances of your working language.  A final section sets forth
      a few programming hints, and tips which help avoid run-time
      errors.

I - Common Functions


Secant SEC(X) = 1 / COS(X)

Cosecant CSC(X) = 1 / SIN(X)

Cotangent COT(X) = 1 / TAN(X)

Inverse Sine ARCSIN(X) = ATN(X / SQR(1-X*X))

Inverse Cosine ARCCOS(X) = - ATN(X / SQR(1-X*X)) + PI/2

Inverse Secant ARCSEC(X) = ATN(SQR(X*X-1)) + (SGN(X) -1) * PI/2

Inverse Cosecant ARCCSC(X) = ATN(1 / SQR(X*X-1)) + (SGN(X) -1) * PI/2

Inverse Cotangent ARCCOT(X) = PI/2 - ATN(X) | or | PI/2 + ATN(-X)

II - Hyperbolic Functions


Sine SINH(X) = (EXP(X) - EXP(-X)) / 2

Cosine COSH(X) = (EXP(X) + EXP(-X)) / 2

Tangent TANH(X) = -2 * EXP(-X) / (EXP(X) + EXP(-X)) + 1

Secant SECH(X) = 2 / (EXP(X) + EXP(-X))

Cosecant CSCH(X) = 2 / (EXP(X) - EXP(-X))

Cotangent COTH(X) = 2 * EXP(-X) / (EXP(X) - EXP(-X)) + 1

Inverse Sine ARCSINH(X) = LOG(X + SQR(X*X+1))

Inverse Cosine ARCCOSH(X) = LOG(X + SQR(X*X-1))

Inverse Tangent ARCTANH(X) = LOG1) / 2

Inverse Secant ARCSECH(X) = LOG2) / X)

Inverse Cosecant ARCCSCH(X) = LOG3) / 2

III - Hints and Tips


The comments related here apply specifically to QuickBasic v4.0 and lower and MS GWBasic, unless otherwise mentioned. Other Basic implementations may be better or worse in certain idiosyncrasies which should be determined by users before placing total faith in any suggested anomoly trapping.

These fundamental needs should be acceptable in all cases:

      PI = 4 * ATN(1)
       J = PI / 180
      J is a facilitiation constant for Degrees - Radians - Degrees
      conversion, thusly:
      Variable (Xd) * J = Variable (Xr) ..... degrees to rads
      Variable (Xr) / J = Variable (Xd) ..... rads to degrees

The question of single or double-precision use may be one of importance to your application. With MS QB, final precision deteriorates significantly when the above trig transformations are employed. In other words, don't expect single precision (7-8 digits) when using s-p or 15-16 digits in d-p.

Depending on vector position, the end result can be as poor as 1/2 the expected accuracy. Also, if one wants highest accuracy, it is essential that low digit numerics (eg: 0.815) be declared as d-p (.815#) otherwise they will be treated as single precision even though attached in a series to a variable which has been declared as d-p.

      CAUTIONS
      --------

1. Entering arguments at or very near ñ1 can produce attempts to

  divide by zero.  Some form of trapping is essential to avoid program
  stoppage.  Appropriate filtering with bypasses, alternate paths
  are suggested.

2. In complex trigometric manipulations it is possible for the end

  result to exceed ñ1.  This may be due to binary quirks or
  simply erroneous procedures.  Some form of trapping is also
  needed to avoid crashes when such are used as entering arguments.

3. Similarly, trapping is required for 0 and -X values when entering

  some functions using LOG.  Also note that a few functions with SQR
  have other invalid ranges for entering arguments.

IV - Acknowledgement

      Source material for Sections I and II from Texas Instruments,
      TI Extended BASIC handbook for the TI-99/4, 1981.

Prepared by Anthony W. Severdia : San Francisco, CA : FEB 1989 This file is in Public Domain


     For QUality and Excellence in bbs'ing, visit & join  QU-AN-TO
                       QUantitative ANalytic TOols
                      ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
     (415) 255-2981         ÄÄ   24 Hours   ÄÄ         3/12/2400 Baud
     Sysop - Dr. Ken Hunter                    San Francisco, CA  USA
     û Mathematics    û Statistics    û Decision Support    û Finance
     û Sciences   û Engineering   û Programming Languages   û More
     û Celestial Navigation Forum (W)     Tony Severdia (Ass't Sysop)

–End

Downloaded from Just Say Yes. 2 lines, More than 500 files online!

       Full access on first call. 415-922-2008 CASFA 

Another file downloaded from:

!

  1. $- & the Temple of the Screaming Electron

! * Walnut Creek, CA

 +    /^   |
 !    | |//^  _^_     2400/1200/300 baud  (415) 935-5845  
/^  /   @ |  /_-_            Jeff Hunter, Sysop
|@ _| @     @|- - -|                                     
|  | |    /^ |  _  |                  - - - - - - - - - * 
|___/____|_|_|_(_)_|       Aaaaaeeeeeeeeeeeeeeeeee!   /   

Specializing in conversations, E-Mail, obscure information,

 entertainment, the arts, politics, futurism, thoughtful discussion, 
        insane speculation, and wild rumours. An ALL-TEXT BBS.

"Raw data for raw minds."

1)
1+X) / (1-X
2)
1+SQR(1-X*X
3)
SGN(X) * SQR(X*X+1) + 1) / X) Inverse Cotangent ARCCOTH(X) = LOG((X+1) / (X-1
/data/webs/external/dokuwiki/data/pages/archive/science/trigfunc.txt · Last modified: 2001/11/04 06:14 by 127.0.0.1

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki