Microsoft KB Archive/28249

From BetaArchive Wiki
Knowledge Base


How to Derive Inverse (ARC) and Hyperbolic Trig Functions

Article ID: 28249

Article Last Modified on 8/16/2005



APPLIES TO

  • Microsoft Visual Basic for MS-DOS
  • Microsoft BASIC Compiler 6.0
  • Microsoft BASIC Compiler 6.0b
  • Microsoft Business BASIC Compiler 1.0
  • Microsoft Business BASIC Compiler 1.0
  • Microsoft GW-BASIC 3.2
  • Microsoft GW-BASIC 3.22
  • Microsoft GW-BASIC 3.23
  • Microsoft GW-BASIC 5.28
  • Microsoft BASIC Interpreter 1.0
  • Microsoft BASIC Interpreter 1.01 for Macintosh
  • Microsoft BASIC Interpreter 2.0
  • Microsoft BASIC Interpreter 2.1 for Macintosh
  • Microsoft BASIC Interpreter 3.0 for Macintosh
  • Microsoft BASIC Compiler 6.0b
  • Microsoft QuickBasic Compiler for Macintosh 1.0
  • Microsoft BASIC Professional Development System 7.0
  • Microsoft BASIC Professional Development System 7.1
  • Microsoft BASIC Interpreter 7.0



This article was previously published under Q28249

SUMMARY

From the built-in BASIC functions LOG, COS, SIN, TAN, SGN, EXP, and SQR, you can derive the other transcendental functions as shown below.

This information is also included with the Help file provided with the Standard and Professional Editions of Microsoft Visual Basic for MS-DOS, version 1.0.

MORE INFORMATION

The following trigonometric and mathematical functions that are not intrinsic to Microsoft Visual Basic for MS-DOS can be calculated as shown. In these formulas, X is an angle measured in radians and Y is a unitless number:

Function                  BASIC Equivalent
--------                  ----------------

Secant                    SEC(X) = 1/COS(X)
Cosecant                  CSC(X) = 1/SIN(X)
Cotangent                 COT(X) = 1/TAN(X)
Inverse Sine              ARCSIN(Y) = ATN(Y/SQR(1-Y*Y))
Inverse Cosine            ARCCOS(Y) = -ATN(Y/SQR(1-Y*Y)) + Pi/2
Inverse Secant            ARCSEC(Y) = ATN(Y/SQR(1-Y*Y)) + (SGN(Y)-1)
                                      * Pi/2
Inverse Cosecant          ARCCSC(Y) = ATN(1/SQR(1-Y*Y)) + (SGN(Y)-1)
                                      * Pi/2
Inverse Cotangent         ARCCOT(Y) = -ATN(Y) + Pi/2
Hyperbolic Sine           SINH(Y) = (EXP(Y) - EXP(-Y))/2
Hyperbolic Cosine         COSH(Y) = (EXP(Y) + EXP(-Y))/2
Hyperbolic Tangent        TANH(Y) = (EXP(Y) - EXP(-Y))/(EXP(Y)
                                    + EXP(-Y))
Hyperbolic Secant         SECH(Y) = 2/(EXP(Y) + EXP(-Y))
Hyperbolic Cosecant       CSCH(Y) = 2/(EXP(Y) - EXP(-Y))
Hyperbolic Cotangent      COTH(Y) = EXP(-Y)/(EXP(Y) - EXP(-Y)) * 2 + 1
Inverse Hyperbolic Sine   ARCSINH(Y) = LOG(Y + SQR(Y*Y+1))
Inverse Hyperbolic Cos    ARCCOSH(Y) = LOG(Y + SQR(Y*Y-1))
Inverse Hyperbolic Tan    ARCCTANH(Y) = LOG((1 + Y)/(1 - Y)) / 2
Inverse Hyperbolic CSC    ARCCSCH(Y) = LOG((SGN(Y)*SQR(Y*Y+1)+1)/Y)
Inverse Hyperbolic Sec    ARCSECH(Y) = LOG((SQR(1-Y*Y)+1) / Y)
Inverse Hyperbolic Cot    ARCCOTH(Y) = LOG((Y+1)/(Y-1)) / 2
                

The general formulas listed above may be used in Microsoft Visual Basic for MS-DOS or any other language. Note that the constant Pi has the following approximate value:

   Pi# = 3.14159265359
   Pi# = 4.0# * ATN(1.0#)
                

To convert degrees to radians, multiply the degrees by pi/180.


Additional query words: VBmsdos QuickBas BasicCom MQuickB

Keywords: KB28249