home *** CD-ROM | disk | FTP | other *** search
/ ProfitPress Mega CDROM2 …eeware (MSDOS)(1992)(Eng) / ProfitPress-MegaCDROM2.B6I / PROG / BASIC / REALFUN.ZIP / MANUAL.TXT < prev    next >
Encoding:
Text File  |  1991-06-01  |  10.3 KB  |  236 lines

  1.  
  2.  
  3.          RealFun:  Real & Complex Math Libraries for QuickBASIC
  4.  
  5.          MANUAL.TXT
  6.  
  7.  
  8.  
  9.            RealFun & CompFun:  Mathematics Libraries for QuickBASIC
  10.  
  11.                        Copyright 1991, L. Kerry Mitchell
  12.  
  13.  
  14.  
  15.  
  16.  
  17.          Contents: I.   Introduction
  18.  
  19.                    II.  RealFun Libraries
  20.  
  21.                    III. CompFun Libraries
  22.  
  23.                    IV.  Support Policy
  24.  
  25.                    V.   General Comments
  26.  
  27.                    VI.  Revision History
  28.  
  29.  
  30.  
  31.  
  32.  
  33.          I.   Introduction
  34.  
  35.  
  36.  
  37.          One of the nice things about BASIC is that it's an easy
  38.  
  39.          language to learn and use, especially in the QuickBASIC
  40.  
  41.          environment.  However, this ease of use comes at the expense
  42.  
  43.          of programming power.  As it is packaged, QuickBASIC just
  44.  
  45.          doesn't have the same number-crunching capability as
  46.  
  47.          FORTRAN, for example.  In much of my personal programming, I
  48.  
  49.          wanted to use functions, like hyperbolic trigonometric
  50.  
  51.          functions, that were available in FORTRAN.  The essential
  52.  
  53.          pieces were there (arithmetic operators and the EXP
  54.  
  55.          function), but not in the forms I wanted.  So I set out to
  56.  
  57.          create a set of libraries that would contain all the
  58.  
  59.          functions I'd ever want to use, and then some.
  60.  
  61.  
  62.  
  63.          Along the way, I realized that some of the intrinsic
  64.  
  65.          functions in QuickBASIC don't quite function the way I'd
  66.  
  67.          like.  For example, the modulo function (MOD) only returns
  68.  
  69.          integers, which is not helpful if you're trying to find 1000
  70.  
  71.          mod 3.14159.  The arctangent function (ATN) only takes one
  72.  
  73.          argument, so you can't tell what quadrant your angle is in. 
  74.  
  75.          Specifically, if the sides of your angle are x and y, with x
  76.  
  77.          = -1 and y = -1, ATN(y/x) will give you the same result as
  78.  
  79.          it would if x and y were both 1.  And of course, QuickBASIC
  80.  
  81.          does not handle complex numbers (as such).
  82.  
  83.  
  84.  
  85.          This package is a compilation of my efforts to make
  86.  
  87.          QuickBASIC more powerful and more productive.  I hope you
  88.  
  89.          find it useful.
  90.  
  91.  
  92.  
  93.  
  94.  
  95.          II.  RealFun Libraries
  96.  
  97.  
  98.  
  99.          The RealFun library is actually two libraries, a Quick
  100.  
  101.          library (REALFUN.QLB) that is used during your interactive
  102.  
  103.  
  104.          programming session, and a stand-alone library (REALFUN.LIB)
  105.  
  106.          that is used to create stand-alone programs.  To use them,
  107.  
  108.          initiate QuickBASIC with the "/l" option:
  109.  
  110.  
  111.  
  112.               C> qb/l realfun
  113.  
  114.  
  115.  
  116.          This assumes that you keep RealFun in the same directory as
  117.  
  118.          your QuickBASIC executable files.  For additional
  119.  
  120.          information on loading libraries, see your QuickBASIC
  121.  
  122.          manuals.
  123.  
  124.  
  125.  
  126.          Once you've gotten the library loaded, you need to tell your
  127.  
  128.          program about it.  For each function that you use, you need
  129.  
  130.          a declaration statement at the beginning of your code.  For
  131.  
  132.          example, to use the sind (sine of an angle in degrees)
  133.  
  134.          function, you would need a
  135.  
  136.  
  137.  
  138.               DECLARE FUNCTION sind (x)
  139.  
  140.  
  141.  
  142.          at the beginning of your program.  Then, if you wanted to
  143.  
  144.          find the sine of 35 degrees somewhere later, call the sind
  145.  
  146.          function just as you would the intrinsic SIN function:
  147.  
  148.  
  149.  
  150.               .
  151.  
  152.               .
  153.  
  154.               .
  155.  
  156.               s35 = sind(35)
  157.  
  158.               .
  159.  
  160.               .
  161.  
  162.               .
  163.  
  164.  
  165.  
  166.          All the other functions are similarly available for your
  167.  
  168.          use.
  169.  
  170.  
  171.  
  172.          RealFun is composed of 38 functions.  A full list of them by
  173.  
  174.          general topic area (sine, hyperbolic tangent, modulo, etc.)
  175.  
  176.          can be found in the file REALTOP.TXT.  An alphabetic listing
  177.  
  178.          by function name (sind, tanh, dmod, etc.) can be found in
  179.  
  180.          the file REALLIST.TXT.  That's all there is to it!
  181.  
  182.  
  183.  
  184.  
  185.  
  186.          III. CompFun Libraries
  187.  
  188.  
  189.  
  190.          The CompFun libraries are also two libraries, a Quick
  191.  
  192.          library (COMPFUN.QLB) that is used during your interactive
  193.  
  194.          programming session, and a stand-alone library (COMPFUN.LIB)
  195.  
  196.          that is used to create stand-alone programs.  To use them,
  197.  
  198.          initiate QuickBASIC with the "/l" option:
  199.  
  200.  
  201.  
  202.               C> qb/l compfun
  203.  
  204.  
  205.  
  206.  
  207.          just like intializing the RealFun libraries.
  208.  
  209.  
  210.  
  211.          The CompFun library is a superset of the functions included
  212.  
  213.          in RealFun, and is composed of FUNCTIONS and SUBprograms. 
  214.  
  215.          To use the FUNCTIONs, you need to let your program know
  216.  
  217.          about them, with the appropriate declaration(s).  For
  218.  
  219.          example, to use the amax and amin functions (maximum and
  220.  
  221.          minimum of 2 items in a list), you would need
  222.  
  223.  
  224.  
  225.               DECLARE FUNCTION amax (x, y)
  226.  
  227.               DECLARE FUNCTION amin (x, y)
  228.  
  229.  
  230.  
  231.          at the beginning of your program.
  232.  
  233.  
  234.  
  235.          The strength of CompFun lies in its ability to manipulate
  236.  
  237.          complex numbers via their real and imaginary parts.  (In
  238.  
  239.          brief, complex numbers have 2 parts, that are known as the
  240.  
  241.          "real" and "imaginary" parts.  QuickBASIC can only handle
  242.  
  243.          "real" numbers, that is, numbers with 1 part.  See
  244.  
  245.          REGISTER.TXT for information regarding a tutorial on complex
  246.  
  247.          numbers and using them with the CompFun library.)  Since
  248.  
  249.          FUNCTIONs only return 1 number, the complex routines are
  250.  
  251.          executed using SUBprograms, which support parameter lists. 
  252.  
  253.          Each SUBprogram you want to use requires its own declaration
  254.  
  255.          statement.  For example, to convert the real and imaginary
  256.  
  257.          parts of a complex number to its magnitude and phase, use
  258.  
  259.  
  260.  
  261.               DECLARE SUB cpolar (x, y, r, t)
  262.  
  263.  
  264.  
  265.          at the beginning of your program, and
  266.  
  267.  
  268.  
  269.               CALL cpolar (a, b, mag, phase)
  270.  
  271.  
  272.  
  273.          in the body of your code.  Of course, you don't have to use
  274.  
  275.          these same variables names, as long as they are of the
  276.  
  277.          proper type.  In this example, the inputs are a (the real
  278.  
  279.          part of the complex number) and b (the imaginary part).  The
  280.  
  281.          outputs are mag (the magnitude) and phase (the phase, in
  282.  
  283.          radians).  The file COMPTOP.TXT lists all the FUNCTIONs and
  284.  
  285.          SUBprograms in CompFun, arranged by topic.  Also listed are
  286.  
  287.          the input and output types (single- or double-precision,
  288.  
  289.          integer or long), and the number of arguments.  An
  290.  
  291.          alphabetic listing of all the routines can be found in
  292.  
  293.          COMPLIST.TXT.
  294.  
  295.  
  296.  
  297.          A bit of warning about dealing with complex numbers:  Any
  298.  
  299.          function involving the trigonometric functions (sin, cos,
  300.  
  301.          tan, sinh, cosh, tanh) or the exponentials (exp, log), the
  302.  
  303.          so-called "transcendental" functions, will be multi-valued. 
  304.  
  305.  
  306.          That is to say, there is an infinity of numbers that give
  307.  
  308.          the same answer.  This is not really a problem, but
  309.  
  310.          something of which you need to be aware.  For example, if
  311.  
  312.          you computed the cosine and arccosine of (-1, -3):
  313.  
  314.  
  315.  
  316.               DECLARE SUB ccos(a, b, c, d)
  317.  
  318.               DECLARE SUB cacos(a, b, c, d)
  319.  
  320.               CALL ccos(-1, -3, u, v)
  321.  
  322.               CALL cacos(u, v, x, y)
  323.  
  324.               PRINT x, y
  325.  
  326.  
  327.  
  328.          you'd find that x = 1 and y = 3, rather than -1 and -3.  So
  329.  
  330.          computing the inverse of a function does not necessarily get
  331.  
  332.          you right back where you started.
  333.  
  334.  
  335.  
  336.  
  337.  
  338.          IV.  General Comments
  339.  
  340.  
  341.  
  342.          The limits of these libraries are the same as the limits of
  343.  
  344.          QuickBASIC, as far as precision, overflow, underflow, etc.
  345.  
  346.  
  347.  
  348.          It is assumed that the user has some idea of what he/she is
  349.  
  350.          doing, or doesn't mind crashing his/her program often.  That
  351.  
  352.          is to say that there is no error-checking in the routines. 
  353.  
  354.          If you try to compute cdacos(145%), your program will
  355.  
  356.          probably die.  I decided that QuickBASIC's error-checking
  357.  
  358.          facilities were good enough to keep your machine from
  359.  
  360.          hanging up, and that checking for the more common errors
  361.  
  362.          would amount to excessive overhead and adversely affect the
  363.  
  364.          routines' performance.
  365.  
  366.  
  367.  
  368.          Some of the calculations, especially the inverse
  369.  
  370.          trigonometric functions, are a bit involved.  A lot of
  371.  
  372.          effort has gone into optimizing the algorithms, but it can
  373.  
  374.          still take a long time to do a massive calculation (like a
  375.  
  376.          640 x 480, several thousand iteration fractal).  There's not
  377.  
  378.          much that can be done about that; it's the nature of the
  379.  
  380.          system.
  381.  
  382.  
  383.  
  384.  
  385.  
  386.          V.   Support Policy
  387.  
  388.  
  389.  
  390.          It is expected that the user of this package will have at
  391.  
  392.          least a passing familiarity with QuickBASIC and the
  393.  
  394.          mathematics used in the libraries.  For a tutorial on
  395.  
  396.          complex numbers and usage of the libraries, please see
  397.  
  398.          REGISTER.TXT and order the enhanced package.
  399.  
  400.  
  401.  
  402.          These libraries have been tested thoroughly, but on only one
  403.  
  404.          installation.  The modules are believed to be fully
  405.  
  406.  
  407.          compatible with MS-DOS 3.3 and QuickBASIC 4.5. 
  408.  
  409.          Compatibility with earlier versions is an open question,
  410.  
  411.          although no "tricks" or dirty programming have been used, so
  412.  
  413.          it should be safe.  To report bugs and problems, please send
  414.  
  415.          a short note to me at the address below.
  416.  
  417.  
  418.  
  419.          Support in working with the package can be obtained in two
  420.  
  421.          ways.  For 90 days after registration, you are entitled to a
  422.  
  423.          total of 1 hour telephone support, free of charge (except
  424.  
  425.          normal long-distance charges).  Support by mail (postal or
  426.  
  427.          electronic) is available free of charge for 180 days after
  428.  
  429.          registration.  To obtain help or report a bug, write or
  430.  
  431.          call:
  432.  
  433.  
  434.  
  435.               Kerry Mitchell
  436.  
  437.               Creative Imagery
  438.  
  439.               1454 Todds Lane #A-25
  440.  
  441.               Hampton, VA 23666
  442.  
  443.               804-827-7034
  444.  
  445.               CompuServe:  [70152,1444]
  446.  
  447.               Internet:  70152.1444@compuserve.com
  448.  
  449.               Delphi:  lkmitch
  450.  
  451.  
  452.  
  453.  
  454.  
  455.          VI.  Revision History
  456.  
  457.  
  458.  
  459.          This is officially version 1.0 of the RealFun package.  A
  460.  
  461.          preliminary version was released in 1990, primarily as an
  462.  
  463.          exercise for myself.
  464.  
  465.