home *** CD-ROM | disk | FTP | other *** search
/ World of Ham Radio 1997 / WOHR97_AmSoft_(1997-02-01).iso / formulas / math / amsoft.iii next >
Text File  |  1997-02-01  |  23KB  |  603 lines

  1.  
  2.                      SCIENTIFIC EQUATION SOLVER
  3.                      ==========================
  4.  
  5.  
  6. Scientific Equation Solver (SCIEQS) acts as a sophisticated scientific
  7. calculator.  It can perform double precision floating point arithmetic
  8. using an assignment statement syntax similar to BASIC or FORTRAN.
  9. Variables may be assigned values in one statement and then used on the
  10. right-hand side of another statement.
  11.  
  12. Almost every built-in function found on scientific calculators has
  13. been included: trigonometric, hyperbolic, exponential, logarithmic,
  14. factorial, and square/cube root functions.  Even advanced functions
  15. such as erf(x) and gamma(x) have been included.  You can also define
  16. your own functions with any number of arguments.
  17.  
  18. There is also an equation solver built into the program.  This feature
  19. allows the program to solve for any variable in a given equation.
  20. Suppose you needed to solve for the variable 'x', where
  21.  
  22.       (3 * x) + exp(x+1) = 99 .
  23.  
  24. By entering the command
  25.  
  26.       !solve  x, [0,100] : (3 * x) + exp(x+1) = 99 ,
  27.  
  28. the solution 3.483559695247 comes up on your screen in seconds.
  29.  
  30. SCIEQS also supports numerical integration (also known as quadrature).
  31. This feature allows the program to approximate the values of definite
  32. integrals.  Suppose you needed to evaluate the following integral:
  33.  
  34.            2
  35.           ⌠
  36.           │  (x^2 * sqrt(x^3 + 1))  dx .
  37.           ⌡
  38.            0
  39.  
  40. By entering the command
  41.  
  42.       !quad  x, [0,2] : x^2 * sqrt(x^3 + 1) ,
  43.  
  44. the value 5.7777777777778 comes up on your screen in seconds.
  45.  
  46.  
  47.  
  48.                         HOW TO START SCIEQS
  49.                         ===================
  50.  
  51. To begin SCIEQS, type the following command at the MS-DOS command
  52. prompt:
  53.            SCIEQS
  54.  
  55. The program reads its input from the standard input and writes its
  56. output to the standard output so you may use the data redirection
  57. symbols >, >>, <, and | from the MS-DOS command line.  For example,
  58. the following command reads commands from file POLY.EQS and writes the
  59. results to file RESULTS.TXT:
  60.  
  61.            SCIEQS  <POLY.EQS  >RESULTS.TXT
  62.  
  63.  
  64.  
  65.                         EXPRESSIONS IN SCIEQS
  66.                         =====================
  67.  
  68. SCIEQS is an expression oriented language.  Expressions typed by the
  69. user are interpreted, evaluated, and displayed immediately by SCIEQS.
  70. Most commands are of the form
  71.  
  72.            variable = expression
  73.  
  74. or simply
  75.  
  76.            expression
  77.  
  78. The first form is the assignment statement.  It assigns the expression
  79. on the right side of the equals sign to the variable named on the left
  80. side and also displays the value of the expression.  The second form
  81. simply evaluates the expression and displays its value.
  82.  
  83. Examples:   2+3      area = pi()*R^2       b = c*d
  84.             x^2      sqrt(2)               (2+3)!
  85.  
  86. Expressions are composed of numbers, variables, function references,
  87. and arithmetic operators.  Following are the rules for forming
  88. expressions.
  89.  
  90. Numbers follow a conventional decimal notation, with optional decimal
  91. point.  A power-of-ten scale factor can be included as a suffix.  This
  92. is similar to the number notations used in the computer languages
  93. BASIC and FORTRAN.  The range of numbers is approximately 1E-308 to
  94. 1E+308 with approximately 15 significant digits.
  95.  
  96. Examples:    1.2       +.8         -788       1E6
  97.              4.        1256        -7.3E-5
  98.  
  99. Variable names and function names must start with a letter and may be
  100. followed by any number of letters, digits, and underscores.  However,
  101. only the first 31 characters of the name are remembered.  SCIEQS is
  102. not case-sensitive so it treats upper and lower case letters as the
  103. same character.  The variable names "Answer" and "answer" refer to the
  104. same variable.
  105.  
  106. Examples:   SUM       x       days_in_month       xYzzY
  107.  
  108. An arithmetic expression can be any expression preceded by unary + or
  109. -, two expressions linked by a binary operator (+ - * / % ^), or any
  110. expression followed by unary !.
  111.  
  112. Arithmetic operators are (from high to low precedence):
  113.  
  114.                 Factorial                     !
  115.                 Unary plus and minus          +  -
  116.                 Exponentiation                ^
  117.                 Mult, Div, and Modulus        *  /  %
  118.                 Addition and Subtraction      +  -
  119.  
  120. Examples:   x+3    -t^2    tan(x)/y    6!    4^2^3 (evaluates to 65536)
  121.  
  122. Operations at the same precedence level are performed from left to
  123. right except for series of exponentiations, which are performed from
  124. right to left.  The factorial operator appears on the right of the
  125. expression on which it operates.  The order of operations may be
  126. controlled by enclosing expressions in parentheses.
  127.  
  128. There are two main categories of functions in SCIEQS: built-in and
  129. user-defined functions.  Built-in functions are automatically provided
  130. every time you run SCIEQS.  User-defined functions are defined by you
  131. to handle your specific problem.  To invoke a function, refer to the
  132. function in an expression.
  133.  
  134. Example:    a = tan(x)/d
  135.  
  136. Following is a list of the built-in functions.
  137.  
  138. Mathematical Constants
  139.  
  140. PI() = 3.141592653589793    ratio of circumference to diameter
  141. E()  = 2.718281828459045    base of natural logarithms
  142.  
  143.  
  144. Trigonometric and Inverse Trigonometric Functions in Radians
  145.  
  146. SIN(x)           Sine of x
  147. COS(x)           Cosine of x
  148. TAN(x)           Tangent of x
  149. ASIN(x)          Arc sine of x
  150. ACOS(x)          Arc cosine of x
  151. ATAN(x)          2-quadrant arc tangent of x
  152. ATAN2(y,x)       4-quadrant arc tangent of y/x
  153. ANGL(x,y)        Angle to point (x,y)
  154. HYPOT(x,y)       Hypotenuse of right triangle
  155.  
  156.  
  157. Trigonometric and Inverse Trigonometric Functions in Degrees
  158.  
  159. SIND(x)          Sine of x
  160. COSD(x)          Cosine of x
  161. TAND(x)          Tangent of x
  162. ASIND(x)         Arc sine of x
  163. ACOSD(x)         Arc cosine of x
  164. ATAND(x)         2-quadrant arc tangent of x
  165. ATAN2D(y,x)      4-quadrant arc tangent of y/x
  166. ANGLD(x,y)       Angle to point (x,y)
  167.  
  168.  
  169. Hyperbolic and Inverse Hyperbolic Functions
  170.  
  171. SINH(x)       Hyperbolic sine of x
  172. COSH(x)       Hyperbolic cosine of x
  173. TANH(x)       Hyperbolic tangent of x
  174. ASINH(x)      Hyperbolic arc sine of x
  175. ACOSH(x)      Hyperbolic arc cosine of x
  176. ATANH(x)      Hyperbolic arc tangent of x
  177.  
  178.  
  179. Exponential and Logarithmic Functions
  180.  
  181. EXP(x)     Number e, 2.718281828459045, raised to the xth power
  182. LN(x)      Natural (base e) logarithm of x
  183. LOG(x)     Common (base 10) logarithm of x
  184. LOG2(x)    Base 2 logarithm of x
  185.  
  186.  
  187. Other Mathematical Functions
  188.  
  189. ABS(x)      Absolute value of x
  190. SQRT(x)     Positive square root of x
  191. CBRT(x)     Cube root of x
  192. ERF(x)      Error function associated with normal distribution curve
  193. ERFC(x)     Complementary error function,  1 - erf(x)
  194. GAMMA(x)    Gamma function, x-1 factorial for integer x>0
  195. RTOD(x)     Convert x in radians to degrees
  196. DTOR(x)     Convert x in degrees to radians
  197. PERM(n,r)   Permutations of n items taken r at a time
  198. COMB(n,r)   Combinations of n items taken r at a time
  199. SGN(x)      Sign (-1, +1 or 0) of x
  200. INT(x)      Integer part of x
  201. ROUND(x)    Nearest integer to x
  202. CEIL(x)     Smallest integer >= x
  203. FLOOR(x)    Largest integer <= x
  204. STEP(x,y)   Returns  1 if x >= y,  0 if x < y
  205.  
  206.  
  207.  
  208.            ASSIGNMENT STATEMENTS AND USER-DEFINED FUNCTIONS
  209.            ================================================
  210.  
  211. The assignment statement is used to define variables and user-defined
  212. functions.  They have the following formats:
  213.  
  214.       variable  =  expression
  215.  
  216.       function(arguments)  =  expression
  217.  
  218. Once the assignment has been done, the variable or function is
  219. associated with the given expression.  For a user-defined function,
  220. the right-side expression should use the arguments listed in the
  221. function's argument list.  If a variable or function is used in an
  222. expression before it is defined in an assignment statement, an error
  223. message will be displayed.
  224.  
  225. Examples:
  226.            a = 2
  227.            b = sqrt(a)
  228.            area_circle(radius) = pi() * radius ^ 2
  229.            c = area_circle(a)
  230.  
  231. Assignment in SCIEQS assigns the expression, not the value of the
  232. expression.  What this means is the value of variables can change if
  233. the variables they depend on change.  For example, after the four
  234. assignments in the above example have been done, the values of the
  235. variables are:
  236.  
  237.           A = 2
  238.           B = 1.4142135623731
  239.           C = 12.566370614359
  240.  
  241. But suppose we change the value of variable A by assigning it the
  242. value 3.  Now the values of variables B and C change automatically
  243. because they were defined in terms of variable A.
  244.  
  245.           A = 3
  246.           B = 1.7320508075689
  247.           C = 28.274333882308
  248.  
  249. This feature is important when you want to play "What happens if..."
  250. games.  You can build a mathematical model using different formulas
  251. and see what happens when you start changing the values of some of the
  252. variables.
  253.  
  254.  
  255.                           COMMANDS IN SCIEQS
  256.                           ==================
  257.  
  258. Commands in SCIEQS begin with the character "!".  Following is a list
  259. of available commands and what they do.
  260.  
  261.  
  262. SOLVE COMMAND
  263. -------------
  264.  
  265. The solve command uses a numerical approximation method to solve
  266. equations.  It has the form
  267.  
  268.    !solve  variable ,  [ low, high ]  :  equation
  269.  
  270. Example: Solve for x where  x^3 - 11*x^2 + 39*x = 27.
  271.  
  272.    > !solve x, [-100,100]: x^3 - 11*x^2 + 39*x = 27
  273.                    = 0.90375019315913
  274.  
  275. The variable x now has the value 0.90375019315913 for use in later
  276. calculations.
  277.  
  278. The values in brackets [ ] represent the low and high bounds of an
  279. interval in which to look for a solution.  The approximation method
  280. first takes a trial value at the midpoint of the specified interval
  281. and iterates until the trial values converge on a solution.  If the
  282. equation to be solved has singularity points, choose the intervals to
  283. avoid the singularities.  SCIEQS may not be able to find a solution if
  284. you include singularity points within the intervals.
  285.  
  286. If the equation has multiple solutions within the given interval,
  287. SCIEQS will usually find one of them.  To find multiple solutions, you
  288. must narrow the search interval to include only one solution at a
  289. time.  You can narrow down the search intervals by plotting the
  290. equations to find the vicinity of the solutions.
  291.  
  292.  
  293. QUAD COMMAND
  294. ------------
  295.  
  296. The quadrature command uses a numerical approximation method to
  297. evaluate definite integrals.  It has the form
  298.  
  299.    !quad  variable ,  [ low, high ]  :  integrand
  300.  
  301. The variable indicates the "variable of integration."  The values in
  302. brackets [ ] represent the low and high limits of integration.  The
  303. integrand is the expression to be integrated.  SCIEQS will integrate
  304. the integrand from low to high limits with respect to the specified
  305. variable of integration.
  306.                                            π
  307.                                           ⌠
  308. Example: Evaluate the definite integral   │ sin(x)  dx .
  309.                                           ⌡
  310.                                            0
  311.    > !quad x, [0,pi()] : sin(x)
  312.    estimated error = 4.206476E-016
  313.                    = 2
  314.  
  315. An estimate of the size of the actual error in the result is first
  316. listed.  If the approximation method encounters problems during the
  317. integration, it may execute much longer than usual in an attempt to
  318. achieve enough accuracy in the result.  If the accuracy can not be
  319. achieved, a warning message will be shown indicating the result may be
  320. unreliable.  The result of the integration is then listed below the
  321. estimated error.  The variable of integration will now have the result
  322. of the integration for use in later calculations.  In the above
  323. example, the variable x will now contain the result.
  324.  
  325. SCIEQS may not be able to evaluate the integral if there are
  326. singularity points within the limits of integration which cause
  327. floating point overflows.  If a floating point overflow occurs, the
  328. program may terminate unexpectedly.
  329.  
  330.  
  331. DERIV COMMAND
  332. -------------
  333.  
  334. The derivative command uses a numerical approximation method to
  335. evaluate the derivative of a function at a specified point.  It has
  336. the form
  337.  
  338.    !deriv  variable , point  :  function
  339.  
  340. The variable indicates the "variable of differentiation."  The
  341. derivative is taken with respect to the variable of differentiation.
  342. Point indicates the value of the variable of differentiation where the
  343. derivative will be evaluated.  It must be a value where the function
  344. is defined.  Function indicates the function to be differentiated.
  345.  
  346. Example: Evaluate the derivative of f(x) = 3 * x^4  at  x = 7.
  347.  
  348.    > !deriv x, 7  :  3 * x^4
  349.    estimated error = 0
  350.                    = 4116
  351.  
  352. An estimate of the size of the actual error in the result is first
  353. listed.  The result of the differentiation is then listed below the
  354. estimated error.  The variable of differentiation will now have the
  355. result of the differentiation for use in later calculations.  In the
  356. above example, the variable x will now contain the result.
  357.  
  358. SCIEQS may not be able to evaluate the derivative if the function is
  359. undefined near the point of evaluation.  You may restrain the
  360. numerical approximation method by using the following form of the
  361. command.
  362.  
  363.    !deriv  variable , point , range  :  function
  364.  
  365. Range specifies the range (point - range) to (point + range).  SCIEQS
  366. will not try to evaluate the function outside of this range.  The
  367. default value of range is ABS(point / 16).  If there are singularity
  368. points within the range (even the default range), the derivative
  369. command will probably fail to evaluate the derivative.  Specifying a
  370. very small value for range may increase the error in the
  371. approximation.
  372.  
  373.  
  374. LIST COMMAND
  375. ------------
  376.  
  377. The list command is used to display the values of all the variables
  378. used.  The command has the following forms:
  379.  
  380.    !list
  381.  
  382.    !list  filename
  383.  
  384. The first form displays the variables on the standard output.  The
  385. second form stores the output in the named file.
  386.  
  387.  
  388. DEL COMMAND
  389. -----------
  390.  
  391. The del command is used to delete variables no longer needed.  The
  392. command has the form:
  393.  
  394.    !del  variable
  395.  
  396. When the del command is executed, all occurrences of the variable in
  397. formulas and function definitions are replaced by the variable's
  398. current numerical value.  Here is an example:
  399.  
  400.    a = 2
  401.    b = 5 * a
  402.    !del a
  403.    !list
  404.  
  405. The list command will not show variable 'a'.  Variable 'b' will have a
  406. value of 10 since the del command replaced the "5 * a" with "5 * 2".
  407.  
  408.  
  409. ECHO/NOECHO COMMANDS
  410. --------------------
  411.  
  412. The echo and noecho commands control the echoing of the input commands
  413. to the output destination.  They have the following forms:
  414.  
  415.    !echo
  416.  
  417.    !noecho
  418.  
  419. The echo command turns on input command echoing while the noecho
  420. command turns it off.  SCIEQS starts out with echoing turned off.  You
  421. may wish to turn on echoing when sending output to a file so the
  422. output file will contain a record of the input as well as the results.
  423.  
  424.  
  425. SYS COMMAND
  426. -----------
  427.  
  428. The sys command allows you to execute MS-DOS commands from within
  429. SCIEQS.  It has the following forms:
  430.  
  431.    !sys
  432.  
  433.    !sys  MS-DOS_command
  434.  
  435. The first form starts the MS-DOS command shell underneath SCIEQS.  You
  436. must type "EXIT" at the MS-DOS command prompt to return to SCIEQS.
  437. The second form executes the given MS-DOS command and automatically
  438. returns to SCIEQS after the command finishes.
  439.  
  440.  
  441. EXIT/QUIT COMMANDS
  442. ------------------
  443.  
  444. Both commands terminate SCIEQS execution.  They have the forms
  445.  
  446.    !exit
  447.  
  448.    !quit
  449.  
  450.  
  451.                       COMMAND FILES IN SCIEQS
  452.                       =======================
  453.  
  454. SCIEQS supports the inclusion of input from command files.  These
  455. command files are ASCII text files which contain data, numerical
  456. operations, and commands for SCIEQS to interpret.  You may think of
  457. them as "include" files.  To include a file, give the following
  458. command:
  459.  
  460.    @filename
  461.  
  462. SCIEQS will open the file named after the "@" character and start
  463. getting its input from that file.  When the end of file is reached,
  464. SCIEQS will resume getting its input from the original source.  You
  465. may specify a directory pathname if the file is not in the current
  466. directory.  You may nest command files within other command files, but
  467. MS-DOS may limit you in the number of files you may open at any one
  468. time.
  469.  
  470.  
  471.                         COMMENTS IN SCIEQS
  472.                         ==================
  473.  
  474. Comments can be included in the input to help document your work.  A
  475. comment begins with a semicolon and continues to end of the line.  You
  476. can put a comment after an expression to explain the operation on that
  477. line.  You can also start a line with a comment in which case the
  478. entire line is a comment.
  479.  
  480. Examples:   cbrt(x)   ;taking the cube root of variable x
  481.             ; This entire line is a comment.
  482.  
  483.  
  484.                        MATH COPROCESSOR USAGE
  485.                        ======================
  486.  
  487. The SCIEQS program will automatically detect the presence of an 8087,
  488. 80287, or 80387 math coprocessor in your computer and use it for
  489. calculations if available.  If a math coprocessor is not available,
  490. the program will still work, but at a slower execution speed.
  491.  
  492.  
  493.                       EDITING PREVIOUS COMMANDS
  494.                       =========================
  495.  
  496. The MS-DOS operating system provides a facility to edit the previous
  497. command given to SCIEQS so that it may be reexecuted.  This is useful
  498. if you had mistyped the last command or if you want to execute several
  499. similar commands in succession.  The following editing keys may be
  500. used to edit the previous command:
  501.  
  502.    F1   Copies the next character from previous command.
  503.    F2   Copies all characters from previous command up to a specified
  504.           character.  Type specified character after F2 key.
  505.    F3   Copies all remaining characters from previous command.
  506.    F4   Skips over all characters in previous command up to a
  507.           specified character.  Type specified character after F4 key.
  508.    INS  Allows insertion of characters into the command.
  509.    DEL  Skips over one character from previous command.
  510.    <--  Deletes character to left of the cursor on current command.
  511.    ESC  Cancels the current command.
  512.  
  513. Please refer to your MS-DOS reference manual for more information on
  514. the above editing keys.
  515.  
  516. Starting with SCIEQS 1.4, you may also recall and edit more than just
  517. the last command by using the program CED.  CED is a command editor
  518. which allows you to use the cursor arrow keys to recall, edit, and
  519. reissue previous commands.  It also works at the MS-DOS command prompt.
  520. CED is available without registration fees on most electronic bulletin
  521. board systems and from user group libraries.  If you can't find it
  522. elsewhere, I'll provide a copy of it when you register SCIEQS.
  523.  
  524. If you use CED, I suggest you change the default chain character of
  525. caret (^) to control-backslash.  This chain character allows you to
  526. issue more than one command on the same input line.  However, the
  527. CED default value of caret (^) conflicts with the exponentiation
  528. operator used in SCIEQS.  Issue this command at the MS-DOS command
  529. prompt to change the CED chain character:
  530.  
  531.          CED CHAINCH ^\
  532.  
  533. The "^\" in the above command is typed by holding down the CTRL key
  534. while pressing the backslash key (\).  You can also type the caret (^)
  535. character followed by the backslash key.  Please refer to the CED
  536. documentation to learn how to have this command issued automatically
  537. when you start your computer.  When you wish to issue more than one
  538. command on the same input line, enter the control-backslash character
  539. between the commands by holding down the CTRL key while pressing the
  540. backslash key (\).
  541.  
  542.  
  543.                            UPDATE HISTORY
  544.                            ==============
  545.  
  546. Version 1.0: Initial release.
  547.  
  548. Version 1.1: Added feature to evaluate definite integrals.
  549.  
  550. Version 1.2: Added feature to evaluate derivatives.
  551.  
  552. Version 1.3: Added command to delete variables.
  553.              Improved comb() and perm() functions.
  554.              Fixed bug in hypot() function.
  555.  
  556. Version 1.4: Improved error messages with a pointer showing where
  557.                a syntax error occured in the user's input.
  558.              Improved keyboard input so SCIEQS can be used with
  559.                the CED program to recall and edit previous commands.
  560.              Fixed bug where nested evaluations of user-defined
  561.                functions within other user-defined functions did
  562.                not work correctly.
  563.  
  564.  
  565.                             DISCLAIMER
  566.                             ==========
  567.  
  568. The SCIEQS program and associated files are provided "as is" without
  569. any warranty or guarantee, including no warranty of fitness for a
  570. particular purpose.  You assume the entire risk as to the results
  571. generated through your use of this software.
  572.  
  573.  
  574.                             DISTRIBUTION
  575.                             ============
  576.  
  577. The shareware version of SCIEQS is distributed on electronic bulletin
  578. boards and by computer clubs.  You may use the software and make
  579. multiple backup copies.  Versions of SCIEQS designated as "shareware"
  580. may be given to friends and uploaded to electronic bulletin boards
  581. provided no changes have been made to the distribution package.  Do
  582. not distribute copies of the program which do not have the initial
  583. screen explaining the shareware concept.
  584.  
  585. If you find this program useful, please feel free to give consideration
  586. for my time and effort in developing this tool.  Please send $6.00 to
  587. the address below and ask for SCIEQS registration.  The file ORDER.ME
  588. contains a registration form that can be printed on your printer if
  589. you wish.  In return, you will receive a floppy disk with the latest
  590. version of SCIEQS.  The introductory screen along with its keyboard
  591. entry will NOT appear in the copy of the program you will receive upon
  592. registration.  There will be no advertising in your registered copy.
  593.  
  594. Please upload the shareware version of this program onto as many local
  595. bulletin boards as possible.  You will be helping me make this tool
  596. available to many more people giving me incentive to make further
  597. improvements to the program.
  598.  
  599.  
  600. Send contributions to:  George Yee
  601.                         1847 N. Frances Blvd.
  602.                         Tucson, AZ  85712
  603.