home *** CD-ROM | disk | FTP | other *** search
/ Simtel MSDOS - Coast to Coast / simteldosarchivecoasttocoast2.iso / calculat / sm30a.zip / SYMBMATH.DOC < prev    next >
Text File  |  1993-11-15  |  204KB  |  5,471 lines

  1.     SymbMath 3.0: A Symbolic Calculator with Learning
  2.         (Version 3.0)
  3.  
  4.         by Dr. Weiguang HUANG
  5.     Dept. Analytical Chemsitry, University of New South Wales,
  6.     Kensington, Sydney, NSW 2033, Australia
  7.     Phone:  61-2-697-4643,  Fax:    61-2-662-2835
  8.     E-mail: w.huang@unsw.edu.au, s9300078@cumulus.csd.unsw.oz.au
  9.  
  10.         Copyright (C) 1990-1993
  11.         Nov. 12, 1993
  12.     
  13.         You should register with the author if you use SymbMath.
  14.  
  15.  
  16.             Contents
  17.  
  18. PART 1
  19.  
  20. 1.      Introduction
  21. 1.1     What is SymbMath
  22. 1.2     Capabilities
  23. 1.3     Shareware, Student and Advanced Versions
  24. 1.4     A List of Files in SymbMath
  25.  
  26. 2.      SymbMath Environment: Windows and Menus
  27.  
  28. 2.1     File Menu
  29. 2.1.1   Open
  30. 2.1.2   New
  31. 2.1.3   Save Input
  32. 2.1.4   Save Output
  33. 2.1.5   DOS Shell
  34. 2.1.6   Exit
  35.  
  36. 2.2     Input Menu
  37. 2.2.1   Edit Help Menu
  38. 2.2.1.1 Show help file
  39. 2.2.1.2 Cursor movement
  40. 2.2.1.3 Insert & Delete
  41. 2.2.1.4 Block functions
  42. 2.2.1.5 Wordstar-like
  43. 2.2.1.6 Miscellaneous
  44. 2.2.1.7 Global functions
  45.  
  46. 2.3     Run Menu
  47.  
  48. 2.4     Output Menu
  49. 2.4.1   Edit Help Menu
  50.  
  51. 2.5     Color Menu
  52. 2.5.1   Menu line
  53. 2.5.2   Edit window
  54. 2.5.3   Output window
  55. 2.5.4   Status line
  56.  
  57. 2.6     Help Menu
  58. 2.7     Example Menu
  59. 2.8     Keyword Menu
  60.  
  61. 3.      Programming in SymbMath
  62.  
  63. 3.1.    Data Types
  64. 3.1.1   Numbers
  65. 3.1.2   Constants
  66. 3.1.3   Variables
  67. 3.1.4   Patterns
  68.  
  69. 3.1.5   Functions, Procedures and Rules
  70. 3.1.5.1 Standard Mathematical Functions
  71. 3.1.5.2 Calculus Functions 
  72. 3.1.5.3 Test Functions
  73. 3.1.5.4 Miscellaneous Functions
  74. 3.1.5.5 User-defined Functions
  75. 3.1.5.6 Procedures
  76. 3.1.5.7 Rules
  77.  
  78. 3.1.6   Equations
  79. 3.1.7   Inequalities
  80. 3.1.8   Arrays and Array Index
  81. 3.1.9   Lists and List Index
  82. 3.1.10  Strings
  83.  
  84. 3.2.    Expressions
  85. 3.2.1   Operators
  86. 3.2.1.1 Arithmetic Operators
  87. 3.2.1.1 Relational Operators
  88. 3.2.1.2 Logical Operators
  89. 3.2.2   Function Calls
  90.  
  91. 3.3.    Statements
  92. 3.3.1   Comment Statements
  93. 3.3.2   Evaluation Statements
  94. 3.3.3   Assignment Statements
  95. 3.3.4   Conditional 
  96. 3.3.5   Loop 
  97.  
  98. 3.3.6   Switch 
  99. 3.3.6.1 Output Switch
  100. 3.3.6.2 Case Switch
  101. 3.3.6.3 Numeric Switch
  102. 3.3.6.4 Expand Switch
  103. 3.3.6.5 ExpandExp Switch
  104.  
  105. 3.3.7   Read and Write Statements
  106. 3.3.8   DOS Command Statements
  107. 3.3.9   Sequenece Statements
  108.  
  109. 3.4.    Libraries and Packages
  110. 3.4.1   Initial Package
  111. 3.4.2   Chemical Calculation Package
  112.  
  113. 3.5.    Interface with Other Software
  114.  
  115.  
  116. PART 2
  117.  
  118. 4.      Examples
  119.  
  120. 4.1     Calculation
  121. 4.1.1   Discontinuity and one-sided value
  122. 4.1.2   Undefined and indeterminate forms
  123.  
  124. 4.2     Simplification 
  125. 4.2.1   Assuming domain
  126. 4.2.2   Comparising and testing numbers
  127.  
  128. 4.3     Defining Your Own Functions, Procedures and Rules
  129.  
  130. 4.3.1   Defining Your Own Functions
  131. 4.3.1.1 Defining Conditional Functions
  132. 4.3.1.2 Defining Case Functions
  133. 4.3.1.3 Defining Piece-wise Functions
  134. 4.3.1.4 Defining Recursion Functions
  135. 4.3.1.5 Defining Multi-value Functions
  136.  
  137. 4.3.2   Defining Your Own Procedures
  138. 4.3.3   Defining Your Own Rules
  139.  
  140. 4.4     Limits
  141. 4.4.1   One-sided Limits
  142. 4.4.2   Numeric Limits: NLim()
  143.  
  144. 4.5     Differentiation
  145. 4.5.1   One-sided derivatives
  146. 4.5.2   Defining f'(x)
  147.  
  148. 4.6     Integration
  149. 4.6.1   Indefinite Integration
  150. 4.6.2   Definite Integration
  151. 4.6.3   Numeric Integration: NInte()
  152.  
  153. 4.7     Solving Equations
  154. 4.7.1   Solving Algebraic Equations
  155. 4.7.2   Solve()
  156. 4.7.3   Polynomial Solver: PSolve()
  157. 4.7.4   Numeric Solver: NSolve()
  158. 4.7.5   Solving Differential Equations
  159. 4.7.6   Differential Solver: DSolve()
  160.  
  161. 4.8     Sums, Products, Series and Polynomials
  162. 4.8.1   Partial Sum
  163. 4.8.2   Infinite Sum
  164. 4.8.3   Series
  165. 4.8.4   Polynomials
  166.  
  167. 4.9     Arrays, Lists, Vectors and Matrices
  168.  
  169. 4.9.1   Arrays
  170. 4.9.1.1 Entering Arrays
  171. 4.9.1.2 Accessing Arrays
  172. 4.9.1.3 Modifying Arrays
  173. 4.9.1.4 Operating Arrays
  174.  
  175. 4.9.2   Lists
  176. 4.9.2.1 Entering Lists
  177. 4.9.2.2 Accessing Lists
  178. 4.9.2.3 Modifying Lists
  179. 4.9.2.4 Operating Lists
  180.  
  181. 4.9.3   Vectors and Matrices
  182.  
  183. 4.10    Statistics
  184. 4.11    Tables of Function Values
  185.  
  186. 4.12    Conversion 
  187. 4.12.1  Converting to Numbers
  188. 4.12.2  Converting to Lists
  189. 4.12.3  Converting to Strings
  190. 4.12.4  Converting to Table
  191.  
  192. 4.13    Getting parts of expression
  193. 4.13.1  Getting type of data
  194. 4.13.2  Getting operators
  195. 4.13.3  Getting operatands
  196. 4.13.4  Getting coefficients
  197.  
  198. 4.14    Database
  199. 4.14.1  Phone No. Database
  200. 4.14.2  Chemical Reaction Database
  201.  
  202. 4.15    Learning from User
  203. 4.15.1  Learning integrals from derivatives
  204. 4.15.2  Learning complicated integrals from a simple indefinite integral
  205. 4.15.3  Learning definite integral from indefinite integral
  206. 4.15.4  Learning integrals from algebra
  207. 4.15.5  Learning complicated derivatives from a simple derivative
  208. 4.15.6  Learning complicated algebra from simple algebra
  209. 4.15.7  Learning vs. programming
  210.  
  211. 5.      Graphics
  212. 5.1     Drawing lines and arcs
  213. 5.2     Plotting y = f(x)
  214. 5.3     Plotting r = f(t) in polar coordinates
  215.  
  216.  
  217. PART 3
  218.  
  219. 6.      Inside SymbMath
  220. 6.1     Internal Structure
  221. 6.2     Internal Format
  222.  
  223. 7.      System Limits
  224.  
  225. 8.      Keywords
  226. 8.1     Keywords in Functional Order
  227. 8.2     Keywords in Alphabetical Order
  228. 8.3     Glossary
  229.  
  230. 9.      References
  231.  
  232.  
  233.         1.   Introduction
  234.         1.1  What is SymbMath
  235.  
  236.     SymbMath (an abbreviation for Symbolic Mathematics) is a
  237. symbolic calculator that can solve symbolic math problems. 
  238.     SymbMath is a computer algebra system that can perform exact 
  239. numeric, symbolic and graphic computation. It manipulates complicated
  240. formulas and returns answers in terms of symbols, formulas, exact
  241. numbers, table and graph. 
  242.     SymbMath is an expert system that is able to learn from user's 
  243. input. If the user only input one formula without writing any code, it 
  244. will automatically learn many problems related to this formula (e.g. it 
  245. learns the integrals of an unknown function from a derivative of that 
  246. unknown function).
  247.     SymbMath is a programming language in which you can write
  248. programs, functions and procedures.
  249.     SymbMath is a symbolic, numeric and graphics computing
  250. environment where you can set up, run and document your calculation,
  251. and draw your graph.
  252.     SymbMath is database where you can search your database.
  253.     SymbMath is a multi-windowed text editor in which you can edit
  254. many documents in many windows.
  255.     It runs on IBM PCs (8086) with 400 KB free memory under MS-DOS.
  256.     
  257.  
  258.           1.2     Capabilities
  259.     It can provide analytical and numeric answers for:
  260.     o Differentiation: regular or higher order, partial or total,
  261.       mixed and implicit differentiation, one-sided derivatives.
  262.     o Integration: indefinite or definite integration, multiple
  263.       integration, infinity as a bound, parametric or iterated 
  264.       integration, line or surface integrals, discontinuous or 
  265.       implicit integration.
  266.     o Solution of equations: roots of a polynomial, systems of
  267.       algebraic or differential equations.
  268.     o Manipulation of expressions: simplification, factoring or 
  269.       expansion, substitution, evaluation.
  270.     o User-defined functions: conditional, case, piecewise, recursion.
  271.     o Calculation: exact and floating-point numeric computation
  272.       of integer, rational, real and complex numbers in the range 
  273.       from minus to plus infinity, even with different units.
  274.     o Limits: real, complex or one-sided limits, indeterminate forms.
  275.     o Complex: calculation, functions, derivatives, integration.
  276.     o Sum and product: partial, finite or infinite.
  277.     o Others: series, lists, arrays, vectors, matrices, tables, etc.
  278. Also included are:
  279.     o Pull-down and pop-up menus, resizable and colourable windows.
  280.     o Programming in integrated edit-interpret-debug environment.
  281.     o On-line help, and on-line manual.
  282.     o Procedural, conditional, iterational, recursive, functional,
  283.       rule-based, logic, pattern-matching and graphic programming.
  284.     o Autoloaded library in the SymbMath language.
  285.     o Plotting functions and graphing.
  286.     o Searching database.
  287.  
  288.         1.3  Shareware, Student and Advanced Versions
  289.  
  290.         You should register with the author if you use SymbMath.
  291.     Please read the document file SymbMath.DOC and all *.TXT files
  292. before running SymbMath. You should print them out if you need the printed
  293. documents. Please follow examples in the document to practise.
  294.     On the MS-DOS prompt to install it, type
  295. install
  296.     On the MS-DOS prompt to run it, type
  297. SymbMath
  298.  
  299.     SymbMath has three versions: Shareware Version A, Student
  300. Version B and Advanced Version C. The shareware version lacks the 
  301. solve(), trig (except sin(x) and cos(x)), and hyerbolic functions, 
  302. (lack 10% keywords) and the student version lacks the hyerbolic
  303. functions (lack 5% keywords). You cannot input these lack functions
  304. in shareware or student version.
  305.  
  306. ----------------------------------------------------------------------
  307. Version         Class   Lacked Functions                Price
  308.  
  309. Shareware       A       solve(), hyerbolic,             US$10 or AU$15
  310.             trig (except sin(x), cos(x))
  311. Student         B       hyerbolic                       US$50 or AU$70
  312. Advanced        C                                       US$99 or AU$140
  313. Libraries       *.(x)                                   US$20 or AU$25
  314. .......................................................................
  315. Upgrade         same                                    50%
  316. .......................................................................
  317. Multiple copies >2                                      80%
  318. .......................................................................
  319. Site licence    >10 copies                              50%
  320. -----------------------------------------------------------------------
  321.                  
  322.     Other foreign money is accepted at the current exchange rate.
  323.     You must provide the photocopy of your license or license 
  324. number for upgrades.    
  325.     If you send the author your payment by cheque, money order
  326. or bank draft that must be drawn in Australia, you will get the 
  327. latest version. If you sign the license (see the LICENSE.TXT file) 
  328. and send it to the author, you will be a legal user for upgrades. 
  329. If you write a paper about this software on publication, you will get 
  330. a free upgrade.
  331.     It has three versions: Shareware, Student, and Advanced. The 
  332. shareware version is available from SIMTEL20 archives on anonymous FTP 
  333. sites (e.g. oak.oakland.edu in /pub/msdos/calculator as sm30a.zip).
  334.  
  335.  
  336.         1.4  A List of Files in SymbMath
  337.  
  338. -------------------------------------------------------------------------
  339. SymbMath.exe    executable SymbMath system.
  340. SymbMath.ini    initial file.
  341. SymbMath.h*     help files, * is numbers.
  342. SymbMath.txt    introduction of SymbMath.
  343. SymbMath.doc    document file or manual file.
  344. readme          the read-me file, this file should be read first.
  345. init.sm         initial SymbMath program file.
  346. *.sm            packages (user SymbMath program files).
  347. *.(x)           the auto loaded libraries (external functions).
  348. *.key           the keyword files.
  349. *.bgi           BGI graphics drives.
  350. *.chr           stroked fonts.
  351. prolog.err      prolog error message file.
  352. problem.txt     problems that other software cannot solve, but
  353.         SymbMath can do.
  354. comment*.txt    comments on SymbMath.
  355. statisti.txt    the download statistics at FTP site of garbo.uwasa.fi.
  356. shareware.txt   shareware concept.
  357. software.txt    software available from the author.
  358. update.txt      the latest updates in SymbMath.
  359. PlotData.txt    introduction of PlotData.
  360. ------------------------------------------------------------------------
  361.  
  362.     See Chapter 3.4 "Library and Package" for the detail of the *.(x) 
  363. and *.sm files.
  364.  
  365.  
  366.         2.  SymbMath Environment: Windows and Menus
  367.     When you start SymbMath, the computer screen looks like:
  368.  
  369. --------------------------------------------------------------------------
  370. | File  Input  Run  Output  Color                 Help  Example Keyword  |
  371. ---------------------------------- Input ---------------------------------
  372. |                                                                        |
  373. |                                                                        |
  374. |                                                                        |
  375. --------------------------------------------------------------------------
  376. ---------------------------------- Output --------------------------------
  377. |                                                                        |
  378. |                                                                        |
  379. |                                                                        |
  380. |                                                                        |
  381. --------------------------------------------------------------------------
  382. SymbMath 3.0 | Arrow keys and <Enter>, Highlight or first capital letter
  383. --------------------------------------------------------------------------
  384.     
  385.     The screen is divided into four areas: a menu line, an input
  386. window, an output window, and a status line.
  387.     The menu line is the main menu and locates in the top of the 
  388. screen. 
  389.     The input window is a multi-windowed text editor for input.
  390.     The output window is a multi-windowed text editor for output.
  391.     The status line indicates the current status or which key to 
  392. be active. It places in the bottom of the screen. The content of the 
  393. status line will be changed according to which active window.
  394.     In the menu line, the File, Color, and Help commands have its 
  395. pull-down menus.
  396.     Select the menu by the arrow keys and <Enter>, or the first 
  397. capital letter. The <Esc> key always escape from the current window and 
  398. return to the previous window. 
  399.     A pop-up menu is the Edit Help menu.
  400.  
  401.  
  402.         2.1  File Menu
  403.  
  404.     The File menu has 5 choices in the pull-down menu:
  405.  
  406. -----------
  407. |Open     |
  408. |New      |
  409. |Save     |
  410. |DOS shell|
  411. |Exit     |
  412. -----------
  413.  
  414.                        2.1.1  Open
  415.  
  416.     The Open command opens a file for edit in the Input window. This 
  417. command first opens a Directory window and changes the content of the 
  418. status line to
  419.  
  420. ---------------------------------------------------------------------
  421. <F4> File mask, <F5> Zoom, <Pg Dn> More, -><- Select, <Enter> Accept
  422. ---------------------------------------------------------------------
  423.  
  424. In the Directory window, the following commands are available.
  425.  
  426.     Table 2.1       Commands in the Directory Window 
  427. -------------------------------------------------------------------
  428. key             action
  429.  
  430. <F4>            file mask, e.g. *.sm.
  431. <F5>            zoom the window, zoom back by <F5> again.
  432. <Shift><F10>    resize the window with the -><- keys
  433. -><-            select
  434. <Pg Up>         page up
  435. <Pg Dn>         page down
  436. <Enter>         accept
  437. <Esc>           abort
  438. s               go to the s filename, where s is any single letter.
  439. -------------------------------------------------------------------
  440.  
  441.         You select a file from the Directory window to open for edit in
  442. the Input window.
  443.  
  444.            2.1.2  New
  445.  
  446.     The New command creates a new file, clears the Input window,
  447. and changes the content of the status line to
  448.  
  449. ----------------------------------------------------------------------------
  450. Input filename | <F8> Last filename, -><- Edit, <Enter> Accept, <Esc> Abort
  451. ----------------------------------------------------------------------------
  452.            
  453.            2.1.3  Save Input
  454.     The "Save Input" command saves the file in the Input window into 
  455. disk under a different name or in a different directory.
  456.  
  457.            2.1.4  Save Output
  458.     The "Save Output" command saves the file in the Output window
  459. into disk under a different name or in a different directory.
  460.  
  461.            2.1.5  DOS shell
  462.     The "DOS shell" command executes a DOS command and automatically
  463. returns to the SymbMath system if you provide a DOS command on
  464. the command window, otherwise it goes to the DOS shell, the control must 
  465. be returned to the resident SymbMath system with the EXIT command on the 
  466. DOS shell.
  467.  
  468.         2.1.6  Exit
  469.     The Exit command exits from SymbMath.
  470.  
  471.  
  472.         2.2  Input Menu
  473.  
  474.     The Input menu goes into the Input window.
  475.     SymbMath includes a multi-windowed text editor for creating 
  476. and modifying program files.  Usage of the editor is similar to 
  477. WordStar in nondocument mode, to Borland's SideKick, or to Borland's C
  478. compiler. 
  479.     Within the Input window, press <F8> to open an Aux Edit window 
  480. with an auxiliary editor. In the Auxi Edit window, press <F8> again to 
  481. open another Aux Edit window. So you can open many the Aux Edit windows 
  482. to edit many files.
  483.     Text in the Input window always be saved after exit by pressing
  484. <Esc>. The Aux Edit window is closed with saving by pressing <F10>, or 
  485. without saving by pressing <Esc>.
  486.     In the Input window or the Aux Edit window, press <F1> to pop-
  487. up the Edit Help menu (see 2.2.1 Edit Help Menu), or <Shift><F1> to call
  488. the manual, and <F7> to copy block from the an Aux Edit window into 
  489. the main editor or into the last Aux Edit window. 
  490.     Move the cursor around in the editor with the arrow
  491. keys, <Page Up>, <Page Down>, and some other keys listed below.  The
  492. editor has two typing modes, Insert and Overwrite.  In Insert
  493. mode, anything you type is inserted at the cursor position.  In
  494. Overwrite mode, pressing a key replaces the current character
  495. at the cursor position with the new typed character.  Initially,
  496. the editor operates in Insert mode, to switch modes, press the
  497. <Insert> key or <Ctrl>V.  (<Ctrl>V means to hold down the <Ctrl> key
  498. on your keyboard while you press V.  The V need not be in upper
  499. case.)
  500.     Unlike a more standard word processing program, the editor
  501. does not have word-wrap. You must press <Enter> at the end of each
  502. line.
  503.     The editor has an autoindent feature that allows subsequent
  504. lines to automatically indent.  If you leave several spaces at the
  505. start of a line, use <Ctrl>OI to indent subsequent lines the same
  506. amount.  The command sequence is a toggle, so you need only
  507. press <Ctrl>OI again to stop indenting.
  508.     Sometimes you may want to see more than the area covered by
  509. the current window.  You can zoom the window, expanding it to the
  510. size of the entire screen, by pressing <F5>.  To return the window
  511. to its usual size, press <F5> again.  For other window commands,
  512. such as moving and resizing a window, see the window command table, 
  513. below.
  514.  
  515.     Table 2.2.1   Edit window commands
  516. ---------------------------------------------------------------------
  517. Key             Action
  518.  
  519. <F5>            zoom window, zoom back by <F5> again.
  520. <Shift><F10>    resize window with the -><- keys.
  521. <F8>            open an Aux Edit window.
  522. <F10>           close the Aux Edit window with saving.
  523. <Esc>           close the Aux Edit window without saving.
  524. <F7>            block copy from an Aux Edit window into the last window.
  525. ---------------------------------------------------------------------
  526.  
  527.     The content of the status line 
  528.  
  529. --------------------------------------------------------------------------
  530. F1 Help, F2 Save, F3 Open, F4 Replace, F5 Zoom, F7 XCopy, F8 XEdit, F10 End
  531. --------------------------------------------------------------------------
  532.  
  533. indicates that to press <F1> key to get help.
  534.  
  535.  
  536.       Table 2.2.2  Editing commands.
  537. ---------------------------------------------------------------
  538.   Cursor Movement Commands (move cursor to):
  539.  
  540.   Character left         <Ctrl>S  or Left arrow <-
  541.   Character right        <Ctrl>D  or Right arrow  ->
  542.   Word left              <Ctrl>A  or <Ctrl> <-
  543.   Word right             <Ctrl>F  or <Ctrl> ->
  544.   Line up                <Ctrl>E  or Up arrow
  545.   Line down              <Ctrl>X  or Down arrow
  546.   Scroll up              <Ctrl>W
  547.   Scroll down            <Ctrl>Z
  548.   Page up                <Ctrl>R  or <Pg Up>
  549.   Page down              <Ctrl>C  or <Pg Dn>
  550.   Beginning of line      <Ctrl>QS or <Home>
  551.   End of line            <Ctrl>QD or <End>
  552.   Top of screen          <Ctrl>QE or <Ctrl><Home>
  553.   Bottom of screen       <Ctrl>QX or <Ctrl><End>
  554.   Top of file            <Ctrl>QR or <Ctrl><Pg Up>
  555.   Bottom of file         <Ctrl>QC or <Ctrl><Pg Dn>
  556.   Beginning of block     <Ctrl>QB
  557.   End of block           <Ctrl>QK
  558.   Previous point         <Ctrl>QP
  559.   Marker 0               <Ctrl>Q0
  560.   Marker 1               <Ctrl>Q1
  561.   Marker 2               <Ctrl>Q2
  562.   Marker 3               <Ctrl>Q3
  563.   Set marker 0           <Ctrl>K0
  564.   Set marker 1           <Ctrl>K1
  565.   Set marker 2           <Ctrl>K2
  566.   Set marker 3           <Ctrl>K3
  567.  
  568. ...........................................................
  569.  
  570.   Insert & Delete Commands:
  571.  
  572.   Insert mode on/off                 <Ctrl>V or <Ins>
  573.   Insert line                        <Ctrl>N
  574.   Delete line                        <Ctrl>Y
  575.   Delete to end of line              <Ctrl>QY
  576.   Delete left character              <Ctrl>H or <Backspace>
  577.   Delete character under cursor      <Ctrl>G or <Del>
  578.   Delete right word                  <Ctrl>T
  579.  
  580. ...........................................................
  581.  
  582.   Block commands:
  583.  
  584.   Mark block begin       <Ctrl>KB
  585.   Mark block end         <Ctrl>KK
  586.   Mark word              <Ctrl>KT
  587.   Hide block             <Ctrl>KH
  588.   Copy block             <Ctrl>KC or <Ctrl><F5>
  589.   Repeat the last copy   <Shift><F5>
  590.   Move block             <Ctrl>KV or <Alt><F6>
  591.   Delete block           <Ctrl>KY
  592.   Read block             <Ctrl>KR or <F7>
  593.   Write block            <Ctrl>KW
  594.   Print block            <Ctrl>KP
  595.  
  596. .....................................................................
  597.  
  598.   Miscellaneous Commands:
  599.  
  600.   Quit edit                     <Esc>, <F10>, <Ctrl>KD, or <Ctrl>KQ
  601.   Call the auxiliary editor     <F8>
  602.   Tab                           <Ctrl>I  or <Tab>
  603.   Tab mode toggle               <Ctrl>OT
  604.   Auto indent on/off            <Ctrl>OI
  605.   Restore line                  <Ctrl>QL
  606.   Find                          <Ctrl>QF or <Ctrl><F3>
  607.   Repeat last find              <Ctrl>L  or <Shift><F3>
  608.   Find & replace                <Ctrl>QA or <Ctrl><F4>
  609.   Repeat last find & replace    <Ctrl>L  or <Shift><F4>
  610.   Control key prefix            <Ctrl>P
  611.   Abort operation               <Ctrl>U
  612.   Restore error message         <Ctrl>QW
  613.  
  614.   Search Options:
  615.  
  616.   L           Local search
  617.   G           Global search
  618.   N           Replace without asking
  619.   Y           Replace with asking
  620. ------------------------------------------------------------------
  621.  
  622.     Pop-up the Edit Help menu by pressing <F1>, select the editing 
  623. command from its sub-menus by the arrow keys and <Enter>.
  624.  
  625.  
  626.                2.2.1  Edit Help Menu
  627.  
  628.        Pop-up the Edit Help menu by pressing <F1> within the Edit window 
  629. or the Aux Edit window.
  630.     This menu has 7 choices:
  631.  
  632. ------------------
  633. |Show help file  |
  634. |Cursor movement |
  635. |Insert & Delete |
  636. |Block functions |
  637. |Wordstar-like   |
  638. |Miscellaneous   |
  639. |Global functions|
  640. ------------------
  641.  
  642. Except for the first choice of the "Show help file", others have their 
  643. own sub-menu. You can select the edit command in the sub-menu by the
  644. up or down key and <Enter>.
  645.  
  646.  
  647.             2.3  Run Menu
  648.  
  649.     The Run menu executes the user program in the Input window, 
  650. outputs the results in the Output window, and saves the output into the 
  651. file named "output".
  652.     Notice that it clears memory and executes the initial package 
  653. "init.sm" before it inteprets the users programm in the Input window.
  654. You can run the program from the disk (see Chapter 3.4 Packages).
  655.  
  656.  
  657.             2.4  Output Menu
  658.  
  659.     The Output command goes into the Output window.
  660.     The Output window is similar to the Input window, where you can
  661. edit any text. You can copy the output into your document by the block
  662. copy command in the editor.
  663.     In the Output window, the line with beginning of IN: is content
  664. of input, and the line with beginning of OUT: is the output.
  665.         The output in the Output window is always saved into the file
  666. "output".
  667.  
  668.         2.5  Color Menu
  669.  
  670.     The Color menu has 4 choices:
  671.  
  672. ---------------
  673. |Menu line    |
  674. |Edit window  |
  675. |Output window|
  676. |Status line  |
  677. ---------------
  678.  
  679.     When you choose one of them, a color pattern will come up. There 
  680. are 125 colors in the color pattern. Select your favour color by the 
  681. arrow keys and <Enter>.
  682.  
  683.         2.5.1  Menu line
  684.     It is to change the menu line's color.
  685.  
  686.         2.5.2  Edit window
  687.     It is to change the edit window's color.
  688.  
  689.         2.5.3  Output window
  690.     It is to change the output window's color.
  691.  
  692.         2.5.4  Status line
  693.     It is to change the status line's color.
  694.  
  695.  
  696.         2.6  Help Menu
  697.     The Help menu dispays the syntax of SymbMath language.
  698.  
  699. ------------------
  700. |How to help     |
  701. |Contents        |
  702. |Brief           |
  703. |Data            |
  704. |Function        |
  705. |Procedure & rule|
  706. |eqUation        |
  707. |Array & list    |
  708. |Expression      |
  709. |commenT         |
  710. |eValuate        |
  711. |assigN          |
  712. |cOnditional     |
  713. |Loop            |
  714. |sWitch          |
  715. |Read & write    |
  716. |Sequence        |
  717. |librarY         |
  718. ------------------
  719.  
  720.     In the Help menu, Each command has its own Help window and help
  721. file. The on-line help files are text (ASCII) files.
  722.     While the Help window is open, the status line is changed to
  723.  
  724. ----------------------------------------------------------------------------
  725. Ctrl-F3 Find, Shift-F3 Find again, F5 Zoom, <Pg Dn> more, <Esc> Abort
  726. -----------------------------------------------------------------------------
  727.  
  728.     In the Help window, to search for a special word, you first press
  729. <Ctrl><F3>, then type the word you want to search, finally press
  730. <Ctrl><F3> again. e.g. if you want to search for the word "help", you
  731. first press <Ctrl><F3>, then type "help", finally press <Ctrl><F3> again.
  732. The cursor will go to the word "help". You press <Shift><F3> to repeat
  733. the last find.
  734.     The commands in the Help window are the same as that in the Edit
  735. window, except that text is unable to be changed.
  736.  
  737.     Table 2.6        Commands in the Help window
  738. -------------------------------------------------------------------
  739. Keys            Action
  740.  
  741. -><-            move the cursor.
  742. <F5>            zoom the window, <F5> again to zoom out.
  743. <Esc>           exit from the window.
  744. <F10>           exit from the window, the same as <Esc>.
  745. <Home>          go to the beginning of the current line.
  746. <End>           go to the end of the current line.
  747. <Pg Up>         page up.
  748. <Pg Dn>         page down.
  749. <Ctrl><Home>    go to the beginning of the window.
  750. <Ctrl><End>     go to the end of the windo.
  751. <Ctrl><Pg Up>   go to the beginning of the help file.
  752. <Ctrl><Pg Dn>   go to the end of the help file.
  753. <Crtl><F2>      go to nth line, end by <crtl><F2> instead of <Enter>.
  754. <Ctrl><F3>      find the special word, end by <Ctrl><F3>
  755.         instead of <Enter>.
  756. <Shift><F3>     repeat last find.
  757. <Shift><F10>    re-size window by arrow keys.
  758. x               go to x, where x is a letter.
  759. ----------------------------------------------------------------------
  760.  
  761.     There are other two helps in the Input, Output and Aux Edit 
  762. windows, press <F1> to pop-up the Edit Help menu, or press <Shift><F1> to
  763. open a Help File window for manual.
  764.  
  765.                         2.7  Example Menu
  766.     The Example menu shows examples in SymbMath language.
  767.  
  768. ---------------
  769. |Calculate    |
  770. |Simplify     |
  771. |assUme       |
  772. |comparE      |
  773. |deFine       |
  774. |Limit        |
  775. |Differentiate|
  776. |Integrate    |
  777. |sOlve        |
  778. |suM          |
  779. |Vector       |
  780. |stAtistics   |
  781. |Table        |
  782. |conveRt      |
  783. |Get parts    |
  784. |databasE     |
  785. |learN        |
  786. |draW         |
  787. |Plot         |
  788. ---------------
  789.  
  790.                     2.7  Keyword Menu
  791.         The Keyword menu showes keywords in the SymbMath language.
  792.  
  793. --------------------
  794. |Topic order       |
  795. |Alphabetical order|
  796. |Index             |
  797. |Library index     |
  798. --------------------
  799.  
  800.         The Topic order command opens a help window for the keywords
  801. in topic order.
  802.         The Alphabetical order command opens a help window for the
  803. keywords in alphabetical order.
  804.         The Index command opens an index window, where you can select a
  805. keyword (file *.key) to open a help window for its file. e.g. if you want
  806. to help for the keyword d, you press d and <Enter> to open the help file
  807. d.key.  If the keyword is longer than 8 letter, its filename is the first
  808. 8 letter plus extension .key.
  809.         The Library index command is similar to the Index command, but it
  810. opens a library index window for library (external function file *.(x)).
  811.  
  812.  
  813.             3.  Programming in SymbMath
  814.  
  815.     SymbMath is an interpreter, and runs a SymbMath program in
  816. the Input window, which is written by any editor in the text (ASCII) 
  817. file format. 
  818.     SymbMath language is a procedure language, which is executed
  819. from top to bottom in a program, like BASIC, FORTRAN, or PACSAL.
  820. It also is an expression-oriented language and funtional language. 
  821.     The SymbMath program consists of a number of statements. 
  822. The most useful statement contains expressions, the expression 
  823. includes data, and the most important data is functions.
  824.     The structure of SymbMath language is:
  825.         data -> expression -> statement -> program
  826.     Note that upper and lower case letters are different in 
  827. SymbMath language, (e.g. abc is different from ABC) until the switch
  828. lowercase:=on.
  829.     In the following examples, a line of "IN: " means input, which 
  830. you type in the Edit window, then leave the Edit window by <Esc>,
  831. finally run the program by the command "Run"; while a line of "OUT: "
  832. means output. You will see both input and output are displayed on
  833. two lines with beginning of "IN: " and "OUT: " in the Output window.
  834. You should not type the word "IN: ". Some outputs may be omit on the
  835. examples. # is a comment statement. 
  836.     You can split a line of command into multi-lines of command by
  837. the comma ,. The comma without any blank space must be the last character
  838. in the line.
  839.  
  840.  
  841.             3.1.  Data Types
  842.     The data types in SymbMath language is the numbers, constants, 
  843. variables, functions, equations, arrays, array index, lists, list index,
  844. and strings. All data can be operated. It is not necessary to declare
  845. data to be which type, as SymbMath can recognize it.
  846.  
  847.             3.1.1  Numbers
  848.     The types of numbers are integer, rational, real (floating-point), 
  849. and complex numbers in the range from -infinity to infinity. 
  850.     In fact, the range of the input real numbers is 
  851. -inf, -(10^307)^(10^307) to -(10^-307)^(10^-307), 0, (10^-307)^(10^-307)
  852.  to (10^307)^(10^307), inf.
  853.     The range of the output real numbers is the same as input 
  854. when the switch numeric:=off, but when the switch numeric:=on, it is
  855.     -inf, -1.E307 to -1.E-307, 0, 1.E-307 to 1.E307, inf.
  856.     It means that the number larger than 1.e307 is converted 
  857. automatically to inf, the absolute values of the number less than 
  858. 1.e-307 is converted to 0, and the number less than -1e307 is 
  859. converted to -inf.
  860.  
  861.     For examples:
  862. -------------------------------------------
  863. Numbers         Type
  864.  
  865. 23              integer
  866. 2/3             rational
  867. 0.23            real
  868. 2.3E2           real 
  869. 2+3*i           complex
  870. 2.3+i           complex
  871. ---------------------------------------------
  872.  
  873.  
  874. That "a" and "b" are the same means a-b = 0, while that they are 
  875. different means a-b <> 0. 
  876.     For the real numbers, the upper and lower case letters E 
  877. and e in exponent are the same, e.g. 1e2 is the same as 1E2.
  878.  
  879.  
  880.         3.1.2.  Constants 
  881.  
  882.     The constants are the unchangeable values. There are some 
  883. built-in constants. The name of these built-in constants should be 
  884. avoided in the user-defined constants.
  885.  
  886. ------------------------------------------------------------------
  887. Built-in Constants      Meanings
  888.  
  889. pi:=3.1415926536        the circular constant.
  890. e:=2.7182818285         the base of the natural logarithms.
  891. i:=sqrt(-1)             the imaginary sign of complex numbers.
  892. inf                     infinity.
  893. -inf                    negative infinity.
  894. c_inf                   complex infinity, both real and imaginary parts
  895.             of complex numbers are infinity. e.g. inf+inf*i.
  896. constant                the integral constant.
  897. discont                 discontinuity, e.g. 1/0. 
  898.             (You can evaluate the one-
  899.             sided value by x=x0+zero or x0-zero if the 
  900.             value of expression is discont).
  901. x0-zero                 to evaluate left-sided value when x approach x0 
  902.             from negative (-inf) direction, as zero -> 0.
  903. x0+zero                 to evaluate right-sided value when x approach x0 
  904.             from positive (+inf) direction, as zero -> 0.
  905. undefined               the undefined value, e.g. indeterminate forms:
  906.             0/0, inf/inf, 0*inf, 0^0, etc.
  907. --------------------------------------------------------------------
  908.  
  909. Zero is the positive-directed 0, as the built-in constant. f(x0+zero)  
  910. is the right-hand sided function value when x approaches to x0 from the
  911. positive direction, i.e. x = x0+. f(x0-zero) is the left-sided function
  912. value when x approaches to x0 from the negative direction, i.e. x = x0-.
  913. e.g. f(1+zero) is the rigth-hand sided function value when x approaches 
  914. to 1 from the positive (+infinity) direction, i.e. x = 1+, f(1-zero) is
  915. the left-hand sided function value when x approaches to 1 from the negative
  916. (-infinity) direction, i.e. x = 1-; exp(1/(0+zero)) gives inf,
  917. exp(1/(0-zero)) gives 0.
  918.         The inf, discont and undefined can be computed as if numbers.
  919.  
  920.         Example.
  921. IN:  inf+2, discont+2, undefined+2
  922. OUT: inf, discont, undefined
  923.  
  924.     Notice that the discont and undefined constants are
  925. different. If the value of an expression at x=x0 is discont, the
  926. expression only has the one-sided value at x=x0 and this one-sided 
  927. value is evaluated by x=x0+zero or x=x0-zero. If the value of an 
  928. expression at x=x0 is undefined, the expression may be evaluated by 
  929. the function lim(). 
  930.  
  931.     Example 3.1.1. evaluate exp(1/x) and sin(x)/x at x=0.
  932.  
  933. IN:  f(x_) := exp(1/x)
  934. OUT: f(x_) := exp(1/x)
  935. IN:  f(0)
  936. OUT: discont            # f(0) is discontinuty, only has one sided value
  937. IN:  f(0+zero)          # right-sided value
  938. OUT: inf
  939. IN:  f(0-zero)          # left-sided value
  940. OUT: 0
  941.  
  942. IN:  subs(sin(x)/x, x = 0)
  943. OUT: undefined
  944. IN:  lim(sin(x)/x, x = 0)     # it is evaluated by lim()
  945. OUT: 1
  946.  
  947.  
  948.         3.1.3.  Variables
  949.  
  950.     The sequence of characters is used as the name of variables. 
  951. Variable names can be up to 128 characters long. They must begin with a
  952. letter and use only letters and digits.  SymbMath knows upper and lower
  953. case distinctions in variable names, so AB, ab, Ab and aB are the
  954. different variables. They are case sensitive until the switch lowercase is
  955. set to on (i.e. lowercase:=on).
  956.      Variables can be used to store the results of calculations.
  957. Once a variable is defined, it can be used in another formula.  Having
  958. defined X as above, you could define Y := ASIN(X).  You can also redefine a
  959. variable by storing a new value in it.  If you do this, you will lose the
  960. original value entirely.
  961.          Assign a result to a variable, just put
  962.       <var-name> :=  expression
  963. e.g.               a := 2 + 3      # assign value to a
  964.       Variables can be used like constants in expressions.
  965. For example:
  966.                a := 2 + 3
  967.                b := a*4
  968.       If an undefined variable is used in an expression, then the
  969. expression returns a symbolic result (which may be stored in another
  970. variable).  Pick an undefined variable name, say x, and enter:
  971.  
  972.                y := 3 + x  # formula results since x undefined
  973.                x := 4      # Now x is defined
  974.                y           # y returns 7, but its value is
  975.                    # still the formula 3 + x
  976.                x := 7      # revalue x
  977.                y           # new value for y
  978.  
  979.     Note that in symbolic computation, the variable has not only a
  980. numeric value but also a symbolic value.
  981.     Symbolic values for variables are useful mostly for viewing 
  982. the definitions of functions and symbolic differentiation and 
  983. integration.
  984.     Watch out for infinite recursion here.  Defining
  985.                x := x+3
  986. when x has no initial value, it will not cause an immediate problem,
  987. but any future reference to x  will result in an infinite recursion !
  988.     A value can be assigned to the variable, by one of three methods:
  989. (1) the assignment :=, 
  990. (2) the user-defined function f(), 
  991. (3) subs(y, x = x0).
  992.  
  993. e.g. 
  994. y:=x^2
  995. x:=2                    # assignment
  996. y
  997. f(2)                    # if f(x) has been defined, e.g. f(x_):=x^2.
  998. subs(x^2, x = 2)        # evaluate x^2 when x = 2.
  999.     The variable named last is the built-in as the variable last is
  1000. always automatically assigned the value of the last output result.
  1001.         The usual used independent variable is x.
  1002.         By default, |x| < inf and all variables are complex, except that
  1003. variables in inequalities are real, as usual only real numbers can be
  1004. compared. e.g. x is complex in sin(x), but y is real in y > 1.
  1005.     You can restrict the domain of a variable by assuming the variable
  1006. is even, odd, integer, real number, positive or negative (see Chapter 4.2
  1007. Simplification and Assumption).
  1008.  
  1009.  
  1010.         3.1.4  Patterns
  1011.     Patterns stand for classes of expressions.
  1012.  
  1013. _       any expression.
  1014. x_      any expression, given the name x.
  1015.  
  1016. Patterns should appear on the left-hand side of the assignment only,
  1017. not on the right-hand side of the assignment. Patterns are only used in
  1018. definition of functions, procedures and rules.
  1019.         Patterns in SymbMath language are similar with patterns in such
  1020. language as MATHEMATICA.
  1021.  
  1022.         3.1.5.  Functions, Procedures and Rules
  1023.     These are two types of functions: internal and external. The
  1024. internal function is compiled into the SymbMath system. The external
  1025. function is the library written in SymbMath language, which is 
  1026. automately loaded when it is needed. (See Chapter 3.4 Library and Package).
  1027. The usgae of both types are the same. You can change the property or name
  1028. of the external function by modifying its library file, or you add a new 
  1029. external function by creating its library file, but you cannot change the 
  1030. internal function.
  1031.  
  1032.         3.1.5.1  Standard Mathematical Functions
  1033.      Different versions of SymbMath have different number of
  1034. standard mathematical functions. The Advanced Version C has all of them.
  1035. See the following table in detail for other versions. All below standard
  1036. functions, (except for random(x), n!, fac(n) and atan2(x,y)), can be 
  1037. differentiated and integrated symbolically.
  1038.  
  1039.      Table 3.1.5.1  Standard Mathematical Functions
  1040. -----------------------------------------------------------------------
  1041. Functions       Meanings
  1042.  
  1043. random(x)       generate a random number.
  1044. n!              factorial of n.
  1045. fac(n)          the same as n!.
  1046. sqrt(x)         square root, the same as x^0.5.
  1047. root(x,n)       all n'th root of x.
  1048. exp(x)          the same as e^x.
  1049. sign(x)         1 when re(x) > 0, or both re(x) = 0 and im(x) > 0; 0 when
  1050.         x=0; -1 otherwise.
  1051. abs(x)          absolute value of x.
  1052. ln(x)           natural logarithmic function of x, based on e.
  1053. log10(x)
  1054. sin(x)          sine function of x.
  1055. cos(x) 
  1056.  
  1057. ............... above functions in Shareware Version A ...............
  1058.  
  1059. tan(x) 
  1060. csc(x) 
  1061. sec(x) 
  1062. cot(x) 
  1063. asin(x)         arc sine function of x, the inverse of sin(x).
  1064. acos(x) 
  1065. atan(x)
  1066. acot(x)
  1067. asec(x)
  1068. acsc(x)
  1069. atan2(x,y)      the radian angle of (x,y).
  1070.  
  1071. ............... above functions in Student Version B .................
  1072.  
  1073. sinh(x)         hyerbolic sine function of x.
  1074. cosh(x) 
  1075. tanh(x) 
  1076. csch(x) 
  1077. sech(x) 
  1078. coth(x)
  1079. asinh(x)        arc hyerbolic sine function of x, the inverse of sinh(x).
  1080. acosh(x) 
  1081. atanh(x)
  1082. acoth(x)
  1083. asech(x)
  1084. acsch(x)
  1085.  
  1086. --------------------------------------------------------------------------
  1087.  
  1088.  
  1089.         3.1.5.2  Calculus Functions 
  1090.     Calculus functions are for calculus calculation. The first 
  1091. arguement of the function is for evaluation, and the second arguement
  1092. is a varilable that is with repsect to.
  1093.  
  1094.         Table 3.1.5.2       Calculus Functions
  1095. ----------------------------------------------------------------------
  1096. Functions       Meanings
  1097.  
  1098. subs(y, x = x0)      evaluates y when x = x0.
  1099. lim(y, x = x0)          gives the limit of y when x approaches x0.
  1100.             Note that the correct answers usually for the 
  1101.             indeterminate forms: 0/0, inf/inf, 0*inf, 0^0, 
  1102.             inf^0.
  1103.  
  1104. d(y, x)         differentiate y with respect to x.
  1105. d(y, x, order)  gives the nth order derivative of y with respect to an 
  1106.         undefined variable x.
  1107. d(y)            implicit differentiation.
  1108.  
  1109. inte(y, x)      find the indefinite integral of y with respect to an
  1110.         undefined variable x.
  1111. inte(y,x,a,b)   find the definite integral of y with respect to an 
  1112.         undefined variable x taken from x=a to x=b.
  1113. inte(y,x,a,b,c)   find the definite integral of y with respect to an 
  1114.         undefined variable x taken from x=a to x=b, then to x=c,
  1115.         where b is singularity.
  1116. inte(y, x from a to b)  the same as inte(y,x,a,b).
  1117. inte(y)         implicit integration, used to integrate the 
  1118.         differential equations.
  1119.  
  1120. dsolve(y'(x)=f(x,y), y(x), x)         solve differential equations.
  1121.  
  1122. sum(y, x from xmin to xmax)             sum of y step=1.
  1123. sum(y, x from xmin to xmax step dx)     sum of y.
  1124.  
  1125. prod(y, x from xmin to xmax)            product of y step=1.
  1126. prod(y, x from xmin to xmax step dx)    product of y.
  1127. ---------------------------------------------------------------------
  1128.  
  1129.     If a second argument x is omitted in the functions d(y) 
  1130. and inte(y), they are implicit derivatives and integrals. If f(x) is 
  1131. undefined, d(f(x), x) is differentiation of f(x). These are useful 
  1132. in the differential and integral equations. (see later chapters).
  1133.     For examples:
  1134.     inte(inte(F,x), y) is double integral of F with respect 
  1135. to both variables x and y. 
  1136.     d(d(y,x),t) is the mixed derivative of y with respect
  1137. to x and t.
  1138.     The keywords "from" "to" "step" "," are the same as separators
  1139. in multi-arguement functions. e.g. inte(f(x), x, 0, 1) are the same as
  1140. inte(f(x), x from 0 to 1).
  1141.  
  1142.        Examples:
  1143. -------------------------------------------------------------------
  1144. differentiation         d()             d(x^2,x)
  1145. integration             inte()          inte(x^2,x)
  1146. limit                   lim()           lim(sin(x)/x, x = 0)
  1147. --------------------------------------------------------------------
  1148.  
  1149.         3.1.5.4  Test Functions
  1150.  
  1151.         Table 3.1.5.4.1  is*(x) Functions
  1152. ---------------------------------------------------------------------
  1153. Function                Meaning
  1154.  
  1155. isodd(x)                test if x is an odd number.
  1156. iseven(x)               test if x is an even number.
  1157. isinteger(x)            test if x is an integer number.
  1158. isratio(x)              test if x is a rational number.
  1159. isreal(x)               test if x is a real number.
  1160. iscomplex(x)            test if x is a complex number.
  1161. isnumber(x)             test if x is a number.
  1162. islist(x)               test if x is a list.
  1163. isfree(y,x)             test if y is free of x.
  1164. issame(a,b)             test if a is the same as b.
  1165. islarger(a,b)           test if a is larger than b.
  1166. isless(a,b)             test if a is less than b.
  1167. ----------------------------------------------------------------------
  1168.         
  1169. All of the is* functions give either 1 if it is true or 0 otherwise.
  1170.  
  1171.      The type(x) gives the type of x. Its value is a string.
  1172.  
  1173.                 Table 3.1.5.4.2  type(x) functions
  1174. --------------------------------------------------
  1175. x                   type(x)          
  1176.  
  1177. 1                   "integer"        
  1178. 1.1                 "real"
  1179. 2/3                 "ratio"
  1180. 1+i                 "complex"
  1181. sin(x)              "sin()"
  1182. [1,2]               "[]"
  1183. a                   "variable"
  1184. a+b                 "+"
  1185. a*b                 "*"
  1186. a^b                 "^"
  1187. "a"                 "string"
  1188. a=b                 "="
  1189. a==b                "=="
  1190. a>b                 ">"
  1191. a>=b                ">="
  1192. a<b                 "<"
  1193. a<=b                "<="
  1194. a<>b                "<>"
  1195. a,b                 ","
  1196. ---------------------------------
  1197.  
  1198.         You also can test x, e.g. if x is type of real number, by
  1199. type(x)=="real".
  1200.  
  1201.         3.1.5.3  Miscellaneous Functions
  1202.  
  1203.         Table 3.1.5.3      Algebra Functions
  1204. ---------------------------------------------------------------------
  1205. expand(F)               expand (a+b)^2 to a^2 + 2*a*b + b^2.
  1206. factor(F)               factorise a^2 + 2*a*b + b^2 to (a+b)^2.
  1207. solve(f(x)=0, x)        solve polynomial and systems of linear
  1208.             equations, or rearrange the equation.
  1209. ---------------------------------------------------------------------
  1210. Note: the Shareware Version has not solve().
  1211.  
  1212.     For example:
  1213. -----------------------------------------------------------
  1214. solving                 solve()         solve(x^2+1 = 0, x)
  1215. expanding               expand()        expand((a+b)^2)         
  1216. factoring               factor()        factor(a*c+b*c)         
  1217. -----------------------------------------------------------
  1218. where x is an undefined variable.
  1219.  
  1220.     Conversion functions convert a type of data to another
  1221. type of data.
  1222.  
  1223.                 Table 3.1.5.4   Conversion Functions
  1224. ---------------------------------------------------------------------
  1225. listsum([a,b])          convert list to sum.
  1226. coef(expr, x^2)         gives the coefficient of x^2 in expr.
  1227. left(x^2=b)             left hand side of an equation.
  1228. right(x^2=b)            right hand side of an equation.
  1229. re(x)                   real part of complex numbers.
  1230. im(x)                   imaginative part of complex numbers.
  1231. num(x)                  convert x to the floating-point number.
  1232. ratio(x)                convert x to the rational number.
  1233. round(x)                convert x to the rounded integer.
  1234. trunc(x)                convert x to the truncated integer.
  1235. ----------------------------------------------------------------------
  1236.  
  1237.         Table 3.1.5.5     The List and Table Functions
  1238. ----------------------------------------------------------------------
  1239. list(f(x), x from xmin to xmax step dx)         lists of f(x).
  1240. table(f(x), x from xmin to xmax step dx)        
  1241.     data table of function values.
  1242. ----------------------------------------------------------------------
  1243.  
  1244.     Above functions can be operated and chained, like the standard 
  1245. functions. 
  1246.  
  1247.                3.1.5.5     User-defined Functions
  1248.     You can define the new functions, which include the
  1249. standard functions, calculus functions, and algebraic operators.
  1250.     Define a new function f(x) by  
  1251.         f(x_) := x^2
  1252. and then call f(x) as the standard functions. The function name can 
  1253. be any name, except for some keywords. The maximum number of arguments 
  1254. in the users-defined functions on this version is 6, but that in the
  1255. users-defined rules on this version is 2.
  1256.     Clears a variable or function from assignment by
  1257.         clear(x)          # clear x from assignment.
  1258.         clear(f(x))       # clear f(x) from assignment.
  1259.         clear(a>0)        # clear a>0 from assignment.
  1260.     Variables can be used in function definitions. It leads to 
  1261. an important difference between functions and variables.  When a 
  1262. variable is defined, all terms of the definition are evaluated.  When 
  1263. a function is defined, its terms are not evaluated; they are evaluated 
  1264. when the function is evaluated.  That means that if a component of the 
  1265. function definition is changed, that change will be reflected the next 
  1266. time the function is evaluated.
  1267.  
  1268.           3.1.5.6  Procedures
  1269.     A procedure is similar to a function, but the right side of
  1270. assigment in its definition is multi statements grouped by block().
  1271. block(a,b,c) groups a,b,c and only returns the last arguement as its
  1272. value, or returns the second last arguement as its value if the last
  1273. arguement is local(). It is used as grouper in definition of a procedure.
  1274. All variables in block are global, except for variables declared by
  1275. local().
  1276.         e.g. f(x_):=block(p:=x^6,p,local(p))
  1277.         Remember that you can split a line of program into multi-lines
  1278. program at comma ,.
  1279.  
  1280.           3.1.5.7  Rules
  1281.     Defining rules is similar to defining functions. In definition 
  1282. of function, all arguements of function are simple variables, but in 
  1283. definition of rules, the first arguement may be a complicated expression.
  1284.     e.g.
  1285.     f(x_,y_) := x^2+y^2                     # defining function
  1286.     f(x_,y_) := block(a:=2, a+x^2+y)        # defining procedure
  1287.     log(x_ * y_) := log(x)+log(y)           # defining rule
  1288.  
  1289.  
  1290.         3.1.6  Equations
  1291.     An equation is an equality of two sides linked by an equation
  1292. sign =, e.g. x^2+p = 0, where the symbol = stands for an
  1293. equation. Note that the symbols "=", "==" and ":=" are different:
  1294. ":=" is the assignment, "==" is the equal sign, and "=" is the 
  1295. equation sign.
  1296.          Example:
  1297. IN:  2 = 2
  1298. OUT: 2 = 2             # unevaluated
  1299. IN:  2 == 2
  1300. OUT: 1                 # evaluated to 1 (true)
  1301.  
  1302.     Systems of equations are a list of equations, e.g. 
  1303. [a1*x+a2*y=a3, b1*x+b2*y=b3].
  1304.  
  1305.                 3.1.7  Inequalities
  1306.         e.g.
  1307.                a < b              less than
  1308.                a <= b             less than or equal to
  1309.                a > b              greater than
  1310.                a >= b             greater than or equal to
  1311.                a == b             equal to
  1312.                a <> b             not equals
  1313.  
  1314.  
  1315.                 3.1.8  Arrays and Array Index
  1316.         Arrays are the same as arrays in such language as PASCAL and
  1317. FORTRAN. But you can use arrays without declaring arrays, unlike in PASCAL
  1318. and FORTRAN.
  1319.         e.g.
  1320. a[1]:=1
  1321. a[2]:=4
  1322.  
  1323.     The array index is the index for n-th element in an array. e.g.
  1324. a[2] indicates the second element in the array a.
  1325.  
  1326.         3.1.9  Lists and List Index
  1327.         Lists are similar to lists in such language as PROLOG.
  1328.     [a, b, c] is a list.
  1329.         [a, b, [c1, c2]] is a list of lists.
  1330.     The list index is the index for n-th element in a list. e.g.
  1331. b[2] indicates the second element in the list b.
  1332.     The built-in list index is last[number]. The name of last
  1333. output list is last, e.g. last[1] is the first element in the
  1334. last output list.
  1335.  
  1336.                 3.1.10  Strings
  1337.     A string is a sequence of characters between two quotation marks.
  1338. e.g. "1234567890". Note that 1234 is number but "1234" is string. The
  1339. number can be calculated and only has 11 of max digits, while string
  1340. cannot be calculated and has 64000 of max characters long.
  1341.         Strings can be storeed in variables, concatenated, removed,
  1342. lengthed, and converted to numbers if possible.
  1343.         e.g. 
  1344. IN:  p := "abc"                  # "abc" is stored in variable p
  1345. OUT: p := "abc"
  1346. IN:  concat("s","t")             # concatenate "s" and "t"
  1347. OUT: st
  1348. IN:  remove("b" from "ab")       # remove "b" from "ab"
  1349. OUT: "a"
  1350. IN:  length("abc")               # count length of "abc"
  1351. OUT: 3
  1352. IN:  number("123")               # convert string "123" into number 123
  1353. OUT: 123       
  1354.  
  1355.  
  1356.             3.2.   Expressions
  1357.     Expressions (i.e. expr) are made up of operators and operands.
  1358. Most operator are binary, that is, they take two operands; the rest
  1359. are unary and take only one operand. Binary operators use the usal
  1360. algebraic form, e.g. a+b.
  1361.     There are two kinds of expressions: numeric and Boolean. The
  1362. numeric expression is combination of data and algebraic operators while
  1363. the Boolean expression is combination of data and relational operators
  1364. and logic operators. These two kinds of expressions can be mixed, but
  1365. the numeric expression has higher priority than Boolean operators.
  1366. x*(x>0) is different from x*x>0. x*x>0 is the same as (x*x)>0.
  1367.  
  1368. e.g.
  1369. a+b+3           numeric expression,
  1370. a>0             Boolean expression
  1371. a>0 and b>0     Boolean expression
  1372. (x>0)*x         mixed numeric and Boolean expression
  1373.  
  1374.                         3.2.1   Operators
  1375.  
  1376.     Table 3.2.1       Operators
  1377. -----------------------------------------------------------------
  1378. Operation               Operators       Examples        Order
  1379.  
  1380. comma                   ,               a:=2, b:=3      1
  1381. assignment              :=              p:=2+3          2
  1382. and                     and             a>2 and a<8     2
  1383. or                      or              a>2 or b>2      2
  1384. equation                =               x^2+x+1 = 0     3
  1385. equal                   ==              a==2            3
  1386. larger than             >               a>2             3
  1387. larger and equal        >=              a>=2            3
  1388. less than               <               a<2             3
  1389. less and equal          <=              a<=2            3
  1390. unequal                 <>              a<>2            3
  1391. plus                    +               a+b             4
  1392. minus                   -               a-b             4
  1393. mutilation              *               a*b             5
  1394. division                /               a/b             5
  1395. power                   ^               a^b             6
  1396. power                   **              a**b            6
  1397. factorial               !               n!              6
  1398. positive                +               +a              7
  1399. negative                -               -a              7
  1400. function                f()             sin(x)          7
  1401. list index              f[]             f[1]            7
  1402. parentheses             ()              (a+b)*c         7
  1403. list                    []              [a,b]           7
  1404. --------------------------------------------------------------------
  1405.  
  1406.     All functions have the same 7th order.
  1407.     Operations with higher order precede, otherwise operations with
  1408. equal precedence are performed from left to right.  These are the usual
  1409. algebraic conventions.
  1410.     a^b^c is the same as (a^b)^c.
  1411.         You can get operators by type(x).
  1412.  
  1413.                 3.2.1.1  Arithmetic operators
  1414.  
  1415. --------------------------------------------------------------------
  1416. plus                    +               a+b             4
  1417. minus                   -               a-b             4
  1418. mutilation              *               a*b             5
  1419. division                /               a/b             5
  1420. power                   ^               a^b             6
  1421. power                   **              a**b            6
  1422. positive                +               +a              7
  1423. negative                -               -a              7
  1424. --------------------------------------------------------------------
  1425.  
  1426.         3.2.1.2  Relational Operators
  1427.       Before you can write loops, you must be able to write 
  1428. statements that evaluate to 1 or 0, and before you can do that, you
  1429. must be able to write useful statements with logical values.  In
  1430. mathematics, these are relational statements.
  1431.     SymbMath allows you to compare numbers six ways:
  1432.  
  1433.                a < b              less than
  1434.                a <= b             less than or equal to
  1435.                a > b              greater than
  1436.                a >= b             greater than or equal to
  1437.                a == b             equal to
  1438.                a <> b             not equals
  1439.  
  1440.       SymbMath uses the double equals sign == (like C language) for
  1441.  "is equal to" to distinguish this operator from the equation =.
  1442.       The result of a comparison of two real numbers is either 1 or 0. 
  1443. If the comparsion is not both real numbers, it left unevaluated.
  1444.  
  1445.  
  1446.         3.2.1.3    Logical operators
  1447.       SymbMath uses the logical operators:  AND, and OR.  You can
  1448. combine comparison operators with them to any level of complexity.
  1449. In contrast to Pascal, logical operators in SymbMath have a lower
  1450. order or precedence than the comparisons, so  a < b  and  c > d
  1451. works as expected.  The result of combining logical values with
  1452. logical operators is another logical value (1 or 0).  Bit operations 
  1453. on integers can be performed using the same operations, but result is
  1454. integers.
  1455.       SymbMath uses the "short-circuit" definition of AND and OR 
  1456. when the arguments are boolean.  Here are tables that show how AND 
  1457. and OR are defined:
  1458.  
  1459.              a AND b
  1460. --------------------------------------------------------
  1461.             b       1       0
  1462.         a
  1463.         1               1       0
  1464.         0               0       0
  1465. ------------------------------------------------------
  1466.  
  1467.              a OR b
  1468. --------------------------------------------------------
  1469.             b       1       0
  1470.         a
  1471.         1               1       1
  1472.         0               1       0
  1473. ------------------------------------------------------
  1474.  
  1475.     Short-circuit evaluation is used because often one condition
  1476. must be tested before another is meaningful.
  1477.     The result of Boolean expression with logic operators is either
  1478. 1 or 0. Boolean expression like (1 < 3 or 1 > 4) return a real value 1
  1479. or 0.  Numeric expressions can replace Boolean ones, provided
  1480. they evaluate to 1 or 0.  The advantage here is that you can
  1481. define the step function that is 0 for x < a and 1 for x > a by
  1482. entering:
  1483.  
  1484.             step(x_, a_) := x > a
  1485.  
  1486.     To define the function:
  1487.  
  1488.             f(x) = x-1    if x < 1
  1489.                  = x^2-x  if x >= 1
  1490.  
  1491.     enter:
  1492.            f(x_) := (x-1)*(x < 1) + (x^2-x)*(x >= 1)
  1493.  
  1494.     These functions can be differentiated and integrated symbolically.
  1495.  
  1496.                         3.2.2  Function calls
  1497.         A function call activates the function specified by the function
  1498. name. The function call must have a list of actual parameters if the
  1499. corresponding function decalaration contains a list of formal parameters.
  1500. Each parameter takes the place of the corresponding formal parameter.
  1501. If the function is external, the function call will automatically load
  1502. the library specified by its function name plus extension .fun when needed.
  1503.        Some examples of function calls follow:
  1504.             sin(x)            # will load the library sin.fun when needed
  1505.             inte(x^2, x)      # will load the library inte.fun when needed
  1506.  
  1507.  
  1508.                     3.3    Statements
  1509.                 3.3.1  Comment Statements
  1510.  
  1511.     # is the comment statement sign.
  1512.     You can add comments into a line, or even produce a single 
  1513. line which is entirely a comment, by preceding the comment sign with #.
  1514.     For example:
  1515.            # This is my program
  1516.            3 + 4    # My first calculation
  1517.  
  1518. Comments make your calculations more understandable, whether you
  1519. are making a printed record of what you are doing or if you just
  1520. want to jot some notes to yourself while you are working.
  1521.  
  1522.  
  1523.         3.3.2  Evaluation Statements
  1524.     The evaluation statement has the format:
  1525.  
  1526.         expression
  1527.  
  1528.     SymbMath evaluates any expression which in a line and gives
  1529. the value of the expression. e.g.
  1530.  
  1531. IN:  3 + 4
  1532. OUT: 7          # the value of 3+4
  1533. IN:  d(x^6, x)
  1534. OUT: 6 x^5      # the value of d(x^6, x)
  1535. IN:  subs(last, x = 1)         # evaluate the last output when x = 1.
  1536. OUT: 6
  1537.  
  1538.     The last output can be saved to a variable for the later use
  1539. by the built-in variable "last", e.g. f:=last.
  1540.  
  1541.  
  1542.          3.3.3  Assignment Statements
  1543.         The assignement in SymbMath language is similar to assignment in
  1544. such language as PASCAL.
  1545.         An assignment operator is   :=
  1546.     The assignment statement specifies that a new value of expr2 
  1547. be assigned to expr1, and saved into memory. The form of the assignment
  1548. statements is
  1549.  
  1550.         expr1 := expr2
  1551.  
  1552.         You can use assignment for storing result.
  1553.         You can assign the result of calculation or any formula to a
  1554. variable with a command like:    X := SIN(4.2).
  1555.         The assignemts are useful for long calculations.  You can save
  1556. yourself a lot of recalculations by always storing the results of your
  1557. calculations in your own variables instead of leaving them in the default
  1558. variable last.
  1559.         You can destroy the assignmemt to X with the command clear(X). If 
  1560. X stored a large list, you could regain a considerable amount of memory by
  1561. clearing X. Also, since a variable and a function can have the same name,
  1562. you can clear a variable p, not a function p(x).
  1563.     The assignment operator is also used in the definition of
  1564. a function or procedure.
  1565.         Variables can be used in function definitions, and that leads to an
  1566. important difference between functions and variables.  When a variable is
  1567. defined, all terms of the definition are evaluated.  When a function is
  1568. defined, its terms are not evaluated; they are evaluated when the function 
  1569. is evaluated.  That means that if a component of the function definition is
  1570. changed, that change will be reflected the next time the function is
  1571. evaluated.
  1572.  
  1573.     e.g. 
  1574. IN:  p:=2+3     # 2+3 is evaluated at the time of assignment,
  1575.             # p is assigned with 5.
  1576. OUT: p := 5
  1577. IN:  p(x):=2+3  # 2+3 is evaluated when the value of p(x) is requested,  
  1578.             # p(x) is assigned with 2+3.
  1579. OUT: p(x) := 2+3
  1580.  
  1581. If the left hand side of the assignment is a variable, it is the immediate
  1582. assignment (i.e. expr2 is evaluated at the time of assignment); if the
  1583. left hand side is a function, it is the delayed assignment (i.e. expr2 is
  1584. evaluated when the value of expr1 is requested).
  1585.         You can force all the components of a function to be evaluated when
  1586. the function is defined by preceding the function with the command eval():
  1587.                 f(x_) := eval(2+3)   # f(x_) is assigned with 5
  1588.     Note that not only a variable but also any expression can be
  1589. assigned. e.g. x:=2, sin(x)/cos(x) := tan(x), a>0 := 1.
  1590.     Clear a variable, function or expression from assignment by
  1591.  
  1592.         clear(x)          # clear x from assignment.
  1593.         clear(f(x))       # clear f(x) from assignment.
  1594.         clear(a>0)        # clear a>0 from assume(a>0).
  1595.  
  1596.  
  1597.         3.3.4  Conditional 
  1598.     There are two conditional functions:
  1599.         if(test then x)
  1600.         if(test then x else y)
  1601. if(condition then x)            gives x if condition evaluates to 1, or no 
  1602.                 output otherwise.
  1603. if(condition then x else y)     gives x if condition evaluates to 1, y if 
  1604.                 it evaluates to 0, or no output if it 
  1605.                 evaluates to neither 1 or 0.
  1606. The 2 words (then and else) can be replaced by comma ,.
  1607.       It is useful in definition of the use-defined function to left the
  1608. function unevaluted if the argument of the function is not number.
  1609. e.g. define f(x_):=if(isnumber(x), 1), then call f(x), f(10) gives 1, 
  1610. and f(a) gives f(a).
  1611.  
  1612.  
  1613.         3.3.5  Loop 
  1614.     You can use two kinds of loops in SymbMath, fixed length
  1615. loops controlled by do() and variable-length loops controlled by
  1616. repeat(). The do() loop is similar to the FOR loop in BASIC language.
  1617.     The control variable in the do() loops is not limited to
  1618. integer values.  You can say:
  1619.  
  1620.         do(f:=f+1, x from xmin to xmax step dx)
  1621.  
  1622. It is similar to
  1623.         FOR x := xmin TO xmax STEP dx
  1624.         f:=f+1
  1625.         NEXT x
  1626. where xmin, xmax, and dx are real values.  If STEP dx is omitted, it
  1627. defaults to 1.
  1628.  
  1629.     e.g.
  1630. IN:  x:=1
  1631. OUT: x := 1
  1632. IN:  do(x:=x+1, j from 1 to 5 step 1)
  1633. OUT: x := 5
  1634.  
  1635.  
  1636.       The conditional loops are probably more useful than the do()
  1637. loops if a number of iteration is unknown. It is
  1638.         repeat(y until test)
  1639.         repeat(y, test)
  1640. The word (until) can be replaced by comma ,.
  1641. The repeat() repeats to evaluate f until the test is true (i.e. the
  1642. result of the test is 1).
  1643.     Example.
  1644.  
  1645. IN:  x:=1
  1646. OUT: x := 1
  1647. IN:  repeat(x:=x+1 until x>5)
  1648. OUT: x := 6
  1649.  
  1650.  
  1651.                     3.3.6  Switch 
  1652.     The switch sets or changes the switch status. The switch status
  1653. is unchanged in memory until the switch is assigned by the new value.
  1654.  
  1655. ----------------------------------------------------------------------
  1656. Switch                   Action
  1657.  
  1658. output:=math             output form is math symbol notation, this is
  1659.                  default.
  1660. output:=basic            output form is BASIC format.
  1661. output:=fortran          output form is FORTRAN format.
  1662. output:=prolog           output form is Prolog format (internal form).
  1663. output:=off              not display output.
  1664. output:=on               the same as ouput:=basic
  1665.  
  1666. lowercase:=on            convert letters into the lower-case letters.
  1667. lowercase:=off           not convert letters into the lower-case letters,
  1668.              this is default.
  1669.  
  1670. numeric:=on              convert numbers to floating-point numbers.
  1671. numeric:=off             not convert numbers to floating-point numbers,
  1672.              this is default.
  1673.  
  1674. expand:=on               expansion. e.g. c*(a+b) to c*a+c*b.
  1675. expand:=off              disable expansion, this is default.
  1676.  
  1677. expandexp:=on            expand exponent. e.g. c^(a+b) to c^a*c^b.
  1678. expandexp:=off           disable exponent expansion, this is default.
  1679. ----------------------------------------------------------------------
  1680.  
  1681.         3.3.6.1.  Output Switch
  1682.     When the switch output:=math, the output displays the math symbol
  1683. notation (e.g. π). 
  1684.     When the switch output:=basic, the output form is the BASIC
  1685. language format. 
  1686.     When the switch output:=fortran, the output form is the FORTRAN
  1687. language format. 
  1688.     The default switch is output:=math.
  1689.     The output switch only changes the output format, neither affects
  1690. the internal format nor the calculation.
  1691.  
  1692.     Example 3.3.6.1
  1693.     In the Input window, you type
  1694. inte(pi*sin(x)^2,x)
  1695.     You see the display of your input in the Output window as
  1696.  
  1697.  ⌠ π sin(x)^2 dx
  1698.  
  1699. --------------------------------------
  1700. Math symbol             Typing
  1701.  
  1702. π                       pi
  1703. ⌠ f(x) dx               inte(f(x),x)
  1704. √x                      sqrt(x)
  1705. a b                     a*b
  1706. -------------------------------------
  1707.  
  1708.         
  1709.         3.3.6.2  Case Switch
  1710.     When the switch lowercase := on, all letters are converted into
  1711. the lower-case letters so the upper- and lower- case letters are the 
  1712. same, e.g. EXP(x) is the same as exp(x).
  1713.  
  1714.  
  1715.         3.3.6.3  Numeric Switch
  1716.         Example.
  1717. IN:  1/2
  1718. OUT: 1/2
  1719. IN:  numeric:=on
  1720. IN:  1/2
  1721. OUT: 0.5
  1722.  
  1723.         3.3.6.4 Expand Switch
  1724.     Example.
  1725. IN:  a*(b+c)
  1726. OUT: a (b + c)
  1727. IN:  expand:=on
  1728. IN:  a*(b+c)
  1729. OUT: a b + a c
  1730.  
  1731.         3.3.6.5 ExpandExp Switch
  1732.         Example.
  1733. IN:  exp(a+b)
  1734. OUT: e^(a + b)
  1735. IN:  expandexp:=on
  1736. IN:  exp(a+b)
  1737. OUT: e^a e^b
  1738.  
  1739.  
  1740.         3.3.7  Read and Write Statements
  1741.     The format of the readfile statement is
  1742.         readfile("filename")
  1743. The filename is any MS-DOS file anme. It seems to copy the file into the 
  1744. user program.
  1745. e.g. to read a file named "inte.sm":
  1746.         readfile("inte.sm")
  1747.     The file to be read must be in the current directory.
  1748.     After a file is read, you can call any part of this 
  1749. package from a second package, as it seems the part of the first 
  1750. program has already been in the second program. you can read 
  1751. many files into the SymbMath program at a time. However, all names 
  1752. of the variables are public and name conflicts must be avoided.
  1753.     Write a file to disk by
  1754.         openfile("file")
  1755.         ...
  1756.         closefile("file")
  1757.         
  1758.     Table 3.3.7.         Reading and Writing Statements
  1759. ---------------------------------------------------------------------
  1760. readchar                read a charactor from  keyboard.
  1761. readline                read a line of strings from keyboard.                                                
  1762. readfile("file")        read (run or include) the file named "file".
  1763. ......................................................................
  1764. openfile("file")        open the disk file "file" for writing.
  1765. closedfile("file")      closed the file "file".
  1766. writes(s)               write s on screen, only on graphics mode.
  1767. newline                 write next text on a new line.
  1768. null                    not write.
  1769. block(a,b)              write the value of the last arguement, b.
  1770. ---------------------------------------------------------------------
  1771. where the filename is any MS-DOS filename.
  1772.     Note that the file must be closed by the closefile() command when
  1773. writing a file with the openfile() command, but the file is automatically
  1774. closed after reading the file. There must be the end statement at the end
  1775. of file for reading.
  1776.     SymbMath can read expressions from a disk file, then manipulate 
  1777. the expression, and finally write the result into another disk file.
  1778.     Example: an expression y:=x^6 is already in the file "y.in",
  1779.  
  1780. The contents of the file "y.in":
  1781. ---------------------------------------------------------------------
  1782. y:=x^6
  1783. -----------------------------------------------------------------------
  1784.  
  1785.     run this SymbMath program
  1786. ----------------------------------------------------------------------------
  1787. readfile("y.in")        # read the expression y:=x^6 from the file "y.in"
  1788. openfile("y.out")       # open a disk file "y.out" for writing
  1789. d(y,x)                  # differentiate y and write the result to the file
  1790. closefile("y.out")      # close the file and return output to SymbMath
  1791. ----------------------------------------------------------------------------
  1792.  
  1793. The contents of the file "y.out":
  1794. ---------------------------------------------------------------------
  1795. 6*x^5
  1796. ---------------------------------------------------------------------
  1797.  
  1798. In this way you can interface to other software (see 3.7. Interface with
  1799. Other Software).
  1800.     These outputs in the disk file can be edited in the Edit window 
  1801. or the Aux Edit window. 
  1802.     It is recommended to use the BASIC output format by setting 
  1803. the switch output:=basic when you write the output into the disk file.
  1804. The default switch is output:=math.
  1805.  
  1806.         3.3.8  DOS Command 
  1807.         You can executes a DOS command in SymbMath language by
  1808.                 system("dir")
  1809.  
  1810.  
  1811.         3.3.9  Sequence Statements
  1812.     The all above statements are simple statements. The sequence
  1813. statement specifies that its component statements are to be executed
  1814. in the same sequence as they are written. They are separated by the
  1815. separators (comma ","). e.g.
  1816.         a+b, 2+3
  1817.  
  1818.  
  1819.         3.4.  Libraries and Packages
  1820.     A library is a file of an external function, which filename is its
  1821. function name within 8 letters plus extension .(x). e.g. the library named
  1822. sin.(x) is a file of the sin(x) function definition.
  1823.     You can protect a library (e.g. sin.(x)) for write-protect by 
  1824. the DOS command:
  1825.         attrib +r sin.(x)
  1826. or for hidden-protect by the DOS command: 
  1827.         attrib +h sin.(x)
  1828.     You can remove the write-protect of a library by the DOS command:
  1829.         attrib -r sin.(x)
  1830. or remove the hidden-protect by the DOS command: 
  1831.         attrib -h sin.(x)
  1832.     The library (*.(x) file) is similar to the MS-DOS .bat file. You
  1833. need not to load or read the library by any command. SymbMath automatically
  1834. load the library when it is needed. For example, when you use the sin(x)
  1835. function first time, the library sin.(x) will be autoloaded. The library
  1836. must be in the default directory, otherwise the library is not loaded and
  1837. the function is not working. Only the assignments in the library can be
  1838. loaded, and others in the library will be omitted, but all of these
  1839. assignments will be not evaluated when they are loaded. You can clear the
  1840. library sin.(x) from memory by clear(sin(x)).
  1841.     You can have libraries (external functions) as many as your disk
  1842. space available. You should use the "one function per file" convenience.
  1843.         Note that all names of the variables in libraries and packages
  1844. are public (global) except for those declared by local() and name
  1845. conflicts must be avoided.
  1846.  
  1847.     A package is the SymbMath program file which filename has not 
  1848. extension .(x). It is recommanded that its filename has the extension .sm.
  1849.         A package is similiar to a libarary, but the package must be read
  1850. by a command
  1851.         readfile("filename")
  1852.     The filename can be any MS-DOS filename. It is recommended that
  1853. the filename is same function name used in your program, plus the
  1854. extension .sm. e.g. inte.sm is the filename of the integral package as
  1855. the name of integral function is inte().
  1856.     After reading the package, you can call the commands in the
  1857. package from your program.
  1858.     The readfile() command must be in a single line anywhere.
  1859.     Many packages can be read at a time.
  1860.     Alternately, a part of the package file rather than the whole
  1861. package file can be copied into the Input window by pressing <F7> 
  1862. (external copy) in order to save memory space.
  1863.     You can convert a package of f.sm into a library by renaming f.sm
  1864. to f.(x) for auto loading, or a library f.(x) to a package by renaming
  1865. f.(x) to f.sm for not auto loading.
  1866.     There are many libraries and packages. The following are some 
  1867. of them.
  1868.  
  1869.         Table 3.4.1      Libraries and Packages
  1870. ------------------------------------------------------------------------
  1871. File Name               Package Function
  1872.  
  1873. plot.(x)                plotting functions.
  1874. d.(x)                   derivatives.
  1875. inte.(x)                integrals.
  1876. sin.(x)                 sin(x) function.
  1877. cos.(x)                 cos(x) function.
  1878. fac.(x)                 n!.
  1879. sign.(x)                sign(x) function.
  1880. abs.(x)                 abs(x) function.
  1881. arg.(x)                 arg(x) function.
  1882. sum.(x)                 sum function.
  1883. NInte.(x)               numeric integration.
  1884. NSolve.(x)              numeric solver of equation.
  1885. DSolve.(x)              differential equation solver.
  1886. gamma.(x)               gamma function.
  1887. ei.(x)                  exponential integral function.
  1888. series.(x)              Taylor series.
  1889. partSum.(x)             partial sum.
  1890. infSum.(x)              infinite sum.
  1891. sinh.(x)                sinh(x) function.
  1892. cosh.(x)                cosh(x) function.
  1893. average.(x)             average([x]) function.
  1894. listSum.(x)             sum of list of data.
  1895. react.(x)               chemical reactions database.
  1896. phoneNo.(x)             phone No. database.
  1897. .......................................................................
  1898. init.sm                 initial package when running the program in 
  1899.             the Input window. It contains switches on the 
  1900.             default status.
  1901.  
  1902. chemical.sm             the atomic weight of chemical elements.
  1903. tExpand.sm              expansion of trig functions.
  1904. expandLn.sm             expand ln(x*y).
  1905. ExpandGa.sm             expand gamma(n,x).
  1906. ExpandEi.sm             expand ei(n,x).
  1907. units.sm                an units conversion.
  1908. listPlot.sm             plotting a list of data.
  1909. plotData.sm             intefacing software PlotData.
  1910. -----------------------------------------------------------------------
  1911.     
  1912.         You can get help for all libraries by the library Index command 
  1913. in the Help menu. You first open the library index window by this command,
  1914. then open a library by selecting its library name in the library index
  1915. window.
  1916.  
  1917.         3.4.1  Initial Package
  1918.  
  1919.     When a program is run in the Input window, SymbMath first
  1920. automatically reads (or runs) the initial package "init.sm". 
  1921. The commands in the "init.sm" package seems to be the SymbMath system 
  1922. commands. You can read other packages (e.g. f.sm) in the initial 
  1923. package "init.sm", so the commands in the package "f.sm" seems 
  1924. to be in SymbMath system. You do this by adding the readfile("f.sm")
  1925. into the init.sm file:
  1926.         readfile("f.sm")
  1927.         
  1928.         3.4.2  ExpandLn Package
  1929.     The lnexpand.sm package does the logarithmic expansion.
  1930. e.g. ln(a*b) is expanded into ln(a)+ln(b).
  1931.             
  1932.         3.4.3  Chemical Calculation Package
  1933.     SymbMath recognizes 100 symbols of chemical elements and 
  1934. converts them into their atomic weights after the chemical package of
  1935. "Chemical.sm" is read.
  1936.  
  1937.     Example 3.4.3.1. 
  1938. Calculate the weight percentage of the element C in the molecule CH4.
  1939.  
  1940. IN:  readfile("chemical.sm")
  1941. IN:  numeric:=on
  1942. IN:  C/(C+H*4)*100*%
  1943. OUT: 74.868 %
  1944.  
  1945.     Example 3.4.3.2. 
  1946. Calculate the molar concentration of CuO when 3 gram of CuO is in 0.5 
  1947. litre of a solution.
  1948.  
  1949. IN:  readfile("chemical.sm")
  1950. IN:  numeric:=on
  1951. IN:  g:=1/(Cu+O)*mol
  1952. IN:  3*g/(0.5*l)
  1953. OUT: 0.07543 mol/l
  1954.  
  1955.  
  1956.         3.5.  Interface with Other Software
  1957.     Interface with other software, (e.g. CurFit, Lotus 123) is 
  1958. similar to interface with the software PlotData in the plotdata package
  1959. "plotdata.sm".
  1960.     After load "plotdata.sm", the functions
  1961.         plotdata(y, x)
  1962.         plotdata(y, x from xmin to xmax)
  1963.         plotdata(y, x from xmin to xmax step dx)
  1964. plot a function of y by mean of the software PlotData. The plotdata() 
  1965. first opens a file "SymbMath.Out" for writing, then write the data table 
  1966. of the y function into the file "SymbMath.out", then close the file, and 
  1967. finally call the software PlotData to plot. These are done automatically 
  1968. by plotdata(). After it exits from PlotData, it automatically return to 
  1969. SymbMath.
  1970.     When SymbMath is interfaced with the software PlotData, SymbMath 
  1971. produces the data table of functions, and PlotData plots from the 
  1972. table. So SymbMath seems to plot the function. This interface can be 
  1973. used to solve equations graphically.
  1974.     
  1975.     Example 3.5.1.
  1976. plot x^2 by interfacing software PlotData.
  1977.  
  1978. IN:  readfile("plotdata.sm")
  1979. IN:  plotdata(x^2, x)
  1980.  
  1981. in the software PlotData, you just select the option to read the file 
  1982. "SymbMath.out" and to plot. PlotData reads the data in the SymbMath 
  1983. format without any modification (and in many data format). 
  1984.     In PlotData, 
  1985. in the main menu:
  1986. 1 <Enter>
  1987. in the read menu:
  1988. 2 <Enter>
  1989. <Enter>
  1990. in the main menu:
  1991. 2 <Enter>
  1992. in the graph menu:
  1993. 1 <Enter>
  1994.  
  1995. where <Enter> is the <Enter> key. Refer to PlotData for detail.
  1996.     Note that if your monitor is Hercules, you must load the 
  1997. MSHERC.COM program as a TRS program before you run PlotData. 
  1998. Otherwise you will get Error when you plot.
  1999.  
  2000.  
  2001.             4. Examples
  2002.  
  2003.     In the following examples, a line of "IN: " means input, which 
  2004. you type in the Input window, then leave the Input window by pressing 
  2005. <Esc>, finally run the program by the command "Run"; while a line of 
  2006. "OUT: " means output. You will see both input and output are displayed 
  2007. on two lines with beginning of "IN: " and "OUT: " in the Output window.
  2008. You should not type the word "IN: ". Some outputs may be omitted on the
  2009. examples. # is a comment statement. 
  2010.     You can split a line of command into multi-lines of command by
  2011. the comma ,. The comma without any blank space must be the last character
  2012. in the line.
  2013.     Note that you should not be suprised if some functions in the 
  2014. following examples are not working when their libraries are not in the 
  2015. default directory or missing.
  2016.  
  2017.             4.1 Calculation
  2018.  
  2019.     SymbMath gives the exact value of calculation when the switch
  2020. numeric := off (default), or the approximate value of numeric
  2021. calculation when the switch numeric := on or by num().
  2022.     Mathematical functions are usually not evaluated until by
  2023. num() or by setting numeric := on.
  2024.     SymbMath can manipulate units as well as numbers, be used as 
  2025. a symbolic calculator, and do exact computation. The range of real 
  2026. numbers is from -infinity to +infinity, e.g. ln(-inf), exp(inf+pi*i), 
  2027. etc. SymbMath contains many algorithms for performing numeric
  2028. calculations. e.g. ln(-9), i^i, (-2.3)^(-3.2), 2^3^4^5^6^7^8^9, etc.
  2029.     Note that SymbMath only gives a principle value if there
  2030. are multi-values, except for the solve() and root().
  2031.     
  2032.     Example 4.1.1.
  2033. exact and numeric calculations of 1/2 + 1/3.
  2034.  
  2035. IN:  1/2+1/3         # exact calculation
  2036. OUT: 5/6
  2037. IN:  num(1/2+1/3)    # numeric calculation
  2038. OUT: 0.8333333333
  2039.  
  2040.     Evaluate the value of the function f(x) at x=x0 by f(x0).
  2041.     Example 4.1.2. 
  2042. evaluate sin(x) when x=pi, x=180 degree, x=i.
  2043.  
  2044. IN:  sin(pi), sin(180*degree)
  2045. OUT: 0, 0
  2046. IN:  sin(i), num(sin(i))
  2047. OUT: sin(i), 1.175201 i
  2048.  
  2049.     Example 4.1.3. 
  2050. Set the units converter from the minute to the second, then calculate 
  2051. numbers with different units.
  2052.  
  2053. IN:  minute:=60*second
  2054. IN:  v:=2*meter/second
  2055. IN:  t:=2*minute
  2056. IN:  d0:=10*meter
  2057. IN:  v*t+d0
  2058. OUT: 250 meter
  2059.  
  2060.     Evaluate the expression value by
  2061.         subs(y, x = x0)
  2062.     Example 4.1.4. 
  2063. evaluate z=x^2 when x=3 and y=4.
  2064.  
  2065. IN:  z:=x^2                   # assign x^2 to z
  2066. IN:  subs(z, x = 3)           # evaluate z when x = 3
  2067. OUT: 9
  2068. IN:  x:=4                     # assign 4 to x
  2069. IN:  z                        # evaluate z 
  2070. OUT: 16
  2071.  
  2072.     Note that after assignment of x by x:=4, x should be cleared from
  2073. assignment by clear(x) before differentiation (or integration) of the 
  2074. function of x. Otherwise the x values still is 4 until new values 
  2075. assigned. If evaluating z by the subs(), the variable x is
  2076. automatically cleared after evaluation, i.e. the variable x in subs()
  2077. is local variable. The operation by assignment is global while the
  2078. operation by internal function is local, but operation by external function
  2079. is global. This rule also applies to other operations. 
  2080.     The complex numbers, complex infinity, and most math functions 
  2081. with the complex arguement can be calculated.
  2082.  
  2083.     Example 4.1.5.
  2084. IN:  sign(1+i), sign(-1-i), i^2
  2085. OUT: 1, -1, -1
  2086.  
  2087.     Example 4.1.6.
  2088. IN:  exp(inf+pi*i)
  2089. OUT: -inf
  2090. IN:  ln(last)
  2091. OUT: inf + pi*i
  2092.  
  2093.     The built-in constants of inf or -inf, zero or -zero, and 
  2094. discont or undefined can be used as numbers in calculation of 
  2095. expressions or functions.
  2096.                 
  2097.                 4.1.1   Discontinuity and one-sided value
  2098.         Some math functions are discontinuous at x=x0, and only have
  2099. one-sided function value. If the function f(x0) gives the discont as its
  2100. function value, you can get its one-sided function value by f(x0-zero)
  2101. or f(x0+zero).
  2102.  
  2103.     Example 4.1.7.
  2104. IN:  f(x_) := exp(1/x)      # define function f(x)
  2105. IN:  f(0)                   
  2106. OUT: discont                # discontinuity at x=0
  2107. IN:  f(0-zero)              # left-sided value at x=0-
  2108. OUT: 0                      
  2109. IN:  f(0+zero)              # right-sided value at x=0+
  2110. OUT: inf                    
  2111.  
  2112.                 4.1.2  Undefined and indeterminate form
  2113.         If the function value is undefined, it may be indetermate form
  2114. (e.g. 0/0, inf/inf), you can evaluate it by lim() (see Chapter 4.4 Limits).
  2115.  
  2116.  
  2117.                 4.2 Simplification
  2118.     SymbMath automatically simplifies the output expression. 
  2119. You can further simplify it by using the built-in variable last 
  2120. in a single line again and again until you are happy with the answer.
  2121.         Expressions can be expanded by
  2122.         expand(x)
  2123.         expand := on
  2124.         expandexp := on
  2125. Remember that the operation by assignment is global while operation by
  2126. function is local. So expand(x) only expands the expression x, but the
  2127. switch expand := on expands all expressions between the switch expand :=
  2128. on and the switch expand := off. Second difference betwen them is that
  2129. the switch expand := on only expands a*(b+c) and (b+c)/p, but does not
  2130. expands the power (a+b)^2. The expandexp is exp expand.
  2131.  
  2132.         Example:
  2133. IN:  expand((a+b)^2+(b+c)*p)
  2134. OUT: a^2 + 2 a b + b^2 + b p + c p
  2135. IN:  expand := on
  2136. IN:  (a+b)^2 + (b+c)*p
  2137. OUT: (a+b)^2 + b p + c p
  2138.  
  2139. ---------------------------------------------------------------------
  2140. ...............    expand(x) ..........................................
  2141. (a+b)^2       to          a^2+2*a*b+b^2
  2142. (a+b)^n       to          a^n+ ...... +b^n        n is positive integer
  2143. ............... expand(x) and expand := on ..........................
  2144. a*(b+c)       to          a*b + a*c
  2145. (b+c)/p       to          b/p + c/p
  2146. ............... expandexp := on .....................................
  2147. e^(a+b)          to      e^a *    e^b    
  2148. ---------------------------------------------------------------------
  2149. where a+b can be many terms or a-b.
  2150.  
  2151.         Expressions can be factorized by
  2152.         factor(x)
  2153.         e.g.
  2154. IN:  factor(a^2 + 2*a*b + b^2)
  2155. OUT: (a + b)^2
  2156.  
  2157.         Polynomials of order less than 5 can be factorized by
  2158.                 factor(y, x)
  2159.         Example.
  2160. IN:  factor(x^2+5*x+6, x)
  2161. OUT: (2 + x) (3 + x)
  2162.         Note that Shareware version of SymbMath cannot do this factor as
  2163. it lacks solve().
  2164.  
  2165.     Example 4.2.1. 
  2166.         Reduce sqrt(x^2).
  2167.  
  2168. IN:  sqrt(x^2)
  2169. OUT: x*sign(x)
  2170.  
  2171.     This output can be further simplified if you know proporties of x.
  2172.     A first way is to evaluate x*sign(x) when sign(x) = 1 if x is
  2173. positive.
  2174.  
  2175. IN:  sqrt(x^2)
  2176. OUT: x*sign(x)
  2177. IN:  subs(last, sign(x) = 1)
  2178. OUT: x
  2179.  
  2180. where a special keyword last stands for the last output, e.g. here last
  2181. is x*sign(x).
  2182.  
  2183.                    4.2.1 Assuming domain
  2184.     A second way is to assume x>0 before evaluation. If you assume
  2185. the variable x is positive or negative, the output expression is simpler 
  2186. than that if you do not declare it.
  2187.  
  2188. IN:  assume(x > 0, y <0)             # assume x > 0, y < 0
  2189. OUT: assumed
  2190. IN:  sqrt(x^2), sqrt(y^2), sqrt(z^2)
  2191. OUT: x*sign(x), y*sign(y), z*sign(z)
  2192. IN:  last                            # simplify last output
  2193. OUT: x, -y, z*sign(z)
  2194.  
  2195.     In this way, all of x is affected until the assume() is cleared by 
  2196. clear(). The first method is local simplification, but the second method 
  2197. is global simplification. 
  2198.         By default, |x| < inf and all variables are complex, except that
  2199. variables in inequalities are real, as usual only real numbers can be
  2200. compared. e.g. x is complex in sin(x), but y is real in y > 1.
  2201.     You can restrict the domain of a variable by assuming the variable
  2202. is even, odd, integer, real number, positive or negative.
  2203.     Example 4.2.3.
  2204.  
  2205. IN:  isreal(b) := 1          # assume b is real
  2206. IN:  sqrt(b^2)
  2207. OUT: abs(b)
  2208.     
  2209.     Table 4.2       Assuming
  2210. ---------------------------------------------------------------------
  2211. Assume          Assignment              Meaning                
  2212.  
  2213. assume(x>y)     x>y := 1                # assume x > y
  2214. assume(x>=y)    x>=y := 1               # assume x >= y
  2215. assume(x<y)     x<y := 1                # assume x < y
  2216. assume(x<=y)    x<=y := 1               # assume x <= y
  2217. assume(x==y)    x==y := 1               # assume x == y
  2218. assume(x<>y)    x<>y := 1               # assume x <> y
  2219.         iseven(b) := 1          # assume b is even
  2220.         isodd(b) := 1           # assume b is odd
  2221.         isinteger(b) := 1       # assume b is integer
  2222.         isratio(b) := 1         # assume b is ratio
  2223.         isreal(b) := 1          # assume b is real
  2224.         iscomplex(b) := 1       # assume b is complex
  2225.         isnumber(b) := 1        # assume b is number
  2226.         islist(b) := 1          # assume b is a list
  2227.         isfree(y,x) := 1        # assume y is free of x
  2228.         issame(a,b) := 1        # assume a is same as b
  2229.         sign(b) := 1            # assume b is positive complex
  2230.         sign(b) := -1           # assume b is negative complex
  2231. ------------------------------------------------------------------------
  2232.  
  2233.     The assume() can be cleared by clear(). e.g. clear(x>y).
  2234.  
  2235.                    Simplification in different domains
  2236. ---------------------------------------------------------------------
  2237. exprsseion         complex               real             x > 0
  2238.  
  2239. sqrt(x^2)          x sign(x)             |x|              x
  2240. x*sign(x)          x sign(x)             |x|              x
  2241. |x|*sign(x)        |x| sign(x)           x                x
  2242. |x|/x              |x|/x                 1/sign(x)        1
  2243. x+inf              x+inf                 inf
  2244. x-inf              x-inf                 -inf
  2245. abs'(x)            |x|/x                 1/sign(x)        1
  2246. ----------------------------------------------------------------------
  2247.  
  2248.                    4.2.2 Comparising and testing numbers
  2249.     You can compare two numbers by relational operators
  2250.                 a > b
  2251.                 a < b
  2252.                 a <= b
  2253.                 a >= b
  2254.                 a <> b
  2255.                 a == b
  2256.  
  2257.     Example 4.2.5.
  2258. IN:  2 > 1, 2 < 1
  2259. OUT: 1, 0
  2260.  
  2261.         You also can compare two numbers, even complex numbers z1 and z2 by
  2262.                 islarger(z1, z2)
  2263.                 isless(z1, z2)
  2264.                 issame(z1, z2)
  2265.  
  2266.         Example 4.2.6.
  2267.         compare 1+i and 1-i.
  2268. IN:  islarger(1+i, 1-i)         # is 1+i larger than 1-i ?
  2269. OUT: 1                          # yes, 1+i > 1-i
  2270.  
  2271.         You can compare squre of a variable a^2 > 0 if you know the
  2272. property of the variable.
  2273.         Example 4.2.7.     
  2274. IN:  assume(a > 0)
  2275. IN:  a^2 > 0, 1/a > 0
  2276. OUT: 1, 1
  2277.  
  2278.         You can test if x is even, odd, integer, real, number or list by
  2279. the is* functions:
  2280.                     iseven(x)
  2281.                     isodd(x)
  2282.                     isinteger(x)
  2283.                     isreal(x)
  2284.                     isnumber(x)
  2285.                     islist(x)
  2286.                     isfree(y,x)
  2287.                     islarger(a,b)
  2288.                     isless(a,b)
  2289.                     issame(a,b)
  2290.  
  2291.         Example:
  2292. IN:  iseven(2)          # is 2 even ?
  2293. OUT: 1                  # yes
  2294.  
  2295.         Note that comparison by the is* functions return either 1 if it is
  2296. true or 0 otherwise, but comparison by relational operators gives 1 if it
  2297. is true, 0 if it is fault, or left unevaluated otherwise.
  2298.  
  2299.           
  2300.     4.3      Defining Your Own Functions, Procedures and Rules
  2301.     4.3.1    Defining Your Own Functions
  2302.  
  2303.     Anytime when you find yourself using the same expression over  
  2304. and over, you should turn it into a function.  
  2305.     You can define your own functions by
  2306.            f(x_) := x^2
  2307.     Here are some sample function definitions:
  2308.            f(x_) := cos(x + pi/3)
  2309.            g(x_, y_) := x^2 - y^2
  2310.     The arguement in the definition should be the pattern x_. 
  2311. Otherwise f() works only for a specific symbolic value, e.g. x when 
  2312. defining f(x):=x^2. The pattern x_ should be only on the left side of
  2313. the assignment.
  2314.        Once defined, functions can be used in expressions or in other 
  2315. function definitions:
  2316.            y := f(3.2)
  2317.            z := g(4.1, -5.3)
  2318.  
  2319.     Example 4.3.1.
  2320. Define a new function for x^2, then evaluate it.
  2321.     
  2322. IN:  g(x) := x^2
  2323. IN:  g(2), g(a),  g(x)
  2324. OUT: g(2), g(a),  x^2         # work only for a symbolic value x
  2325. IN:  f(x_) := x^2
  2326. IN:  f(2), f(a)
  2327. OUT: 4, a^2                   # work for any value
  2328.  
  2329.                 4.3.1.1  Defining Conditional Functions
  2330.     You can define a conditional function by the if() function:
  2331.         f(x_) := if(x>0 then  1)
  2332.         f(x_) := if(x>0 then x^2 else x)
  2333. or by inequalities:
  2334.                 f(x_) := x>0
  2335.         f(x_) := (x>0) * x^2 + (x<=0) * x
  2336. On the first definition by if(), when f() is called it gives 1 if x>0,  
  2337. or left unevaluated otherwise. On the second definition by the if(), when
  2338. f() is called it gives x^2 if x>0, x if x<=0, or left unevaluated
  2339. otherwise. On the third definision by the inequality, when f() is called,
  2340. it gives 1 for x>0, 0 for x<=0, or x>0 for symbolic value of x.
  2341. On the last definition, when f() is called, it is evaluated for any
  2342. numeric or symbolic value of x.
  2343.     Remember that the words "then" and "else" can be replaced by 
  2344. comma ,.
  2345.     You cannot differentiate nor integrate the conditional function
  2346. defined by if(), but you can do the conditional functions defined by
  2347. inequalities.
  2348.  
  2349.         You can define a function evaluated only for numbers by
  2350.         f(x_) := if(isnumber(x) then x^2)
  2351. This definition is different from the definition by f(x_) := x^2. On the
  2352. latter, when f() is called, it gives x^2, regardless whatever x is. On the
  2353. former, when f() is called, it gives x^2 if x is a number, or left
  2354. unevaluated otherwise.
  2355.     
  2356.     Example 4.3.2.
  2357. evaluate to x^2 only if x is number, by defining a conditional function.
  2358.  
  2359. IN:  f(x_) := if(isnumber(x) then x^2)
  2360. IN:  f(2), f(a)
  2361. OUT: 4, f(a)
  2362.  
  2363. IN:  f(x_) := if(x>0 then x^2)
  2364. IN:  f(2), f(-2), f(a)
  2365. OUT: 4, f(-2), f(a)
  2366.  
  2367. IN:  f(x_) := if(x>0 then x^2 else x)
  2368. IN:  f(2), f(-2), f(a)
  2369. OUT: 4, 2, f(a)
  2370.  
  2371.            4.3.1.2  Defining Case Functions
  2372.     You can define the case function by different pattern name. The
  2373. case function is similar to the case statement in BASIC language.
  2374.     Example:
  2375.  
  2376. IN:  f(x_) := if( x > 0 and x < 1 then 1)
  2377. IN:  f(u_) := if( u > 1 and u < 2 then 2)
  2378. IN:  f(v_) := if( v > 2 and v < 3 then 3)
  2379. IN:  f(0.2), f(1.2), f(2.2)
  2380. OUT: 1, 2, 3
  2381.  
  2382.            4.3.1.3  Defining Piece-wise Functions
  2383.         You can define a piece-wise function.
  2384.     Example 4.3.3. 
  2385.         define
  2386.  
  2387.       / x       if x < 0
  2388. f(x) =  0       if x = 0
  2389.       \ x^2     if x > 0
  2390.  
  2391. then evaluate f(-2), f(0), f(3), f(a), f'(x), diff(f(x), x=3).
  2392.  
  2393. IN:  f(x_) := x*(x<0)+x^2*(x>0)
  2394. IN:  f(-2), f(0), f(3), f(a)
  2395. OUT: -2, 0, 9, (a < 0) a + (a > 0) a^2
  2396. IN:  f'(x)
  2397. OUT: (x < 0) + 2 x (x > 0)
  2398. IN:  diff(f(x), x=3)
  2399. OUT: 6
  2400.  
  2401.                 4.3.1.4  Defining Recursion Functions
  2402.         You can define a recursion function.
  2403.         Example.
  2404. IN:  factoria(n_) := if(n > 1, (n-1)*factoria(n-1))
  2405. IN:  factoria(1) := 1
  2406.  
  2407.                  4.3.1.5  Defining Multi-Value Functions
  2408.         You can define a function with the multi function values.
  2409.         Example.
  2410. IN:  squreroot(x_) := [sqrt(x), -sqrt(x)]
  2411. IN:  squreroot(4)
  2412. OUT: [2, -2]
  2413.  
  2414.     Anytime when you find yourself using the same definition over  
  2415. and over, you should turn it into a library.  
  2416.     You can make your defined function as if the built-in function,
  2417. by saving your definition into disk file as a library with the function
  2418. name plus extension .(x) as the filename. e.g. saving above factoria
  2419. function as the factoria.(x) file (see Section 3.6 Libraies and Packages).
  2420.  
  2421.         4.5.2  Defining Your Own Procedures
  2422.     You can define a function as a procedure by
  2423.                 f(x_) := block(command1, command2, ..., commadN)
  2424.                 f(x_) := block(command1, command2, ..., commandN, local(a))
  2425.  
  2426.     By default, all variables within procedure are global, except for
  2427. variables declared by local(). The mult-statement should be grouped by
  2428. block(). The block() only outputs the result of the last statement or the
  2429. second last one as its value. The mult-line can be teminated by a comma,
  2430. (not by a comma and a blank space). Local() must be the last one in
  2431. block().
  2432.  
  2433.     Example 4.5.2. 
  2434. define a numeric integration procedure ninte() and calculate integral
  2435. of x^2 from x=1 to x=2 by call ninte().
  2436.  
  2437. IN:  ninte(y_,x_,a_,b_) := block( numeric:=on,
  2438.         dd:=(b-a)/50,
  2439.     aa:=a+dd,
  2440.     bb:=b-dd,
  2441.     y0:=subs(y, x = a),
  2442.     yn:=subs(y, x = b),
  2443.     (sum(y,x,aa,bb,dd)+(y0+yn)/2)*dd,
  2444.         local(dd,aa,bb,y0,yn) )
  2445. IN:  ninte(x^2, x from 1 to 2)
  2446.  
  2447.  
  2448.         4.5.3  Defining Your Own Rules
  2449.     You can define transform rules. Defining rules is similar to 
  2450. defining functions. In defining functions, all arguments must be simple
  2451. variables, but in defining rules, the first argument can be a
  2452. complicated expression.
  2453.     
  2454.        Example 4.5.3.1 
  2455.        define log rules.
  2456. IN:  log(x_ * y_) := log(x) + log(y)
  2457. IN:  log(x_ ^ n_) := n*log(x)
  2458. IN:  log(a*b)
  2459. OUT: log(a) + log(b)
  2460.  
  2461.         Example 4.5.3.2
  2462. IN:  sin(-x_) := -sin(x)
  2463. IN:  sin(-a)
  2464. OUT: -sin(a)
  2465.  
  2466.         Example 4.5.3.3
  2467.         define the trig simplification rules.
  2468. IN:  simplify(sin(x_)^2, x_) := 1/2*(1-cos(x))
  2469. IN:  simplify(sin(x)^2,x)
  2470. OUT: 1/2 (1 - cos(x))
  2471.  
  2472.     Example 4.5.3.4 
  2473.         define Laplace transform rules.
  2474. IN:  laplace(sin(t_), t_) := 1/(t^2+1)
  2475. IN:  laplace(sin(s), s)
  2476. OUT: 1/(s^2 + 1)
  2477.  
  2478.  
  2479.             4.4    Limits  
  2480.                         4.4.1  One-sided Limits
  2481.     You can finds real or complex limits, and discontinuity or
  2482. one-sided value.
  2483.     First find the expression value by subs(y, x = x0) or the
  2484. function value by f(x0) when x = x0.
  2485.         If the result is the discont (i.e. discontinuity), then use the
  2486. one-sided value x0+zero or x0-zero to try to find the one-sided function
  2487. or expression value.
  2488.     For a function f(x), you can evaluate the left- or right-sided 
  2489. function value, similar you evaluate the normal function value:       
  2490.         f(x0-zero)
  2491.         f(x0+zero)
  2492.     For an expression y, you can evaluate its one-sided expression 
  2493. value by
  2494.         subs(y, x = x0-zero)
  2495.         subs(y, x = x0+zero)
  2496.     The discont (discontinuity) means that the expression has
  2497. a discontinuity and only has the one-sided value at x=x0. You should 
  2498. use x0+zero or x0-zero to find the one-sided value. The value of 
  2499. f(x0+zero) or f(x0-zero) is the right-sided or left-sided function value
  2500. as approaching x0 from positive (+inf) or negative (-inf) direction, 
  2501. respectively, i.e. as x = x0+ or x = x0-.
  2502.         If the result is undefined (indeterminate forms, e.g. 0/0,
  2503. inf/inf, 0*inf, and 0^0), then find its limit by 
  2504.         lim(y, x = x0)
  2505.         If the limit is discont, then you can find a left-
  2506. or right-sided limit when x approaches to x0 from positive (+inf) 
  2507. or negative (-inf) direction at discontinuity by 
  2508.  
  2509.         lim(y, x = x0+zero)
  2510.         lim(y, x = x0-zero)
  2511.  
  2512.     Example 4.4.2. 
  2513.         Evaluate y=exp(1/x) at x=0, if the result is discontinuty, find
  2514. its left-sided and right-sided values (i.e. when x approaches 0 from
  2515. positive and negative directions).
  2516.  
  2517. IN:  y:=exp(1/x)
  2518. IN:  subs(y, x = 0)
  2519. OUT: discont               # discontinuty at x=0
  2520. IN:  subs(y, x = 0+zero), subs(y, x = 0-zero)
  2521. OUT: inf, 0
  2522.  
  2523.       Example 4.4.3:
  2524. How to handle the following one-sided values ?
  2525.  
  2526. Let f(x) = 1 when x < 1, f(x) = 1 when x > 1 (and not defined at x = 1).
  2527. Let g(x) = 1 when x < 1, g(x) = 1 when x > 1, and g(1) = 2.
  2528. Let h(x) = 1 when x < 1, h(x) = 2 when x >= 1.
  2529. Let k(x) = 1 when x < 1, k(x) = 2 when x > 1, and k(1) = 3.
  2530.  
  2531. Now ask SymbMath to compute 
  2532.  
  2533. (1) the limit as x approaches 1,
  2534. (2) the limit as x approaches 1 from the left, and
  2535. (3) the limit as x approaches 1 from the right
  2536.  
  2537. for each of the above piecewise defined functiuons.
  2538.  
  2539. # define functions
  2540. f(x_) :=  if(x<1 or x>1, 1)
  2541. f(1+zero):=1
  2542. f(1-zero):=1
  2543. g(x_) := if( x<1 or x>1, 1)
  2544. g(1):=2
  2545. g(1+zero):=1
  2546. g(1-zero):=1
  2547. h(x_) := if( x<1, 1, 2)
  2548. h(1+zero):=2
  2549. h(1-zero):=1
  2550. k(x_) := if( x<1, 1, if( x>1, 2))
  2551. k(1):=3
  2552. k(1+zero):=2
  2553. k(1-zero):=1
  2554. # evaluate functions
  2555. IN:  f(1), g(1), h(1), k(1)
  2556. OUT: f(1), 2, 2, 3
  2557. IN:  f(1+zero), g(1+zero), h(1+zero), k(1+zero)
  2558. # right-hand side value at x=1+
  2559. OUT: 1, 1, 1, 1
  2560. IN:  f(1-zero), g(1-zero), h(1-zero), k(1-zero)
  2561. # left-hand side value at x=1-
  2562. OUT: 1, 1, 2, 2
  2563.  
  2564.     Example 4.4.1. 
  2565. Find limits of types 0/0 and inf/inf.
  2566.  
  2567. IN:  p:=(x^2-4)/(2*x-4)
  2568. IN:  subs(p, x = 2)
  2569. OUT: undefined
  2570. IN:  lim(p, x = 2)
  2571. OUT: 2
  2572. IN:  subs(p, x = inf)
  2573. OUT: undefined
  2574. IN:  lim(p, x = inf)
  2575. OUT: inf
  2576.  
  2577.                         4.4.2  Numeric limits: NLim()
  2578.         If symbolic limit sometines fall, you should try numeric limit by
  2579.                         nlim(y, x=x0)
  2580.  
  2581.  
  2582.             4.5 Differentiation
  2583.  
  2584.     Differentiate an expression y with respest to x by  
  2585.         d(y, x)
  2586.         Differentiate a simple function f(x) by
  2587.                 f'(x)
  2588.     Differentiate y in order ( order > 0 ) by
  2589.         d(y, x, order)
  2590.     Differentiate y when x = x0 by
  2591.         diff(y, x = x0)
  2592.     Differentiate y when x = x0 in order (order > 0) by
  2593.         diff(y, x = x0, order)
  2594.             
  2595.     Example 4.5.1. 
  2596.         Differentiate sin(x) and x^(x^x).
  2597.  
  2598. IN:  sin'(x)    # sin'(x) is the same as d(sin(x), x).
  2599. OUT: cos(x)
  2600. IN:  d(x^(x^x), x)
  2601. OUT: x^(x^x) (x^(-1 + x) + x^x ln(x) (1 + ln(x)))
  2602.  
  2603. If you differentiate f(x) by f'(x), x must be a simple variable and f(x)
  2604. must be not evaluated.
  2605.         f'(x0) is different from diff(f(x), x=x0). f'(x0) first evaluates
  2606. f(x0), then differentiate the result of f(x0). But diff(f(x), x=x0) first
  2607. differentiate f(x), then replace x with x0.
  2608.         Note that sin'(x^6) gives cos(x^6) as sin'(x^6) is the same as
  2609. d(sin(x^6), x^6), and sin'(0) gives d(0,0) as sin(0) is evaluated to 0
  2610. before differentiation. diff(sin(x),x=0) gives 1.
  2611.  
  2612.     Example 4.5.2. 
  2613. Differentiate the expression f=sin(x^2+y^3)+cos(2*(x^2+y^3)) with respect 
  2614. to x, and with respect to both x and y.
  2615.  
  2616. IN:  f:=sin(x^2+y^3)+cos(2*(x^2+y^3))
  2617. IN:  d(f, x)
  2618. OUT: 2 x cos(x^2 + y^3) - 4 x sin(2 (x^2 + y^3))
  2619. IN:  d(d(f, x), y)           # mixed derivative with x and y.
  2620. OUT: -6 x y^2 sin(x^2 + y^3) - 12 x y^2 cos(2 (x^2 + y^3))
  2621.  
  2622.                 4.5.1  One-sided derivatives
  2623.     Differentiate y when x = x0-zero or 0+zero (the left- or right-
  2624. sided derivative) by
  2625.         diff(y, x = x0-zero)
  2626.         diff(y, x = x0+zero)
  2627.  
  2628.         Example.
  2629. IN:  diff(ln(x), x=0)
  2630. OUT: discont                     # discontinulity at x=0
  2631. IN:  diff(ln(x), x=0-zero)       # left-sided derivative at x=0-
  2632. OUT: -inf                        
  2633. IN:  diff(ln(x), x=0+zero)       # right-sied derivative at x=0+
  2634. OUT: inf
  2635.  
  2636.                4.5.2  Defining f'(x)
  2637.     Defining derivatives is similar to defining rules. You only need
  2638. to define derivatives of a simple function, as SymbMath automately apply
  2639. the chain rule to its complicated function.
  2640.     Example 4.5.2.2.
  2641. IN:  f'(x_) := sin(x)
  2642. IN:  f'(x)
  2643. OUT: sin(x)
  2644. IN:  f'(x^6)            # the same as d(f(x^6), x^6)
  2645. OUT: sin(x^6)
  2646. IN:  d(f(x^6), x)
  2647. OUT: 6 x^5 sin(x^6)
  2648.  
  2649.  
  2650.             4.6 Integration
  2651.  
  2652.     You can find integrals of x^m*e^(x^n), x^m*e^(-x^n),
  2653. e^((a*x+b)^n), e^(-(a*x+b)^n), x^m*ln(x)^n, ln(a*x+b)^n, etc., (where m
  2654. and n are any real number).        
  2655.     It is recommended that before you do symbolic integration, you
  2656. should simplify integrand, e.g. expand the integrand by expand() and/or
  2657. by setting the switch expand:=on and/or expandexp:=on.
  2658.     If symbolic integration fails, you can define a simple integral
  2659. and/or derivative, (or adding integral into the inte.(x) library),
  2660. then do integration again (see Chapter 4.14 Learning from User).
  2661.  
  2662.         4.6.1 Indefinite Integration
  2663.     Find the indefinite integrals of expr by
  2664.         inte(expr, x)
  2665.     Find the double indefinite integrals by
  2666.                 inte(inte(expr, x), y)
  2667. Note that the arbitrary constant is not represented.
  2668.  
  2669.     Example 4.6.1. 
  2670.         Find integrals of 1/a, 1/b and 1/x, knowing a >0, b is real.
  2671.  
  2672. IN:  assume(a>0), isreal(b):=1
  2673. IN:  inte(1/a, a), inte(1/b, b), inte(1/x, x)
  2674. OUT: ln(a), ln(|b|), ln(x*sign(x))
  2675.  
  2676.     Example 4.6.2. 
  2677.         Find indefinite integrals.
  2678.  
  2679. IN:  inte(sin(a*x+b), x)        # integrands involving sin(x)
  2680. OUT: -cos(b + a x)/a
  2681. IN:  inte( sin(x)/x^2, x)
  2682. OUT: ci(x) - sin(x)/x
  2683. IN:  inte( x*sin(x), x)
  2684. OUT: -x cos(x) + sin(x)
  2685. IN:  inte(sin(x)*cos(x), x)
  2686. OUT: (1/2)*sin(x)^2
  2687.  
  2688. IN:  inte( e^(x^6), x)              # integrands involving e^x
  2689. OUT: 1/6 ei(-5/6, x^6)
  2690. IN:  inte( x^2*e^x, x)
  2691. OUT: ei(2, x)
  2692. IN:  inte( x*e^(-x), x)
  2693. OUT: -e^(-x) - x e^(-x)
  2694. IN:  inte( e^x/sqrt(x), x)
  2695. OUT: ei(-0.5, x)
  2696. IN:  inte(x^1.5*exp(x), x)
  2697. OUT: ei(1.5, x)
  2698.  
  2699. IN:  inte(sin(x)*e^x, x)      # integrals involving sin(x) and e^x
  2700. OUT: 1/2 * (sin(x) - cos(x)) * e^x
  2701.  
  2702. IN:  inte( x*ln(x), x)             # integrands involving ln(x)
  2703. OUT: -1/4 x^2 + 1/2 x^2 ln(x)
  2704. IN:  inte( ln(x)^6, x)
  2705. OUT: li(6, x)
  2706. IN:  inte( ln(x)/(√x), x)
  2707. OUT: -4 √x + 2 √x ln(x)
  2708. IN:  inte( ln(x)/sqrt(1 + x), x)
  2709. OUT: -4 √(1 + x) + 2 √(1 + x) ln(x) - 2 ln((-1 + √(1 + x))/(1 + √(1 + x)))
  2710.  
  2711. IN:  inte( 1/(a x + b), x)        # integrands involving polynomials
  2712. OUT: ln((b + a x) sign(b + a x))/a
  2713. IN:  inte( x/(x^2 + 5 x + 6), x)
  2714. OUT: 1/2 ln(|6 + 5 x + x^2|) - 5/2 ln(|(2 + x)/(3 + x)|)
  2715. IN:  inte( (x^3 + x)/(x^4 + 2 x^2 + 1), x)
  2716. OUT: 1/4 ln((1 + 2 x^2 + x^4) sign(1 + 2 x^2 + x^4))
  2717.  
  2718.     Example 4.6.3. 
  2719.         Find the line integral.
  2720.  
  2721. IN:  x:=2*t
  2722. IN:  y:=3*t
  2723. IN:  z:=5*t
  2724. IN:  u:=x+y
  2725. IN:  v:=x-y
  2726. IN:  w:=x+y+z
  2727. IN:  inte(u*d(u,t)+v*d(v,t)+w*d(w,t), t)
  2728. OUT: 63 t^2
  2729.  
  2730.     Example 4.6.4. 
  2731.         Integrate x^2*e^x, then expand it by the mean of the
  2732. packages "ExpandEi.sm" (expand ei(n,x)).  The packages "ExpandGa.sm"
  2733. (expand gamma(n,x)) and "ExpandLi.sm" (expand li(n,x)) are similar one.
  2734.  
  2735. IN:  inte(x^2*e^x, x)
  2736. OUT: ei(2,x)                                 # ei()
  2737. IN:  readfile("ExpandEi.sm")
  2738. IN:  ei(2, x)
  2739. OUT: x^2 e^x - 2 x e^x + 2 e^x               # ei() is expanded
  2740.  
  2741.  
  2742.     Defining integrals is similar to defining rules.
  2743.     Example 4.6.5
  2744.  
  2745. IN:  inte(f(x_), x_) := sin(x)
  2746. IN:  inte(f(t), t)
  2747. OUT: sin(t)
  2748.  
  2749.         4.6.2 Definite Integration
  2750.     Find definite integrals by external functions 
  2751.         inte(expr, x from xmin to xmax)
  2752.         inte(expr, x from xmin to singularity to xmax)
  2753.        
  2754.        Example 4.6.6. 
  2755.        Find the definite integral of y=exp(1-x) with respect to x taken
  2756. from 0 to infinity.
  2757.  
  2758. IN:  inte(exp(1-x), x from 0 to inf)
  2759. OUT: e
  2760.  
  2761.     Example 4.6.7. 
  2762. do discontinuous integration of 1/x^2 and 1/x^3 with discontinuty at x=0.
  2763.  
  2764. IN:  inte(1/x^2, x from -1 to 2)             # singularity at x=0
  2765. OUT: inf
  2766. IN:  inte(1/x^3, x from -1 to 1)             # singularity at x=0
  2767. OUT: 0
  2768. IN:  inte(sqrt((x-1)^2), x from 0 to 2)      # singularity at x=1
  2769. OUT: 1
  2770.  
  2771.         SymbMath usually detect singularity, but sometime it cannot,
  2772. in this case you must provide singularity.
  2773.         Example:
  2774. IN:  inte(1/(x-1)^2, x from 0 to 1 to 2)     # provide singularity at x=1
  2775. OUT: inf
  2776.  
  2777.     Example 4.6.8
  2778.         do complex integration.
  2779.  
  2780. IN:  inte(1/x, x from i to 2*i)
  2781. OUT: ln(2)
  2782.  
  2783.         4.6.3  Numeric Integration: NInte()
  2784.     The external function
  2785.         ninte(y, x from xmin to xmax)
  2786. does numeric integration.
  2787.     
  2788.     Example 4.6.3.1. 
  2789.         Compare numeric and symbolic integrals of 4/(x^2+1) with
  2790. respect to x taken from 0 to 1.
  2791.  
  2792. IN:  ninte(4/(x^2+1), x from 0 to 1)
  2793. OUT: 3.1415
  2794. IN:  num(inte(4/(x^2+1), x from 0 to 1))
  2795. OUT: 3.1416
  2796.  
  2797.  
  2798.                 4.7    Solving Equations
  2799.         4.7.1  Solving Algebraic Equations
  2800.  
  2801.     The equations can be operated (e.g. +, -, *, /, ^, expand(), 
  2802. diff(), inte()). The operation is done on both sides of the equation, 
  2803. as by hand. You can find roots of a polynomial, algebraic equations,
  2804. systems of equations, differential and integral equations.
  2805.     You can get the left side of the equation by
  2806.         left(left_side = right_side)
  2807. or get the right side by
  2808.         right(left_side = right_side)
  2809.         You can assign equations to variables.
  2810.  
  2811.         Example.
  2812.  
  2813. IN:  eq1:= x + y = 3
  2814. IN:  eq2:= x - y = 1
  2815. IN:  eq1+eq2
  2816. OUT: 2 x = 4
  2817. IN:  last/2
  2818. OUT: x = 2
  2819. IN:  eq1-eq2
  2820. OUT: 2 y = 2
  2821. IN:  last/2
  2822. OUT: y = 1
  2823.  
  2824.     Example 4.7.1. 
  2825.         Solve an equation sqrt(x+2*k) - sqrt(x-k) = sqrt(k),
  2826. then check the solution by substituting the root into the equation.
  2827.  
  2828. IN:  eq1 := sqrt(x + 2*k) - sqrt(x - k) = sqrt(k)
  2829. OUT: eq1 := sqrt(x + 2*k) - sqrt(x - k) = sqrt(k)
  2830. IN:  eq1^2
  2831. OUT: ((2*k + x)^0.5 - ((-k) + x)^0.5)^2 = k
  2832. IN:  expand(last)
  2833. OUT: 2*x + k + (-2)*(2*k + x)^0.5*((-k) + x)^0.5 = k
  2834. IN:  last-k-2*x
  2835. OUT: (-2)*(2*k + x)^0.5*((-k) + x)^0.5 = (-2)*x
  2836. IN:  last/(-2)
  2837. OUT: (2*k + x)^0.5*((-k) + x)^0.5 = x
  2838. IN:  last^2
  2839. OUT: (2*k + x)*((-k) + x) = x^2
  2840. IN:  expand(last)
  2841. OUT: (-2)*k^2 + k*x + x^2 = x^2
  2842. IN:  last-x^2+2*k^2
  2843. OUT: k*x = 2*k^2
  2844. IN:  last/k
  2845. OUT: x = 2*k
  2846. IN:  subs(eq1, x = right(last))
  2847. OUT: k^0.5 = k^0.5
  2848.  
  2849.     You can solve algebraic equations step by step, as above.
  2850. This method is useful in teaching, e.g. showing students how to solve
  2851. equations.
  2852.  
  2853.                 4.7.2  Solve()
  2854.     The solve() functions
  2855.          
  2856.         solve(expr1 = expr2, x)
  2857.         solve([expr1 = expr2, expr3 = expr4], [x, y])
  2858.  
  2859. solve a polynomial and systems of linear equations on one step.
  2860. It is recommended to set the switch expand:=on when solve the 
  2861. complicated equations. All of the real and complex roots of the 
  2862. equation will be found by solve(). The function solve() outputs a 
  2863. list of roots when there are multi-roots. You can get one of roots 
  2864. from the list, (see Chapter 4.9 Arrays, Lists, Vectors and Matrices).
  2865.      Shareware version has not this solve() function.
  2866.  
  2867.     Example 4.7.2. 
  2868.         Solve a+b*x+x^2 = 0 for x, save the root to x.
  2869.  
  2870. IN:  solve(a+b*x+x^2 = 0, x)    # solve or re-arrange the equation for x
  2871. OUT: x = [-b/2 + sqrt((b/2)^2 - a),  -b/2 - sqrt((b/2)^2 - a)]
  2872. IN:  x := right(last)           # assign two roots to x
  2873. OUT: x := [-b/2 + sqrt((b/2)^2 - a),  -b/2 - sqrt((b/2)^2 - a)]
  2874. IN:  x[1]                       # the first root
  2875. OUT: -b/2 + sqrt((b/2)^2 - a)
  2876. IN:  x[2]                       # the second root
  2877. OUT: -b/2 - sqrt((b/2)^2 - a)
  2878.  
  2879.     Example 4.7.3. 
  2880.         Solve x^3 + x^2 + x + 5 = 2*x + 6.
  2881.  
  2882. IN:  num(solve(x^3+x^2+x+5 = 2*x+6, x))
  2883. OUT: x = [1, -1, -1]
  2884.  
  2885.     The function solve() not only solves for a simple variable x
  2886. but also solves for an unknown function, e.g. ln(x).
  2887.  
  2888.     Example 4.7.4. 
  2889.         Solve the equation for ln(x).
  2890.  
  2891. IN:  solve(ln(x)^2+5*ln(x) = -6, ln(x))
  2892. OUT: ln(x) = [-2, -3]
  2893. IN:  exp(last)
  2894. OUT: x = [exp(-2), exp(-3)]
  2895.  
  2896.     Example 4.7.5. 
  2897.         Rearrange the equations.
  2898.  
  2899. IN:  eq := [x+y = 3+a+b, x-y = 1+a-b]      # assign equations to eq
  2900. IN:  solve(eq, [x,y])         # rearrange eq for x and y
  2901. OUT: [x = -1/2*(-4 - 2 a), y = -1/2*(-2 - 2 b)]
  2902. IN:  solve(eq, [a,b])         # rearrange eq for a and b
  2903. OUT: [a = -1/2*(4 - 2 x), b = -1/2*(2 - 2 y)]
  2904. IN:  solve(eq, [a,y])         # rearrange eq for a and y
  2905. OUT: [b = -1/2*(2 - 2 y), x = -1/2*(-4 - 2 a)]
  2906. IN:  solve(eq, [x,b])         # rearrange eq for x and b
  2907. OUT: [a = 1/2*(-4 + 2 x), y = 1/2*(2 + 2 b)]
  2908.  
  2909.                 4.7.3  Polynomial Sovler: PSolve()
  2910.         The external function
  2911.                 psolve(f(x), x)
  2912. solves f(x)=0 for x. It is similar to solve(), but it only can solve
  2913. polynomial with order < 3.
  2914.  
  2915.         4.7.4  Numeric Solver: NSolve()
  2916.     The external functions 
  2917.                 nsolve(f(x) = x, x)
  2918.         nsolve(f(x) = x, x,x0)
  2919. numericly solves an algebraic equation with an initial value x0. By
  2920. default x0=1. nsolve() only gives one solution near x0, omitting other
  2921. solutions.
  2922.  
  2923.     Example 4.7.4.1. 
  2924. IN:  nsolve( cos(x) = x, x)
  2925. OUT: x = 0.73911289091
  2926. IN:  nsolve( sin(x) = 0, x,0)    # similar to asin( sin(x)=0 )
  2927. OUT: x = 0                       # only gives one solution near x0=0
  2928. IN:  nsolve( sin(x) = 0, x,3)
  2929. OUT: x = 3.14                    # only gives one solution near x0=3
  2930.  
  2931.         4.7.5  Solving Differential Equations
  2932.     You can solve the differential equations:
  2933.         y'(x) = f(x)
  2934. by integrating the equation.
  2935.     y'(x) is the same as d(y(x),x).
  2936.     
  2937.     Example: 4.7.4.1
  2938.         solve y'(x)=sin(x) by integral.
  2939. IN:  inte( y'(x) = sin(x), x)
  2940. OUT: y(x) = constant - cos(x)
  2941.  
  2942.                4.7.6  Differential Solver: DSolve()
  2943.     The external function 
  2944.         dsolve(y'(x) = f(x,y), y(x), x)
  2945. can solve the first order variables separable and linear differential 
  2946. equations
  2947.         y'(x) = h(x)
  2948.         y'(x) = f(y(x))
  2949.         y'(x) = f(y(x))*x
  2950.         y'(x) = g(x)*y(x)
  2951.         y'(x) = g(x)*y(x)+h(x)
  2952. on one step. Notice that y'(x) must be alone on the left hand
  2953. side of the equation. It is recommended to set the switch 
  2954. expand:=on when solving the complicated differential equations.
  2955.  
  2956.     Example 4.7.6.1 
  2957.         Solve y'(x) = sin(x) by dsolve().
  2958. IN:  dsolve( y'(x) = sin(x), y(x), x)
  2959. OUT: y(x) = constant - cos(x)
  2960.  
  2961.     Example 4.7.6.2 
  2962.         Solve differential equations by dsolve(). If the result is a
  2963. polynomial, then rearrange the equation by solve().
  2964.  
  2965. IN:  dsolve(y'(x) = x/(2+y(x)), y(x), x)
  2966. OUT: 2*y(x) + 1/2*y(x)^2 = constant + x^2
  2967. IN:  solve(last, y(x))
  2968. OUT: y(x) = [-2 + sqrt(4 - 2*(-constant - x^2)),
  2969.          -2 - sqrt(4 - 2*(-constant - x^2))]
  2970.  
  2971.     Example 4.7.6.3 
  2972.         Solve differential equations by dsolve().
  2973.  
  2974. IN:  dsolve(y'(x) = x*exp(y(x)), y(x), x)
  2975. OUT: -e^(-y(x)) = constant + x^2
  2976. IN:  dsolve(y'(x) = y(x)^2+5*y(x)+6, y(x), x)
  2977. OUT: ln((4 + 2 y(x))/(6 + 2 y(x))) = constant + x
  2978. IN:  dsolve(y'(x) = y(x)/x, y(x), x)
  2979. OUT: y(x) = constant x sign(x)
  2980. IN:  dsolve(y'(x) = x + y(x), y(x), x)
  2981. OUT: y(x) = -1 - x + constant*e^x
  2982.  
  2983.  
  2984.           4.8  Sums, Products, Series and Polynomials
  2985.  
  2986.     You can compute partial, finite or infinite sums and 
  2987. products. Sums and products can be differentiated and integrated. You 
  2988. construct functions like Taylor polynomials or finite Fourier series.  
  2989. The procedure is the same for sums as products so all examples will
  2990. be restricted to sums.  The general formats for these functions are:
  2991.         sum(expr, x from xmin to xmax)
  2992.         sum(expr, x from xmin to xmax step dx)
  2993.         prod(expr, x from xmin to xmax)
  2994.         prod(expr, x from xmin to xmax step dx)
  2995. The expression expr is evaluated at xmin, xmin+dx, ...  up to the last
  2996. entry in the series not greater than xmax, and the resulting values
  2997. are added or multiplied.  The part "step dx" is optional and defaults 
  2998. to 1.  The values of xmin, xmax and dx can be any real number.
  2999.  
  3000. Here are some examples:
  3001.      sum(j, j from 1 to 10)   
  3002. for 1 + 2 + .. + 10.
  3003.       sum(3^j, j from 0 to 10 step 2)  
  3004. for 1 + 3^2 + ... + 3^10.
  3005.       Here are some sample Taylor polynomials:
  3006.     sum(x^j/j!, j from 0 to n)  
  3007. for exp(x).
  3008.     sum((-1)^j*x^(2*j+1)/(2*j+1)!, j from 0 to n)
  3009. for sin(x) of degree 2*n+2.
  3010.  
  3011.     Remember, the 3 keywords (from, to and step) can be replaced by
  3012. the comma ,.
  3013.         
  3014.         4.8.1.  Partial Sum
  3015.     The function
  3016.         partsum(f(x),x)
  3017. finds the partial sum (symbolic sum).
  3018.  
  3019.     Example 4.8.1.1.
  3020. Find the sum of 1^2 + 2^2 ... + n^2.       
  3021.  
  3022. IN:  partsum(n^2, n)
  3023. OUT: 1/6 n (1 + n) (1 + 2 n)
  3024.  
  3025.         4.8.2  Infinite Sum 
  3026.     The function
  3027.         infsum(f(x),x)  
  3028. finds the infinite sum, i.e. sum(f(x), x from 0 to inf).
  3029.     Example:
  3030.  
  3031. IN:  infsum(1/n!, n)
  3032. OUT: e
  3033.  
  3034.         4.8.3.  Series 
  3035.     The external functions 
  3036.         series(f(x), x)
  3037.         series(f(x), x, order)
  3038. to find the Taylor series at x=0. The arguement (order) is optional and 
  3039. defaults to 5.
  3040.     
  3041.     Example 4.8.3.1. 
  3042. Find the power series expansion for cos(x) at x=0. 
  3043.  
  3044. IN:  series(cos(x), x)
  3045. OUT: 1 - 1/2 x^2 + 1/24 x^4
  3046.  
  3047.     The series expansion of f(x) is useful for numeric calculation
  3048. of f(x). If you can provide derivative of any function of f(x) and f(0),
  3049. you may be able to calculate the function value at any x, by series
  3050. expansion. Accurary of calculation depends on the order of series
  3051. expansion. Higher order, more accuracy, but longer calculation time.
  3052.     
  3053.     Example 4.8.3.2. 
  3054. calculate f(i), knowing f'(x)=-sin(x) and f(0)=1.
  3055.  
  3056. IN:  f'(x_) := -sin(x)
  3057. IN:  f(0) := 1
  3058. IN:  f(x_) := eval(series(f(x), x))         #  must eval()
  3059. OUT: f(x_) := 1 - 1/2 x^2 + 1/24 x^4
  3060. IN:  f(i)
  3061. OUT: 37/24
  3062.  
  3063.                 4.8.4  Polynomials
  3064.         Polynomials are automately sorted in order from low to high.
  3065.         You can pick up one of coefficient of x in polynomials by
  3066.                 coef(poly, x^n)
  3067.         e.g.
  3068. IN:  coef(x^2+5*x+6, x)
  3069. OUT: 5
  3070.  
  3071.         Note that you cannot pick up the coefficient of x^0 by coef(y,x^0).
  3072.         You can pick up one of coefficient of x in polynomials with
  3073. order < 5 by
  3074.                 coef(poly, x,n)
  3075.         e.g.
  3076. IN:  coef(x^2+5*x+6, x,0)
  3077. OUT: 6
  3078.  
  3079.         You can pick up all of coefficients of x in polynomials with
  3080. order < 5 by
  3081.                 coefall(poly, x)
  3082.         e.g.
  3083. IN:  coefall(x^2+5*x+6, x)
  3084. OUT: [6, 5, 1]                    # 6 + 5*x + x^2
  3085. IN:  coefall(a*x^2+b*x+c, x)
  3086. OUT: [c, b, a]                    # symbolic values of coefficients
  3087.  
  3088.         You can pick up the highest order of x in polynomials with
  3089. order < 5 by
  3090.                 order(poly, x)
  3091.         e.g.
  3092. IN:  order(x^2+5*x+6, x)
  3093. OUT: 2
  3094.  
  3095.         You can factor polynomials in order < 5 with respect with x by
  3096.                 factor(poly, x)
  3097.         e.g.
  3098. IN:  factor(x^2+5*x+6, x)
  3099. OUT: (2 + x) (3 + x)
  3100.  
  3101.         Note that Shareware version of SymbMath cannot do this factor as
  3102. it lacks solve().
  3103.  
  3104.  
  3105.         4.9   Arrays, Lists, Vectors and Matrices
  3106.     You can construct arrays and lists of arbitrary length, and the 
  3107. entries in the arrays and lists can be of any type of value whatsoever: 
  3108. constants, expressions with undefined variables, or equations.
  3109.     A vector and matrix can be represented by a list or array. In a
  3110. matrix, the number of elements in each row should be the same, e.g.
  3111. [[a11, a12], [a21, a22]].
  3112.  
  3113.                 4.9.1    Arrays
  3114.                 4.9.1.1  Entering Arrays
  3115.         You can define an array of a by assigning its element value into
  3116. its index:
  3117.                 a[1]:=1
  3118.                 a[2]:=4
  3119. or you can define arrays another way, with the command:
  3120.         do(a[x]:=f(x), x from xmin to xmax step dx)
  3121.         e.g.
  3122.                 do(a[j] := 2*j, j from 1 to 2)
  3123.         You can define 2-dimentional array by
  3124.                 a[1,1]:=11
  3125.                 a[1,2]:=12
  3126.                 a[2,1]:=21
  3127.                 a[2,2]:=22
  3128. or
  3129.        do(do(a[j,k]:=j+k, j,jmin,jmax,dj), k,kmin,kmax,dk)
  3130.  
  3131.                 4.9.1.2  Accessing Arrays
  3132.         After defining an array of a, you can access one of its element
  3133. by its index
  3134.  
  3135. IN:  a[1]
  3136. OUT: 1
  3137.  
  3138. you also can list out all of its elements by
  3139.                list(a[j], j,1,2,1)
  3140.         e.g.
  3141. IN:  do(a[j]:=2*j, j,1,2,1)
  3142. IN:  list(a[j], j,1,2)
  3143. OUT: 1, 4
  3144.  
  3145.                 4.9.1.3  Modifying Arrays
  3146.         You can modify an array by assigning new value into its index
  3147.  
  3148. IN:  a[1]:=2
  3149.  
  3150.                 4.9.1.4  Operating Arrays
  3151.         e.g.
  3152.         after defining 2 arrays a and b, find their dot time, a .* b.
  3153. IN:  a[1]:=1, a[2]:=2                 # define array a
  3154. IN:  b[1]:=11, b[2]:=12               # define array b
  3155. IN:  p:=0
  3156. IN:  do(p:=p + a[j]*b[j], j,1,2,1)    # a .* b
  3157.  
  3158.                   4.9.2    Lists
  3159.           4.9.2.1  Entering Lists
  3160.     You can define a list by putting its elements between two square
  3161. brackets. e.g.        [1,2,3]
  3162.     You can define lists another way, with the command:
  3163.            [ list(f(x), x from xmin to xmax step dx) ]
  3164. This is similar to the sum command,  but the result is a list:
  3165.            [f(xmin), f(xmin+dx), ..., f(xmin+x*dx), ...]
  3166. which continues until the last value of xmin + x*dx  <= xmax.  
  3167.        You also can assign the list to a variable, which variable name
  3168. become the list name:
  3169.  
  3170.          a := [1,2,3]                 # define the list of a
  3171.          b := [f(2), g(1), h(1)]      # assumes f,g,h defined
  3172.          c := [[1,2],3,[4,5]]         # define the list of c
  3173.  
  3174. Lists are another kind of value in SymbMath, and they can be assigned 
  3175. to variables just like simple values.  (Since variables in SymbMath 
  3176. language are untyped, you can assign any value to any variable.).
  3177.     A function can have a list for its value:
  3178.          f(x_) := [sqrt(x), -sqrt(x)]
  3179.         e.g.
  3180. IN:  squreroot(x_) := [sqrt(x), -sqrt(x)]
  3181. IN:  squreroot(4)
  3182. OUT: [2, -2]
  3183.  
  3184.         A function can have a list for its arguement:
  3185.              abs([-1,2])
  3186.     Try
  3187.          a := [ list(j^2, j from 0 to 10 step 1) ]
  3188.          f(x_) := [ list(x^j, j from 0 to 6 step 1) ]
  3189.          b := f(-2)
  3190.  
  3191.           4.9.2.2     Accessing Lists
  3192.  
  3193.     You can find the value of the j-th member in a list by
  3194.                   member([a,b], j)
  3195. The first member of a list is always member(x, 1).
  3196.         If you have assigned a list to a variable x, you can access the
  3197. j-th element by the list index x[j]. The first element of x
  3198. is always  x[1].  If the x[j] itself is a list, then its j-th element is
  3199. accessed by repeating the similar step.    But you can not use the list
  3200. index unless the list is already assigned to x.
  3201.  
  3202.         e.g.
  3203. IN:  x := [[1,2],3,[4,5]]     # define the x list
  3204. IN:  x[1], x[2]               # take its first and 2nd element
  3205. OUT: [1, 2], 3
  3206. IN:  x                        # access the entire list of x
  3207. OUT: [[1, 2], 3, [4,5]]
  3208. IN:  member(x, 2)             # same as x[2]
  3209. OUT: 3
  3210.  
  3211.     An entire sub-list of a list x  can be accessed with the 
  3212. command x[j], which is the list:
  3213.           [x[j], x[j+1], ... ]
  3214.  
  3215.  
  3216.           4.9.2.3     Modifying Lists
  3217.  
  3218.     The subs() replaces the value of the element in
  3219. the list, as in the variables. e.g.
  3220.  
  3221. IN:  subs([a,b,c], a = a0)
  3222. OUT: [a0, b, c]
  3223.  
  3224.         Note that you cannot modify lists by assignment.
  3225.  
  3226.           4.9.2.4     Operating Lists
  3227.  
  3228.     Lists can be added, subtracted, multiplied, and divided by 
  3229. other lists or by constants.  When two lists are combined, they are
  3230. combined term-by-term, and the combination stops when the shortest 
  3231. list is exhausted.  When a scalar is combined with a list, it is 
  3232. combined with each element of the list.  Try:
  3233.  
  3234.      a := [1,2,3]
  3235.      b := [4,5,6]
  3236.      a + b
  3237.      a / b
  3238.      3 * a
  3239.      b - 4
  3240.  
  3241.     Example 4.9.2.4.1.
  3242.         Two lists are added.
  3243.  
  3244. IN:  [a1,a2,a3] + [b1,b2,b3]
  3245. OUT: [a1 + b1, a2 + b2, a3 + b3]
  3246. IN:  last[1]
  3247. OUT: a1 + b1
  3248.  
  3249.     If L is a list, then  f(L) results in a list of the values,
  3250. even though f() is the differentiation or integration function (d() or 
  3251. inte()). 
  3252.  
  3253. IN:  sqrt([a, b, c])
  3254. OUT: [sqrt(a), sqrt(b), sqrt(c)]
  3255. IN:  d([x, x^2, x^3], x)
  3256. OUT: [1, 2*x, 3*x^2]
  3257.  
  3258.     If you use a list as the value of a variable in a function,
  3259. SymbMath will try to use the list in the calculation.
  3260.     You can sum all the elements in a list x by
  3261.                listsum(x)
  3262.     Example:
  3263.  
  3264. IN:  listsum([a,b,c]^2)
  3265. OUT: a^2 + b^2 + c^2
  3266.  
  3267.     This function takes the sum of the squares of all the elements 
  3268. in the list x.
  3269.     You can do other statistical operations (see Section 4.10. 
  3270. Statistics) on the list, or plot the list of numeric data (see
  3271. Section 5. Plot).
  3272.     You can find the length of a list (the number of elements in a
  3273. list) with:
  3274.         length(a)
  3275.  
  3276.           4.9.3     Vectors and Matrices
  3277.     You can uses arrays or lists to represent vectors, and lists of
  3278. lists to represent matrices.
  3279.     Vectors and matrices can be operated by "+" and "-" with vectors
  3280. and matrixes, by "*" and "/" with a scalar, and by diff() and inte().
  3281. These operations are on each element, as in lists.
  3282.     You can use lists as vectors, adding them and multiplying them 
  3283. by scalars. For example, the dot product of two vectors of a and b is:
  3284.             sum(a[j]*b[j], j from 1 to jmax)
  3285.     You can even make this into a function:
  3286.             dottime(x_, y_) := listsum(x*y)
  3287.         e.g.
  3288.         represnt the dot product of two vectors by arrays
  3289. IN:  a[1]:=1, a[2]:=2                 # define array a
  3290. IN:  b[1]:=11, b[2]:=12               # define array b
  3291. IN:  p:=0
  3292. IN:  do(p:=p + a[j]*b[j], j,1,2,1)    # a .* b
  3293.  
  3294.         represnt the dot product of two vectors by lists
  3295. IN:  dottime([1,2], [11,12])          # by lists in function dottime()
  3296.  
  3297.     How about the cross product:
  3298. cross(a,b) = [a[2]*b[3]-b[2]*a[3],a[3]*b[1]-b[3]*a[1],a[1]*b[2]-b[1]*a[2]]
  3299.  
  3300.      
  3301.         4.10    Statistics
  3302.     The functions:
  3303.         average(x), max(x), min(x), listsum(x), length(x)
  3304. do statistical operations.
  3305.     A list of numbers can be calculation on staticstics.
  3306.     
  3307.     Example 4.10.1.
  3308.  
  3309. IN:  p := [1, 2, 3]
  3310. IN:  average(p), max(p), min(p), length(p)
  3311. OUT: 2, 3, 1, 3
  3312.  
  3313.     Not only a list of number but also a list of symbolic data can be
  3314. operated by some statistic functions to show how to do the statistic 
  3315. operation.
  3316.  
  3317. IN:  p := [a, b, c]
  3318. IN:  average(p)
  3319. OUT: 1/3*(a + b + c)
  3320. IN:  listsum(p)
  3321. OUT: a + b + c
  3322. IN:  length(p)
  3323. OUT: 3
  3324.  
  3325.         4.11     Tables of Function Values
  3326.     If you want to look at a table of values for a formula, you 
  3327. can use the table command:
  3328.       table(f(x), x)
  3329.       table(f(x), x from xmin to xmax)
  3330.       table(f(x), x from xmin to xmax step dx)
  3331. It causes a table of values for f(x) to be displayed with x=xmin, 
  3332. xmin+dx, ..., xmax.  If xmin, xmax, and step omit, then xmin=-5, xmax=5,
  3333. and dx=1 for default. You can specify a function to be in table(), 
  3334.  
  3335.     Example 4.11.1. 
  3336. Make a table of x^2.
  3337.  
  3338. IN:  table(x^2, x)
  3339. OUT:
  3340. -5,     25
  3341. -4,     16
  3342. -3,     9
  3343. -2,     4
  3344. :       :
  3345. :       :
  3346.  
  3347.     Its output can be written into a disk file for interfacing
  3348. with other software (e.g. the numeric computation software).
  3349.  
  3350.  
  3351.         4.12   Conversion 
  3352.     Different types of data may be converted each other.
  3353.     
  3354.         4.12.1.  Converting to Numbers
  3355.     The complex number is converted to the real number by
  3356.         re(z), im(z), abs(z), arg(z), sign(z)
  3357.     The real number is converted to the interger number by
  3358.         tranc(x)
  3359.                 round(x)
  3360.     The real number is converted to the rational number by
  3361.         ratio(x)
  3362.     The rational number is converted to the real number by
  3363.         num(x)
  3364.                 numeric:=on
  3365.     The rational number is converted to the integer number by
  3366.                 nume(x)
  3367.                 deno(x)     
  3368.     The string is converted to the real number if possible, by
  3369.                 number("123")
  3370.  
  3371.                 4.12.2  Converting to lists
  3372.         You can convert sum to a list of terms by
  3373.                         term(a+b)
  3374.  
  3375. IN:  term(a+b)
  3376. OUT: [a, b]
  3377.  
  3378.         You can convert product to a lsit of multiphiers by
  3379.                         mult(a*b)
  3380.  
  3381. IN:  mult(a*b)
  3382. OUT: [a, b]
  3383.  
  3384.        You can convert an array x to a list by
  3385.                 [ list(x[j], j,1,jmax,1) ]
  3386.  
  3387.                 4.12.3  Converting to strings
  3388.         You can convert numbers to strings by
  3389.                         string(123)
  3390. IN:  string(123)
  3391. OUT: "123"
  3392.  
  3393.         4.12.4  Converting to Table
  3394.     A list of real numbers can be converted to a table by
  3395.         table()
  3396.     
  3397.     Example 4.12.1.
  3398.  
  3399. IN:  x := [5,4,3,2,1]
  3400. IN:  table(x[j], j from 1 to 4 step 1)
  3401. OUT:
  3402. 1,      5
  3403. 2,      4
  3404. 3,      3
  3405. 4,      2
  3406.  
  3407.  
  3408.                 4.13    Getting parts of expression
  3409.                 4.13.1  Getting type of data
  3410.         You can get type of data by
  3411.                         type(x)
  3412.  
  3413. IN:  type(2)
  3414. OUT: "integer"
  3415.  
  3416.                 4.13.2  Getting operators
  3417.         You also can get operators by
  3418.                         type(x)
  3419.  
  3420. IN:  type(a>b)
  3421. OUT: ">"
  3422. IN:  type(sin(x))
  3423. OUT: "sin()"
  3424.  
  3425.                 4.13.3  Getting operatands
  3426.     The functions
  3427.         left(x=a), left(a > b)
  3428.         right(x=a), right(a > b)
  3429. pick up the left- and right- side of the equation and inequality.
  3430.  
  3431. IN:  left(a>b), right(a>b)
  3432. OUT: a, b
  3433.  
  3434.         You can get the j-th term of sum by
  3435.                        member(term(a+b), j)
  3436.  
  3437. IN:  member(term(a+b), 1)
  3438. OUT: a
  3439.  
  3440.         You can get the arguments of a function by
  3441.                         argue(f(x))
  3442.  
  3443. IN:  argue(sin(x))
  3444. OUT: x
  3445.  
  3446.                 4.13.4  Getting coefficients
  3447.     A coefficient of x^n in an expression can be picked up by 
  3448.         coef(p, x^n)
  3449.  
  3450. IN:  coef(a + b*x + c*x^2 + d*x^3, x)
  3451. OUT: b
  3452.  
  3453.         You can get a coefficient of x^n (where 0<= n < 4) in polynomials
  3454. ordered up to 4 by
  3455.                 coef(poly, x,n)
  3456. (see Chapter 4.8.4 Polynomials for detail).
  3457.  
  3458.  
  3459.         4.14    Database
  3460.     After you creat a database file as a library (external function),
  3461. you can search your database by finding its function value.
  3462.  
  3463.         4.14.1  Phone No. Database
  3464.       If you have created the database file "phoneNo.(x)" as follow:
  3465.  
  3466. -------------------------------------
  3467. phoneno("huang") := "6974643"
  3468. phoneno("john")  := "12345"
  3469. --------------------------------------
  3470.  
  3471. you can find out phone No. of someone from the phone No. database
  3472. file "phoneNo.(x)" by the external function
  3473.         phoneno("name")
  3474.  
  3475.     Example 4.14.1
  3476.     find out phone No. of huang.
  3477. IN:  phoneno("huang")
  3478. OUT: "6974643"
  3479.  
  3480.         4.14.2  Chemical Reaction Database
  3481.     You can predict products for chemical reactions from the
  3482. database file "react.(x)".
  3483.  
  3484.     Example 4.14.2.  
  3485.         What are the products when HCl + NaOH react ?
  3486.  
  3487. IN:  react(HCl+NaOH)
  3488. OUT: H2O + NaCl
  3489.  
  3490.  
  3491.             4.15  Learning from User
  3492.  
  3493.     One of the most important feature of SymbMath is its ability 
  3494. to deduce and expand its knowledge. If you provide it with the 
  3495. necessary facts, SymbMath can solve many problems which were unable 
  3496. to be solved before. The followings are several ways in which SymbMath 
  3497. is able to learn from your input.
  3498.  
  3499.     4.15.1  Learning integrals from a derivative
  3500.  
  3501.     Finding derivatives is much easier than finding integrals.
  3502. Therefore, you can find the integrals of a function from the derivative
  3503. of that function.
  3504.     If you provide the derivative of a known or unknown function,
  3505. SymbMath can deduce the indefinite and definite integrals of that
  3506. function. If the function is not a simple function, you only need to
  3507. provide the derivative of its simple function. For example, you want to
  3508. evaluate the integral of f(a*x+b), you only need to provide f'(x).
  3509.  
  3510.     Example 4.15.1.1 :
  3511. If you know a derivative of an function f(x) (where f(x) is  
  3512. a known or unknown function), SymbMath can learn the integrals of that 
  3513. function from its derivative.
  3514.     Input: 
  3515. IN:  inte(f(x), x)      # check SymbMath whether or not it had already
  3516.             # known integral of f(x)
  3517. OUT: inte(f(x), x)
  3518. IN:  inte(f(x), x, 1, 2)
  3519. OUT: inte(f(x), x, 1, 2)
  3520.  
  3521. As the output displayed only what was typed in the input without any
  3522. computed results, imply that SymbMath has no knowledge of the indefinite
  3523. and definite integrals of the functions in question. Now you teach
  3524. SymbMath the derivative of f(x) on the first line, and then run the
  3525. program again.
  3526.  
  3527. IN:  f'(x_) := exp(x)/x
  3528. IN:  inte(f(x), x)
  3529. OUT: x*f(x) - e^x
  3530. IN:  inte(f(x), x, 1, 2)
  3531. OUT: e - f(1) + 2*f(2) - e^2
  3532.  
  3533. As demonstrated, you only supplied the derivative of the function, and in
  3534. exchange SymbMath logically deduced its integral.
  3535.     An other example is
  3536.  
  3537. IN:  f'(x_) := 1/sqrt(1-x^2)
  3538. IN:  inte(f(x), x)
  3539. OUT: sqrt(1 - x^2) + x*f(x)
  3540. IN:  inte(k*f(a*x+b), x)
  3541. OUT: k*(sqrt(1 - (b + a*x)^2) + (b + a*x)*f(b + a*x))/a
  3542. IN:  inte(x*f(a*x^2+b), x)
  3543. OUT: sqrt(1-(a*x^2 + b)^2) + (a*x^2 + b)*f(a*x^2 + b)
  3544.  
  3545.     The derivative of the function that you supplied can be another
  3546. derivative or integral.
  3547.  
  3548.     Example 4.15.1.2 :
  3549.  
  3550. IN:  f'(x_) := eval(inte(cos(x),x))
  3551. OUT: f'(x_) := sin(x)
  3552. IN:  inte(f(x), x)
  3553. OUT: -sin(x)
  3554. IN:  inte(f(a*x + b), x)
  3555. OUT: -sin(b + a*x)/a
  3556. IN:  inte(x*f(x), x)
  3557. OUT: -cos(x) - x*sin(x)
  3558. IN:  inte(x^1.5*f(x), x)
  3559. OUT: 1.5*inte(sqrt(x)*sin(x), x) - x^1.5*sin(x)
  3560. IN:  inte(x^2*f(x), x)
  3561. OUT: -2*x*cos(x) + 2*sin(x) - x^2*sin(x)
  3562. IN:  inte(x*f(x^2), x)
  3563. OUT: -sin(x^2)
  3564. IN:  inte(x^3*f(x^2), x)
  3565. OUT: -0.5*cos(x^2) - 0.5*x^2*sin(x^2)
  3566. IN:  inte(f(x)/(x^1.5), x)
  3567. OUT: -2/sqrt(x)*f(x) + 2*inte(sin(x)/sqrt(x), x)
  3568. IN:  inte(f(x)/(x^2), x)
  3569. OUT: -f(x)/x + si(x)
  3570.  
  3571.  
  3572.     4.15.2  Learning complicated indefinite integrals from a simple
  3573.         indefinite integral
  3574.  
  3575.     You supply a simple indefinite integral, and in return, SymbMath
  3576. will perform the related complicated integrals.
  3577.  
  3578.     Example 4.15.2.1 :
  3579. Check whether SymbMath already knowns the following integrals or not.
  3580.  
  3581. IN:  inte(f(x), x)
  3582. OUT: inte(f(x), x)
  3583. IN:  inte((2*f(x)+x), x)
  3584. OUT: inte((2*f(x)+x), x)
  3585. IN:  inte(inte(f(x)+y), x), y)
  3586. OUT: inte(inte(f(x)+y), x), y)
  3587.  
  3588. Supply, like in the previous examples, the information:
  3589. integral of f(x) is f(x) - x; then ask the indefinite integral 
  3590. of 2*f(x)+x, and a double indefinite integral of 2*f(x) + x, 
  3591. and a double indefinite integral of respect to both x and y. Change 
  3592. the first line, and then run the program again.
  3593.  
  3594. IN:  inte(f(x_), x_) := f(x) - x
  3595. IN:  inte(2*f(x)+x, x)
  3596. OUT: 2*f(x) - 2*x + 1/2*x^2
  3597. IN:  inte(inte(f(x)+y, x), y)
  3598. OUT: f(x)*y - x*y + x*y^2
  3599.  
  3600.     You can also ask SymbMath to perform the following integrals: 
  3601. inte(inte(f(x)+y^2, x), y), 
  3602. inte(inte(f(x)*y, x), y), 
  3603. inte(x*f(x), x), 
  3604. triple integral of f(x)-y+z, or others.
  3605.  
  3606.  
  3607.     4.15.3  Learning definite integral from indefinite integral
  3608.  
  3609.     You continue to ask indefinite integral.
  3610.  
  3611. IN:  inte(inte(f(x)+y, x from 0 to 1), y from 0 to 2)
  3612. OUT: 2 f(1)
  3613.  
  3614.  
  3615.     4.15.4  Learning complicated derivatives from a simple derivative
  3616.     SymbMath can learn complicated derivatives from a simple 
  3617. derivative, even though the function to be differentiated is an unknown
  3618. function, instead of standard function.
  3619.  
  3620.     Example 4.15.4.1 :
  3621.         Differentiate f(x^2)^6, where f(x) is an unknown function.
  3622.  
  3623. IN:  d(f(x^2)^6, x)
  3624. OUT: 12 x f(x^2)^5 f'(x^2)
  3625.  
  3626. Output is only the part derivative. f'(x^2) in the output suggest that
  3627. you should teach SymbMath f'(x_). e.g. the derivative of f(x) is another
  3628. unknown function df(x), i.e. f'(x_) = df(x), input f'(x_) = df(x) and
  3629. run it again.
  3630.  
  3631. IN:  f'(x_) := df(x)
  3632. IN:  d(f(x^2)^6, x)
  3633. OUT: 12 x f(x^2)^5 df(x^2)
  3634.  
  3635. This time you get the complete derivative.
  3636.  
  3637.     4.15.5  Learning integration from algebra
  3638.     If you show SymbMath algebra, SymbMath can learn integrals
  3639. from that algebra.
  3640.  
  3641.     Example 4.15.5.1 :
  3642. Input f(x)^2=1/2-1/2*cos(2*x), then ask for the integral of f(x)^2.
  3643.  
  3644. IN:  f(x)^2 := 1/2-1/2*cos(2*x)
  3645. IN:  inte(f(x)^2, x)
  3646. OUT: 1/2 x - 1/4 sin(2 x)
  3647.  
  3648. SymbMath is very flexible. It learned to solve these problems, even 
  3649. though the types of problems are different, e.g. learning integrals 
  3650. from derivatives or algebra.
  3651.  
  3652.  
  3653.     4.15.6  Learning complicated algebra from simple algebra
  3654.  
  3655.     SymbMath has the ability to learn complicated algebra from simple 
  3656. algebra.
  3657.  
  3658.     Example 4.15.6.1:
  3659. Transform sin(x)/cos(x) into tan(x) in an expression.
  3660.  
  3661. IN:  sin(x)/cos(x) := tan(x)
  3662. IN:  x+sin(x)/cos(x)+a
  3663. OUT: a + x + tan(x)
  3664.  
  3665.  
  3666.         4.15.7  Learning vs. Programming
  3667.     The difference between learning and programming is as follows : 
  3668. the learning process of SymbMath is very similar to the way human 
  3669. beings learn, and that is accomplished by knowing certain rule that 
  3670. can be applied to several problems. Programming is diffrent in the way 
  3671. that the programmer have to accomplish many tasks before he can begin 
  3672. to solve a problem. First, the programmer defines many subroutines for 
  3673. the individual integrands (e.g. f(x), f(x)+y^2, 2*f(x)+x,
  3674. x*f(x), etc.), and for individual integrals (e.g. the indefinite
  3675. integral, definite integral, the indefinite double integrals,
  3676. indefinite triple integrals, definite double integrals, definite
  3677. triple integrals, etc.), second, write many lines of program for the
  3678. individual subroutines, (i.e. to tell the computer how to calculate
  3679. these integrals), third, load these subroutines, finally, call these
  3680. subroutines. That is precisely what SymbMath do not ask you to do.
  3681.     In one word, programming means that programmers must
  3682. provide step-by-step procedures telling the computer how to solve
  3683. each problems. By contrast, learning means that you need only supply
  3684. the necessary facts (usually one f'(x) and/or one intergral of f(x)),
  3685. SymbMath will determine how to go about solutions of many problems.
  3686.     If the learning is saved as a library, then you need not to
  3687. teach SymbMath again when you run SymbMath next time.
  3688.  
  3689.  
  3690.         5.   Graphics
  3691.         5.1  Drawing lines and arcs
  3692.     SymbMath includes extensive facilities for graphing. It supports
  3693. BGI-graphics, which graphics commands are the same as those in Turbo Pascal
  3694. and Turbo C, except for:
  3695.  
  3696.           different graphics commands
  3697. ------------------------------------------------
  3698. SymbMath             Turbo Pascal or C
  3699.  
  3700. graph                initgraph(drive,mode,path)
  3701. text                 closegraph
  3702. writes(x)            outtext(x)
  3703. -------------------------------------------------
  3704.                                         
  3705.     Before graphing, you should initialize the graphics system and puts
  3706. the computer hardware into graphics mode by the command:
  3707.         graph
  3708. then you can draw a line by
  3709.         line(x1,y1,x2,y2)
  3710.         lineto(x2,y2)
  3711.         linerel(dx,dy)
  3712. draw a circular arc by                
  3713.         arc(x,y,angle1,angle2,radius)
  3714. draw an elliptical arc by                
  3715.         ellipse(x,y,angle1,angle2,XRadius,YRadius)
  3716. put a pixel by                
  3717.         putpixel(x,y,color)
  3718.     you can move a pointer by
  3719.         moveto(x,y)
  3720.         moverel(dx,dy)
  3721.         A upper left corner on your graphics screen coordinates is (0,0).
  3722.         The color and style of the line can be set by setcolor() and
  3723. setlinestyle(). You can set screen colors.
  3724.      If you are using a color system, you can set the color of the next
  3725. line or graph or text with the command:
  3726.                  setcolor(color)
  3727. where color is an integer in the range 0..15, or one of the color words if
  3728. package color.sm has been loaded.
  3729.      You can set the background color for your graphs with the command
  3730.         setbkcolor(color)
  3731. where color is an integer in the range 0..15, or one of the color words if
  3732. package color.sm has been loaded.
  3733.  
  3734.         Table 5.1     Color word and Its value in package color.sm
  3735. ------------------------------------------------------------------
  3736. color word                value
  3737.  
  3738. black                     0
  3739. blue                      1
  3740. green                     2
  3741. cyan                      3
  3742. red                       4
  3743. magenta                   5
  3744. brown                     6
  3745. lightgray                 7
  3746. gray                      8
  3747. lightblue                 9
  3748. lightgreen                10
  3749. lightcyan                 11
  3750. lightred                  12
  3751. lightmagenta              13
  3752. yellow                    14
  3753. white                     15
  3754. ----------------------------------------
  3755.  
  3756.      You can set line styles.
  3757.      On both monochrome and color systems, you can draw lines and graphs
  3758. with different line styles.  (Since the line segments used to draw graphs
  3759. are usually very short, different line styles may not be distinguished in
  3760. graphs, but they will be distinguished on long lines.)  Linestyles are
  3761. indicated by integers in the range 0..3, and are set by the command:
  3762.                 setlinestyle(style,u,thickness)
  3763. where style, u and thickness are integers.
  3764.     You can set the text style by
  3765.         settextstyle(font,direction,size)
  3766. where font, direction and size are integers.
  3767.         You can add labels to your graphs by
  3768.                 writes(s)
  3769.      You can put alphanumeric labels anywhere on your graphic screens.
  3770. They can be horizontal or vertical, and they can be printed in various
  3771. sizes. To print a string  s  horizontally on the screen with the
  3772. lower-left corner at the screen coordinates (x,y), use two commands:
  3773.                 moveto(x,y), writes(s)
  3774. To write vertically bottom to top, use two commands:
  3775.                 settextstyle(1,2,2), writes(s)
  3776.       
  3777.       If SymbMath attempts to graph a point (x,y) which is outside the
  3778. the screen coordinate, it ignores the point and continues.  No error
  3779. message is generated, and even functions which are undefined on part of
  3780. the graphing domain can be graphed.
  3781.           You can get the max x and max y on your graphics screen
  3782. coordinates by
  3783.                 getmaxx
  3784.                 getmaxy
  3785.           You can get the current point(x, y) on your graphics screen
  3786. coordinates by
  3787.                 getx
  3788.                 gety
  3789.           You can get the background color and foregroud color on your
  3790. graphics screen by
  3791.                 getbkcolor
  3792.                 getcolor
  3793.           You can read a character from the keyboard or pause by the
  3794. command:
  3795.         readchar
  3796.       Finally you should go back the text mode by the command:
  3797.                 text
  3798.  
  3799.       Example 5.1:      
  3800. #    drawing a group of circles and ovals.
  3801. #    Circles are 9 planets around sun.
  3802.  
  3803. graph                                        # graph mode
  3804. do(circle(getmaxx*0.5+2.5*x,getmaxy*0.5,5), x,0,90,10)
  3805. do(oval(getmaxx*0.5,getmaxy*0.5,2.5*x,x), x,10,90,10)
  3806. readchar                                     # pause graph by read a char
  3807. text                                         # back text mode
  3808.  
  3809.         5.2.  Plotting y = f(x)
  3810.     You can plot a function of y = f(x) on the xy-plane by a single 
  3811. external function
  3812.  
  3813.         plot(f(x),x)
  3814.                 plot(f(x),x,xmin,xmax)
  3815.                 plot(f(x),x,xmin,xmax,ymin,ymax)
  3816.  
  3817. f(x) can be either a function  with bound variable x or an expression
  3818. involving x.  For example, you could graph the parabola with the command
  3819. plot(x^2,x).  
  3820.      The xmin and xmax are range of x-axis, the ymin and ymax are range of
  3821. y-axis. The default values are xmin=-5, xmax=5, ymin=-5, and ymax=5.
  3822. The values of xmin, xmax, ymin, ymax are real numbers, such that  
  3823. xmin < xmax  and  ymin < ymax.  Thses values tell SymbMath that the 
  3824. visible screen corresponds to a portion of the xy-plane with  
  3825. xmin <= x <= xmax  and  ymin <= y <= ymax. 
  3826.      The operator plot() plots one point (x,f(x)) for each pixel on the
  3827. x-axis, and connects successive points.  To omit the connections and just
  3828. plot the points, use the command:
  3829.             dotplot(f(x),x)
  3830.      To plot only every 20th point, which is useful for rapidly
  3831. graphing complicated functions, use
  3832.             sketch(f(x),x)
  3833.      If you want your circles and squares to look correct --
  3834. that is, if you want one vertical unit to be really the same
  3835. distance as one horizontal unit--you should select window
  3836. parameters so that the horizontal axis is 1.4 times as long as
  3837. the vertical axis.
  3838.     Example 5.2:                
  3839.     plot a function of x^3.
  3840. IN:  plot(x^3,x)                
  3841.  
  3842.                 5.3    Plotting r = f(t) in polar coordinates
  3843.      You can graph the portion of a polar curve  r = f(t) that lies in
  3844. the window with a single external function:
  3845.  
  3846.                        polar(f(t),t)
  3847.                        polar(r, t,tmin,tmax)
  3848.                        polar(r, t,tmin,tmax,rmin,rmax)
  3849.  
  3850. f(t) can be a function with bound variable t or an expression involving t.
  3851. For example, to graph the cardoid  r = 1+cos(t), execute the command
  3852.                        polar(1+cos(t),t)
  3853. The variable t covers the domain (0, 2π); you can change this default by
  3854. specifying a range for t:
  3855.                        polar(1+cos(t), t,0,pi)
  3856.  
  3857.  
  3858.             6.   Inside SymbMath
  3859.                         6.1  Internal Structure
  3860.     As an expert system, SymbMath consists of three major 
  3861. components: a knowledge base, an inference engine, and a global data 
  3862. base. The knowledge base is a set of rules, the inference engine is a 
  3863. rule interpreter for utilizing the knowledge base in the solution of 
  3864. the problem, and the global data base is a working memory for keeping 
  3865. track of the problem status, the data from the data file for the 
  3866. particular problem, and the solution of sub-problems. In addition, it 
  3867. contains a natural language interface for input and output natural 
  3868. languages (e.g. mathematical formulas, chemical reactions).
  3869.  
  3870.  
  3871.         User    Library         disk
  3872.          /|\       |             /|\
  3873.           |        |              |
  3874.          \|/      \|/            \|/
  3875.         ------------------------------
  3876.         | Natural Language Interface |
  3877.         ------------------------------
  3878.                    /|\
  3879.                 |
  3880.                    \|/
  3881.         ------------------------------
  3882.     ------->|        Inference Engine    |<----------
  3883.     |       ------------------------------          |
  3884.        \|/                                             \|/
  3885. ------------------                              --------------------
  3886. | Knowledge Base |                              | Global Data Base |
  3887. ------------------                              --------------------
  3888.                                /|\
  3889.                             |
  3890.                         --------------------
  3891.                         |    Data File     |
  3892.                         --------------------
  3893.  
  3894.     Figure 6.1      Structure of SymbMath
  3895.  
  3896.  
  3897.  
  3898.     Table 6.1      Characteristics of SymbMath
  3899. --------------------------------------------------------------------
  3900. Function:                       Symbolic computation.
  3901. Domain:                         Mathematics, chemistry.
  3902. Search direction:               Forward chaining.
  3903. Control mechanism:              Guessing and test, pattern match.
  3904. Search space transformations:   Break into sub-problems.
  3905. Knowledge base representation:  Rules.
  3906. Developer interface:            Learning, programming, library.
  3907. User interface:                 Pull-down menu, pop-up menu, multi-windowed
  3908.                 text editor, help, windows.
  3909. System interface:               numeric computation software, graphic 
  3910.                 software (e.g. PlotData), etc.
  3911. Input format:                   Math formulas, numbers, BASIC or FORTRAN 
  3912.                 codes, chemical symbols and reactions.
  3913. Output format:                  Math notation, BASIC or FORTRAN codes, 
  3914.                 chemical reaction equations.
  3915. Input from:                     Keyboard, disk.
  3916. Output to:                      Screen, disk, printer.
  3917. Tool language:                  Prolog.
  3918. Computer:                       IBM PC.
  3919. Memory:                         400 KBytes.
  3920. Operating system:               MS-DOS.
  3921. ---------------------------------------------------------------------
  3922.  
  3923.                         6.2  Internal format
  3924.         You can peep at the internal format in the SymbMath system by
  3925. setting output := prolog. This is useful for understanding SymbMath.
  3926.         Example.
  3927. IN:  output:= prolog
  3928. IN:  a+b
  3929. OUT: plus(var("a"),var("b"))
  3930.  
  3931.  
  3932.             7. System limits
  3933.     1. The maximum character of a symbol is 64000.
  3934.     2. The maximum character of an expression is 64000.
  3935.     3. The range of the input real numbers is 
  3936.   -inf, -(10^307)^(10^307) to -(10^-307)^(10^-307), 0, (10^-307)^(10^-307)
  3937. to (10^307)^(10^307), inf.
  3938.     4. The range of the output real numbers is the same as input 
  3939. when the switch numeric:=off, but when the switch numeric:=on, it is
  3940.     -inf, -1.E307 to -1.E-307, 0, 1.E-307 to 1.E307, inf.
  3941.     5. The maximum digit of the input numbers is 64000.
  3942.     6. The maximum digit of the stored numbers is 16.
  3943.     7. The maximum digit of the output numbers is 11.
  3944.     8. The maximum digit of the rational numbers is 16.
  3945.     9. The maximum arguments of the user-defined function with
  3946. pattern is 6.
  3947.     10. The maximum arguments of the user-defined rule is 2 and the
  3948. maximum pattern is 3. Only following rules are available:
  3949.  
  3950. --------------------------------------------------------------------------        
  3951.         f(a_ + b_)     f(a_ + b_, x_)    d(s(x_), x_)      inte(c(x_), x_)
  3952.         f(a_ - b_)     f(a_ - b_, x_)    d(s(n_,x_), x_)
  3953.         f(a_ * b_)     f(a_ * b_, x_)
  3954.         f(a_ ^ b_)     f(a_ ^ b_, x_)
  3955.         f(s(a_))       f(c(x_), x_)
  3956.         f(-a_)         f(a, x_)
  3957.         f'(x_)         f(a_, x)
  3958. ---------------------------------------------------------------------------
  3959. where s() is a simple function, c() is a complicated function.
  3960.  
  3961.  
  3962.             8.      Keywords
  3963.  
  3964.     SymbMath has three versions: Shareware Version A, Student
  3965. Version B and Advanced Version C. The shareware version lacks the 
  3966. solve(), trig (except sin(x) and cos(x)), and hyerbolic functions, 
  3967. (lack 10% keywords) and the student version lacks the hyerbolic
  3968. functions (lack 5% keywords). You cannot input these lack functions
  3969. in shareware or student version.
  3970.     Upper- and lower-case letters are different until the switch
  3971. lowercase is set to on (i.e. lowercase := on).
  3972.     All keywords are lower-case letters until the switch lowercase
  3973. := on.
  3974.     There are two types of the keywords: internal and external.
  3975. The internal keywords have been compiled into the SymbMath system,
  3976. so you cannot change them. The external ones are in files, so you
  3977. can change their name or property. Usages of both types are the same.
  3978.     The following only includes the internal and some external 
  3979. keywords. You can define your own keyword and add your defined function. 
  3980. If some keywords do not work, you should check whether or not the
  3981. libraries *.(x) are in the default directory.
  3982.  
  3983.  
  3984.          8.1        Keywords in Topic Order
  3985. ---------------------------------------------------------------------
  3986. 1. Algebraic operators: +, -, *, /, ^, **, ().
  3987. 2. Relational operators: ==, >, >=, <, <=, <>.
  3988. 3. Assignments: :=
  3989. 4. Equation: solve(x^2=1,x), solve([x+y=b,x-y=c], [x,y]), psolve(f(x), x),
  3990.              nsolve(cos(x)=x,x), dsolve(y'(x)=f(x,y), y(x),x), =.
  3991. 5. Comment: #.
  3992. 6. Built-in constants: i, e, pi, inf, zero, constant, discont, c_inf,
  3993.     undefined.
  3994. 7. Built-in variables: last.
  3995. 8. Logic operators: and, or, not(x).
  3996. 9. Algebraic functions: -x, sqrt(x), n!, fac(n), mod(x,y), div(x,y),
  3997.     random(x), expand(x), factor(x), factor(y,x), root(x,n).
  3998. 10. Complex to real: re(x), im(x), abs(x), |x|, arg(x), sign(x).
  3999. 11. Exponential functions: exp(x), ln(x), log10(x).
  4000. 12. Trig functions: sin(x), cos(x), tan(x), csc(x), sec(x), cot(x), 
  4001.     asin(x), acos(x), atan(x), acot(x), asec(x), acsc(x), atan2(x,y).
  4002. 13. Hyperbolic functions: sinh(x), cosh(x), tanh(x), csch(x), sech(x),
  4003.     coth(x), asinh(x), acosh(x), atanh(x), acoth(x), acsch(x),
  4004.     asech(x).
  4005. 14. Special math functions: ei(x), ei(n,x), gamma(x), gamma(n,x), erf(x),
  4006.     si(x), ci(x), li(x), li(n,x).
  4007. 15. Defining functions: f(x_):=x^2, f(x_) := if(x>0 then x^2).
  4008. 16. Defining procedures: f(x_):=block(p:=x^2,p,local(p))
  4009. 17. Defining rules: log(x_ * y_) := log(x) + log(y).
  4010. 18. Clear: clear(x), clear(f(x)), clear(a>0).
  4011. 19. Calculus functions: 
  4012.     d(y,x), d(y,x,order),  diff(y, x = x0), f'(x), inte(), ninte(),
  4013.     subs(y, x = x0), lim(y, x = x0), nlim(y, x=x0), laplace(y,x),
  4014.     sum(y, x,xmin,xmax,dx), partsum(y,x), infsum(y,x),
  4015.     prod(y, x,xmin,xmax,dx), series(y,x), series(y,x,order).
  4016. 20. Conversion functions:
  4017.         ratio(x), round(x), trunc(x), nume(2/3), deno(2/3), table(),
  4018.         number(x), string(x), term(a+b), mult(a*b), type(x).
  4019. 21. Numeric computation: num(x), nsolve(), ninte(), nlim(), numeric:=on.
  4020. 22. Test functions: isodd(x), iseven(x), isinteger(x), isratio(x),
  4021.         isreal(x), iscomplex(x), isnumber(x), islist(x), isfree(y,x),
  4022.         issame(x), islarger(a,b), isless(a,b), type(x)=="real".
  4023. 23. Table: table(f, x,xmin,xmax,dx).
  4024. 24. Arrays and array index: a[1]:=1, do(a[x]:=x, x,xmin,xmax,dx), a[1].
  4025. 25. Lists and list index: [a,b], [list()], member([a],j), last[1].
  4026. 26. Statistics: average(x), max(x), min(x), listsum(x), length(x).
  4027. 27. Switches: numeric, output, expand, expandexp, lowercase,
  4028.     :=, on, off, basic, fortran, prolog, math.
  4029. 28. DOS Commands: system("dir").
  4030. 29. Comma: , , from, to, step, then, else, until.
  4031. 30. Assume: assume(a>0), isreal(x):=1.
  4032. 31. Conditional: if(x>0 then x), if(x>0 then x else -x).
  4033. 32. Loop: repeat(expr until x>5), do(expr, x,xmin,xmax,dx),
  4034.           list(y,x,xmin,xmax).
  4035. 33. Reading: readfile("file"), readchar, readline.
  4036. 34. Writing: openfile("file"), closefile("file"), writes(x), null, block(),
  4037.              newline.
  4038. 35. Plot: plot(x^3,x), dotplot(x^3,x), polar(1+t,t).
  4039. 36. Graph: graph, text, line(), lineto(x,y), linerel(dx,dy), ellipse(),
  4040.         putpixel(x,y,color), moveto(x,y), moverel(dx,dy), arc(), getmaxx,
  4041.         getmaxy, setcolor(white), setbkcolor(red), setviewport(),
  4042.         setlinestyle(), settextstyle(font,dir,size), circle(), oval(),
  4043.         settextjustify(hor,ver), getx, gety, getbkcolor, getcolor.
  4044. 37. String: "123", concat(a,b), remove(b,ab), length(a), string(1),
  4045.             reverse(x).
  4046. 38. Getting parts: type(x), left(x), right(x), term(a+b), mult(), coef(),
  4047.             coefall(), power(x^n), base(x^n), argue(x), sequence(x),
  4048.             re(x), im(x), int(x), frac(x).
  4049. --------------------------------------------------------------------------
  4050.  
  4051.  
  4052.        8.2          Keywords in Alphabetical Order
  4053. ---------------------------------------------------------------------------
  4054. abs(x)          acos(x)         acosh(x)        acot(x)         acoth(x) 
  4055. acsc(x)         acsch(x)        and             arc()           arg(x)          
  4056. argue(x)        asec(x)         asech(x)        asin(x)         asinh(x)
  4057. assume(x>0)     assumed         atan(x)         atan2(x,y)      atanh(x)
  4058. average(x)
  4059.  
  4060. base(x^n)       basic           block()
  4061.  
  4062. ci(x)           circle()        clear(x)        cleared         closefile()
  4063. coef()          coefall(y,x)    concat(a,b)     constant        cos(x)
  4064. cosh(x)         cot(x)          coth(x)         csc(x)          csch(x)
  4065. c_inf
  4066.  
  4067. d()             degree          deno(x)         diff()          div(x,y)
  4068. discont         do()            done            dotplot()       dsolve()
  4069.  
  4070. e               ei()            ellipse()       else            eval()
  4071. erf(x)          exp(x)          expand(x)       expand          expandexp
  4072.  
  4073. f'(x)           fac(x)          factor()        fortran         frac(x)
  4074. from            
  4075.  
  4076. gamma(x)        gamma(n,x)      gcd(a,b)        getbkcolor      getcolor
  4077. getmaxx         getmaxy         getx            gety            graph
  4078.  
  4079. i               if()            im(x)           inf             infsum(y,x)
  4080. int(x)          inte()          iscomplex(x)    iseven(x)       isfree(y,x)
  4081. isinteger(x)    islarger(a,b)   isless(a,b)     islist(x)       isodd(x)
  4082. isratio(x)      isreal(x)       issame(x,y)     isnumber(x)
  4083.  
  4084. laplace(y,x)    last            left(x)         length()        li()
  4085. lim()           line()          lineto(x,y)     linerel(dx,dy)  list()
  4086. listsum(x)      ln(x)           local()         log10(x)        lowercase
  4087.  
  4088. math            max(x)          member(x,n)     min(x)          mod(x,y)
  4089. moveto(x,y)     moverel(dx,dy)  mult(x)
  4090.  
  4091. newline         ninte()         nlim(y,x=x0)    not(x)          nsolve()
  4092. null            num(x)          number(x)       nume(x)         numeric
  4093.  
  4094. off             on              openfile("x")   or              order(y,x)
  4095. output          oval()
  4096.  
  4097. partsum(y,x)    pi              plot(y,x)       phoneno(x)      polar()
  4098. power(x^n)      prod()          prolog          psolve()        putpixel()
  4099.  
  4100. random          random(x)       ratio(x)        re(x)           react(x)
  4101. readchar    readfile("x")   readline        remove(b,ab)    repeat()
  4102. reverse(a)      right(x)        root()          round(x)
  4103.  
  4104. sec(x)          sech(x)         series()        sequence([])    setbkcolor()
  4105. setcolor()      setlinestyle()  settextjustify()settextstyle()  setviewport()
  4106. si(x)           sign(x)         sin(x)          sinh(x)         solve(eq,x)
  4107. sqrt(x)         subs()          sum()           step            string(x)
  4108. system(dos)     
  4109.  
  4110. table()         tan(x)          tanh(x)         term()          text
  4111. then            to              trunc(x)        type(x)
  4112.  
  4113. undefined       until
  4114.  
  4115. writes(x)
  4116.  
  4117. zero
  4118.  
  4119. +               -               *               /               ^ 
  4120. **              ()              []              =               := 
  4121. ==              >               >=              <               <=
  4122. <>              !               #               ,               |x|
  4123. "x"             '
  4124. -----------------------------------------------------------------------
  4125.  
  4126.  
  4127.  
  4128.         8.3     Glossary
  4129.  
  4130. --------------------------------------------------------------------------
  4131. * abs                                                 internal+external
  4132. abs(x) is the absolute value function of x. x can be complex numbers.
  4133. abs(x) = sqrt(re(x)^2+im(x)^2). The results are in the range 0 to inf.
  4134. abs(x) = |x|.
  4135. See also: abs, arg, sign, re, im, |x|.
  4136. e.g.
  4137. IN:  abs(-1), abs(-i)
  4138. OUT: 1, 1 
  4139.  
  4140. * acos                                                external
  4141. acos(x) is the arc cosine function of x. The inverse function of 
  4142. cos(x). The result is given in radians.
  4143. See also: acos, cos.
  4144.  
  4145. * acosh                                               external
  4146. acosh(x) is the inverse hyerbolic cosine function of x.
  4147. The inverse function of cosh(x).
  4148. See also: acosh, cosh.
  4149.  
  4150. * acot                                                external
  4151. acot(x) is the arc cotangent function of x. The inverse function 
  4152. of cot(x). The result is given in radians. acot(x)=pi/2-atan(x).
  4153. See also: acot, cot.
  4154.  
  4155. * acoth                                               external
  4156. acoth(x) is the inverse hyperbolic cotangent function of x. The 
  4157. inverse function of coth(x). acoth(x)=atanh(1/x).
  4158. See also: acoth, coth.
  4159.  
  4160. * acsc                                                external
  4161. acsc(x) is the arc cosecant function of x. The inverse function of 
  4162. csc(x). The result is in radians. acsc(x)=pi/2-asin(x).
  4163. See also: acsc, csc.
  4164.  
  4165. * acsch                                               external
  4166. acsch(x) is the inveres hyperbolic cosecant function of x. The 
  4167. inverse function of csch(x). acsch(x)=asinh(1/x).
  4168. See also: acsch, csch.
  4169.  
  4170. * and                                                 internal
  4171. logic operator. It is bitwise and. The result is 1, 0 or unevalated.
  4172. See also: and, or.
  4173. e.g.
  4174. IN:  1 and 1, 1 and 0
  4175. OUT: 1, 0
  4176.  
  4177. * arc                                                 internal
  4178. arc(x,y,angle1,angle2,radius) draws a circular arc from angle1 to angle2
  4179. with radius at point(x,y). The angles are counter-clockwise with 0 degrees
  4180. at o'clock, 90 degrees at 12 o'clock, and so on.
  4181. It only works on graphics mode.
  4182. See also: arc, ellipse, line, lineto, linerel, putpixel.
  4183. e.g.
  4184. IN:  graph, arc(100,100,0,180,100), readchar, text
  4185.  
  4186. * arg                                                 external
  4187. arg(x) gives the argument (phase angle) of x in radians. It only gives the
  4188. principle value (P.V.): -pi < arg(x) <= pi. arg(x) = atan2(re(x),im(x)).
  4189. x can be complex number. For positive real x, arg(x)=0.
  4190. See also: abs, arg, sign, atan2.
  4191. e.g. num(arg(i)) gives 1.5..
  4192.  
  4193. * argue                                               internal
  4194. argue(f(x)) gives the argument of the function f(x). type(f(x)) gives the
  4195. function name.
  4196. See also: type.
  4197. e.g. argue(sin(x)) give x, type(sin(x)) gives "sin()".
  4198.  
  4199. * asec                                                external
  4200. asec(x) is the arc secant function of x. The inverse function of 
  4201. sec(x). The result is given in radians. 
  4202. See also: asec, sec.
  4203.  
  4204. * asech                                               external
  4205. asech(x) is the inverse hyperbolic secant function of x. The inverse 
  4206. function of sech(x). asech(x)=acosh(1/x).
  4207. See also: asech, sech.
  4208.  
  4209. * asin                                                external
  4210. asin(x) is the arc sine function of x. The inverse function of 
  4211. sin(x). The result is given in radians.
  4212. See also: asin, sin.
  4213.  
  4214. * asinh                                               external
  4215. asinh(x) is the inverse hyperbolic sine function of x. The inverse 
  4216. function of sinh(x).
  4217. See also: asinh, sinh.
  4218.  
  4219. * assume                                              external
  4220. assume(x > 1) assumes the variable x > 1 in real domain.
  4221.         By default, |x| < inf and all variables are complex, except that
  4222. variables in inequalities are real, as usual only real numbers can be
  4223. compared. e.g. x is complex in sin(x), but y is real in y > 1.
  4224.     You can restrict the domain of a variable by assuming the variable
  4225. is even, odd, integer, real number, positive or negative.
  4226. The assume() can be cleared by clear().
  4227. See aslo: sign, isodd, iseven, isinteger, isreal, isnumber, clear.
  4228. e.g. assume(x>0), assume(x>0, y<0), iseven(x):=1
  4229.  
  4230. * assumed                                             external
  4231. assumed points out that the variable has been assumed.
  4232. See also: assume, clear.
  4233.  
  4234. * atan                                                internal + external
  4235. atan(x) is the arc tangent function of x. The inverse function of 
  4236. tan(x). The result is given in radians.
  4237. See also: atan, tan.
  4238.  
  4239. * atan2                                               internal
  4240. atan2(x,y) returns the radian angle of (x,y).
  4241.   atan2(x,y)    = sign(y)*pi/2   if x=0
  4242.         = atan(y/x)     if x>0
  4243.         = atan(y/x)+pi  if x<0, y>=0
  4244.         = atan(y/x)-pi  if x<0, y<0 .
  4245. Thus atan2(x,y) takes its value of -pi < atan2(x,y) <= pi.
  4246. See also: atan, arg.
  4247.  
  4248. * atanh                                               external
  4249. atanh(x) is the inverse hyperbolic tangent function of x. The inverse 
  4250. function of tanh(x).
  4251. See also: tanh.
  4252.  
  4253. * average                                             external
  4254. average(x) gives average of a list of data.
  4255. See also: max, min, length, listsum.
  4256. e.g.
  4257. IN:  average([1,2,3]
  4258. OUT: 2
  4259.  
  4260. * base                                                internal
  4261. base(x^n) gives the base of x^n.
  4262. See also: base, power, type.
  4263. e.g. base(x^n) gives x, type(x^n) gives "^", power(x^n) gives n.
  4264.  
  4265. * basic                                               internal
  4266. basic is a value of the switch output. It sets output in BASIC format. 
  4267. See also: output, on, off, fortran, prolog, math.
  4268. e.g. output:=basic.
  4269.  
  4270. * block                                               internal
  4271. block(a,b,c) groups a,b,c and only returns the last arguement as its
  4272. value, or returns the second last arguement as its value if the last
  4273. arguement is local(). It is used as grouper in definition of a procedure.
  4274. All variables in block are global, except for variables declared by
  4275. local().
  4276. e.g. f(x_):=block(p:=x^6,p, local(p))
  4277. See also: local.
  4278.  
  4279. * ci                                                  external
  4280. ci(x) is cos integral, ci(x) = inte(cos(x)/x, x).
  4281. See also: si, ei, gamma, erf.
  4282.  
  4283. * circle                                              external
  4284. circle(x,y,radius) draws a circle at point(x,y) with radius.
  4285. See also: graph, arc, oval.
  4286. e.g. graph, circle(200,200,100), readchar, text
  4287.  
  4288. * clear                                               internal
  4289. clear(y) clears values and definitions for the variable, function or 
  4290. expression y from memory. 
  4291. See also: assume, :=.
  4292. e.g. clear(p), clear(f(x)), clear(a>0)
  4293.  
  4294. * cleared                                             internal
  4295. It says that the variable, function or expression has been cleared
  4296. from assignment.
  4297. See also: clear, assume, :=.
  4298.  
  4299. * closefile                                           internal
  4300. closefile("filename") closes the file "filename" and return the output
  4301. to screen. The filename is any MS-DOS file name.
  4302. See also: openfile, readfile.
  4303.  
  4304. * coef                                                internal + external
  4305. coef(y,form) gives the coefficient of form in the polynomial y. 
  4306. It picks only terms that contain the particular form specified. x is
  4307. not considered part of x^6.
  4308. See also: coefall.
  4309. e.g.
  4310. IN:  coef(2*x^6+x+4, x^6), coef(2*x^6+x+4, x)
  4311. OUT: 2, 1
  4312.  
  4313. coef(y, x, order) gives the coefficient of x with order in the polynomial
  4314. y.  order < 5.
  4315. e.g.
  4316. IN:  coef(x^2+x+6, x, 0)
  4317. OUT: 6
  4318.  
  4319. * coefall                                             internal
  4320. coefall(y, x) gives a list of all coefficients of x in the polynomial y.
  4321. order < 5.  The polynomial is in order from low to high.
  4322. See also: coef.
  4323. e.g.
  4324. IN:  coefall(6+5*x+x^2, x)
  4325. OUT: [6, 5, 1]
  4326.  
  4327. * concat                                              internal
  4328. concat("a","b") concatenates 2 string into one string.
  4329. See also: remove, string.
  4330. e.g. concat("a","b") gives "ab".
  4331.  
  4332. * constant                                            internal+external
  4333. The indefinite integral constant. It only appear on solving differential
  4334. equation, be omitted on indefinite integral.
  4335. See also: dslove, pi, e.
  4336.  
  4337. * cos                                                 internal + external
  4338. cos(x) is the cosine function of x. The angle x is measured in radians
  4339. (multiply by degree to convert from degrees). x can be complex numbers.
  4340. See also: acos, sec.
  4341.  
  4342. * cosh                                                external
  4343. cosh(x) is the hyerbolic cosine function of x.
  4344. cosh(x)=(exp(x)+exp(-x))/2. x can be complex numbers.
  4345. See also: acosh.
  4346.  
  4347. * cot                                                 external
  4348. cot(x) is the cotangent function of x. The angle x is measured in radians.
  4349. (multiply by degree to convert from degrees). cot(x)=1/tan(x).
  4350. See also: acot, tan.
  4351.  
  4352. * coth                                                external
  4353. coth(x) is the hyerbolic cotangent function of x. coth(x)=1/tanh(x).
  4354. See also: acoth, tanh.
  4355.  
  4356. * csc                                                 external
  4357. csc (x) is the cosecant function of x. The angle x is measured in 
  4358. radians (multiply by degree to convert from degrees). csc(x)=1/sin(x)
  4359. x can be complex numbers.
  4360. See also: acsc, sin.
  4361.  
  4362. * csch                                                external
  4363. csch(x) is the hyperbolic cosecant function of x. csch(x)=1/sinh(x).
  4364. x can be complex numbers.
  4365. See also: acsch, sinh.
  4366.  
  4367. * c_inf                                               internal
  4368. The complex infinite, both real and imaginary parts of complex numbers 
  4369. are infinity, as the built-in constant. complex_inf=inf+inf*i, inf-inf*i,
  4370. -inf+inf*i, or -inf-inf*i.
  4371. See also: inf, zero.
  4372.  
  4373. * d                                                   internal + external
  4374. d() gives the partial derivative.                     
  4375.  
  4376. d(y,x)                                                internal
  4377. It differentiate y with respect to x.
  4378. e.g. d(x^2,x) gives 2*x.
  4379. d(f(x),x) is the same as f'(x) .
  4380. e.g. d(sin(x),x) gives cos(x).
  4381.  
  4382. d(y, x, n)                                            external
  4383. It gives the n-th order derivative of y with respect to an undefined
  4384. variable x.
  4385. e.g. d(sin(x),x,2) gives -sin(x).
  4386.  
  4387. See also: diff, f'(x), lim, inte, ninte.
  4388.  
  4389. * degree                                               external
  4390. degree gives the number of radians in one degree. degree=pi/180.
  4391. You can multipy by degree to convert from degree to radians. 
  4392. See also: pi.
  4393. e.g. 45*degree, sin(45*degree).
  4394.  
  4395. * deno                                               internal
  4396. deno(x) gives denominator of x. It only works for rational number.
  4397. See also: nume.
  4398. e.g. deno(2/3) gives 3.
  4399.  
  4400. * diff                                                external
  4401. diff(y, x = x0) differentiates y when x = x0.
  4402. See also: d, inte, lim.
  4403. e.g. diff(x^6, x = 1) gives 6.
  4404.  
  4405. * div                                                 internal
  4406. div(a,b) divides a by b in integer.
  4407. See also: mod.
  4408. e.g. div(5,2) gives 2, mod(5,2) gives 1.
  4409.  
  4410. * discont                                             internal
  4411. The discontinuity. If f(x0) gives discont, the function has a
  4412. discontinuity and only has the one-sided value at x=x0. You should
  4413. evaluate its left-sided or right-sided value by f(x0-zero) or 
  4414. f(x0+zero).
  4415. See also: zero, inf.
  4416. e.g.
  4417. IN:  f(x_) := 1/x+1
  4418. IN:  f(0)
  4419. OUT: discont
  4420. IN:  f(0+zero)
  4421. OUT: inf
  4422.  
  4423. * do                                                  internal
  4424. do(expr, x,xmin,xmax,dx) evaluates expr with the x looping from xmin 
  4425. to xmax on step dx.
  4426. See also: repeat, list.
  4427. e.g.
  4428. IN:  x:=1, do(x:=x+1, j,1,5,1)
  4429. OUT: x := 5
  4430.  
  4431. * done                                                internal
  4432. It indicates that the command has been done.
  4433. See also: assumed, cleared.
  4434.  
  4435. * dotplot                                             external
  4436. dotplot(y, x) plots y with dots.
  4437. dotplot(y, x,xmin,xmax)
  4438. dotplot(y, x,xmin,xmax,ymin,ymax)
  4439. See also: plot, polar.
  4440. e.g. dotplot(x^3, x)
  4441.  
  4442. * dsolve                                              external
  4443. dsolve(y'(x)=f(x,y), y(x), x) solves the first order variables 
  4444. separable and linear differential equations. The y'(x) must be 
  4445. alone on the left hand side of the equations. 
  4446. See also: solve, nsolve.
  4447. e.g. dsolve(y'(x) = sin(x), y(x), x)
  4448.  
  4449. * E                                                   internal
  4450. E is the exponential part of a floating point number. 
  4451. See also: e, exp.
  4452. e.g. 1.1E2 is the same as 1.1*10^2.
  4453.  
  4454. * e                                                   internal + external
  4455. (1) e is the exponential constant (baes of natural logarithms), 
  4456. e=2.718..., the built-in constant, e is converted to 2.718... when the
  4457. switch numeric:=on. e^x is the same as exp(x).
  4458. e.g. e^2, e^x.
  4459. (2) e is the exponential part of a floating point number, the same as E.
  4460. e.g. 1.1e2 is the same as 1.1E2.
  4461. See also: E, exp.
  4462.  
  4463. * ei                                                  external
  4464. ei(x) is the exponential integral function Ei(x),
  4465. ei(x) = inte(e^t/t, t,-inf,x), ei'(x) = e^x/x. 
  4466.  
  4467. ei(n,x) is the incomplete exponential integral function, 
  4468. ei(n,x) = inte(t^n*e^t, t,-inf,x), d(ei(n,x),x) = x^n*e^x, ei(-1, x) =
  4469. ei(x), ei(0,x) = e^x.
  4470. See also: gamma, erf, ci, si, li.
  4471.  
  4472. * ellipse                                             internal
  4473. ellipse(x,y,angle1,angle2,XRadius,YRadius) draws an elliptical arc from
  4474. angle1 to angle2 with XRadius and YRadius as the horizontal and vertical
  4475. axes at point(x,y). The angles are counter-clockwise with 0 degrees at
  4476. o'clock, 90 degrees at 12 o'clock, and so on.
  4477. it only works on graphics mode.
  4478. See also: arc, ellipse, line, lineto, linerel, putpixel.
  4479. e.g.
  4480. IN:  graph, ellipse(100,100,0,180,200,100), readchar, text
  4481.  
  4482. * else                                                external
  4483. comma. The same as comma ,.
  4484. The 6 keywords: from, to, step, then, else, until are the same as comma ,.
  4485. See also: from, to, step, then, until, ,.
  4486.  
  4487. * eval                                                internal
  4488. eval(y) evaluates y. It is only used in definition of a function.
  4489. e.g.
  4490. IN:  f(x_):= eval(sin'(x))
  4491. OUT: f(x_) := cos(x).
  4492.  
  4493. * erf                                                 external
  4494. erf(x) is the error function of x. It is the probability integral 
  4495. function or the integral of the Gaussian distribution. erf(x) =
  4496. 2/sqrt(pi)*inte(exp(-t^2),t,0,x), d(erf(x),x) = 2/sqrt(pi)*e^(-x^2).
  4497. See also: ei, gamma, ci, si.
  4498.  
  4499. * exp                                                 internal
  4500. exp(x) is the exponential function of x (base of e). The same as e^x, 
  4501. e=2.718... It is the inverse to ln(x). x can be complex numbers.
  4502. See also: e, E.
  4503.  
  4504. * expand                                              internal
  4505. (1) expand(y)       expands out products and positive powers in y.
  4506.             expand() works only on positive integer powers.
  4507. See also: factor.
  4508. e.g. expand((a+b)^2) gives a^2 + 2*a*b + b^2.
  4509.  
  4510. (2) the switch of expansion.
  4511. expand:=on       e.g. c*(a+b) to c*a+c*b.
  4512. expand:=off      disable expansion, this is default.
  4513. See also: expandexp.
  4514.  
  4515. * expandexp                                           internal
  4516. The switch of exponential expansion.
  4517. expandexp:=on       e.g. c^(a+b) to c^a*c^b.
  4518. expandexp:=off      disable exponential expansion, this is default.
  4519. See also: expand.
  4520.  
  4521. * f'(x)                                               external
  4522. f'(x) differentiates f(x) with respect to x. f'(x)=d(f(x),x). f'(x0) is
  4523. diferent from diff(f(x), x=x0): f'(x0) first evaluates f(x0), then
  4524. differentiates the value of f(x0); diff(f(x), x=x0) first differentates
  4525. f(x), then replace x = x0.
  4526. See also: d.
  4527. e.g. sin'(x) gives cos(x).
  4528.  
  4529. * fac                                                 external
  4530. fac(n) is the factorial function of n. The same as n!. 
  4531. See also: n!.
  4532. e.g. fac(3) gives 6.
  4533.  
  4534. * factor                                              internal + external
  4535. factor(y)                                             internal
  4536. It factorizes y.
  4537. See also: expand, expandexp.
  4538. e.g.
  4539. IN:  factor(a^2 + 2*a*b + b^2)
  4540. OUT: (a+b)^2
  4541.  
  4542. factor(y, x)                                          external
  4543. It factorizes y for x. y must be polynomial with order < 5.
  4544. e.g.
  4545. IN:  factor(x^2+5*x+6, x)
  4546. OUT: (2+x) (3+x)
  4547.  
  4548. * fortran                                             internal
  4549. fortran is the value of the switch output. It forces the output in 
  4550. Fortran format. 
  4551. See also: output, basic, math, prolog, on, off.
  4552. e.g. output:=fortran.
  4553.  
  4554. * frac                                                external
  4555. frac(x) gives the fractional part of number x. frac(x)=x-trunc(x).
  4556. See also: int, trunc.
  4557. e.g. frac(2.4) gives 0.4.
  4558.  
  4559. * from                                                external
  4560. The comma, the same as the comma (,).
  4561. The 6 keywords: from, to, step, then, else, until are the same as comma ,.
  4562. See also: to, step, then, else, until , ,.
  4563.  
  4564. * gamma                                               external
  4565. gamma(n) is the gamma function Γ(n), 
  4566. gamma(n) = inte(t^(n-1)*e^(-t), t,0,inf), gamma(n) = (n-1)!. 
  4567.  
  4568. gamma(n,x) is the incomplete gamma function, gamma(n,x) =
  4569. inte(t^n*e^(-t), t,0,x), d(gamma(n,x),x) = x^n*e^(-x).
  4570. gamma(n,0) = 0, gamma(n,inf) = gamma(n+1) = n!.
  4571. gamma(n,x) is similar to gamma(n), but its power term is t^n, instead 
  4572. of t^(n-1).
  4573. See also: ei, erf, ci, si, li.
  4574.  
  4575. * gcd                                                 external
  4576. gcd(a,b) gives the greatest commom dividor of a and b.
  4577. e.g. gcd(2,4) gives 2.
  4578.  
  4579. * getbkcolor                                          internal
  4580. getbkcolor gets background color on the graph screen. It must be on the
  4581. graph mode.
  4582. See also: getbkcolor, getcolor, setbkcolor, setcolor.
  4583.  
  4584. * getcolor                                            internal
  4585. getbkcolor gets foreground color on the graph screen. It must be on the
  4586. graph mode.
  4587. See also: getbkcolor, getcolor, setbkcolor, setcolor.
  4588.  
  4589. * getmaxx                          internal    
  4590. getmaxx gets the max x of the graphics screen (number of colum of pixel).
  4591. For EGA video, getmaxx gives 640. It must be in graph mode.
  4592. See also: getmaxx, getmaxy, getx, gety.
  4593.  
  4594. * getmaxy                          internal    
  4595. getmaxy gets the max y of the graphics screen (number of rows of pixel).
  4596. For EGA video, getmaxy gives 350. It must be in graph mode.
  4597. See also: getmaxx, getmaxy, getx, gety.
  4598.  
  4599. * getx                              internal    
  4600. getx gets the x of the current point(x,y) on the graphics screen (number
  4601. of colum of pixel). For EGA video, 0 <= getx < 640. It must be in graph
  4602. mode.
  4603. See also: getmaxx, getmaxy, getx, gety.
  4604.  
  4605. * gety                              internal    
  4606. gety gets the y of the current point(x,y) on the graphics screen (number
  4607. of rows of pixel). For EGA video, 0 <= gety < 350. It must be in graph
  4608. mode.
  4609. See also: getmaxx, getmaxy, getx, gety.
  4610.  
  4611. * graph                             internal
  4612. graph is the graph mode. It initializes the graphics system and sets the
  4613. screen to graphics mode. You can close graphics mode and go back the text
  4614. mode by the text command. It is useful to freez the graphics by the
  4615. command readchar before back to the text mode.
  4616. See also: text.
  4617. e.g. graph, line(100,100,300,300), readchar, text
  4618.  
  4619. * i                                                   internal
  4620. i represents the imaginative unit of the complex numbers, i=sqrt(-1), 
  4621. as the built-in constant. 
  4622. See also: re, im, sign, arg.
  4623. e.g. 1+2*i.
  4624.  
  4625. * if                                                  internal
  4626. if(condition then x)
  4627. It gives x if condition evaluates to 1, or left unevaluated otherwise.
  4628.  
  4629. if(condition then x else y)     
  4630. It gives x if condition evaluates to 1, y if it evaluates to 0, or 
  4631. left unevaluated if the condition is neither 1 nor 0.
  4632. Note that the words then and else can be replaced by comma ,.
  4633. It is useful in definition of the use-defined function to left the
  4634. function unevaluted if the argument of the function is not number.
  4635. See also: isnumber.
  4636. e.g.
  4637. IN:  f(x_):=if(isnumber(x), 1)
  4638. IN:  f(x), f(10)
  4639. OUT: f(x), 1
  4640.  
  4641. * im                                                  internal 
  4642. im(x) gives the imaginative part of the complex number x. 
  4643. See also: re, abs, sign, arg.
  4644. e.g. im(1+2*i) gives 2.
  4645.  
  4646. * inf                                                 internal
  4647. inf is a positive infinity, as the built-in constant.
  4648. See also: c_inf, zero.
  4649. e.g. inf+2*inf gives inf, 1/inf gives 0.
  4650.  
  4651. * infsum                                              external
  4652. infsum(y,x) is infinite sum.
  4653. See also: partsum, sum.
  4654.  
  4655. * int                                                 external
  4656. int(x) gives the integer part of number x. int(x)=trunc(x).
  4657. See also: frac, trunc.
  4658. e.g. int(2.3) gives 2.
  4659.  
  4660. * inte                                                internal + external
  4661. inte() is the integral function.
  4662.  
  4663. inte(y,x)                                             internal
  4664. It finds the indefinite integral of y with respect to an undefined
  4665. variable x.
  4666.  
  4667. inte(y,x,xmin,xmax)                                   external
  4668. It finds the definite integral of y with respect to the variable x taken
  4669. from x=xmni to x=xmax.
  4670.  
  4671. inte(y,x,xmin,x1,xmax)                                external
  4672. It finds the definite integral of y from x=xmin to x=x1, then from x=x1
  4673. to x=xmax. x1 is singularity.
  4674. See also: ninte.
  4675.  
  4676. * iscomplex                                           internal
  4677. iscomplex(x) tests if x is complex. It gives 1 if x is complex, or 0
  4678. otherwise.
  4679. See also: iscomplex, iseven, isfree, isinteger, islarger, isless, islist,
  4680. isodd, isreal, isratio, issame, isnumber.
  4681. e.g. iscomplex(i) gives 1.
  4682.  
  4683. * iseven                                              internal
  4684. iseven(x) gives 1 if x is an even integer, or 0 otherwise.
  4685. You can assume x is even by iseven(x) := 1.
  4686. See also: iscomplex, iseven, isfree, isinteger, islarger, isless, islist,
  4687. isodd, isreal, isratio, issame, isnumber.
  4688. e.g. iseven(2) gives 1, iseven(3) gives 0.
  4689.  
  4690. * isfree                                              internal
  4691. isfree(y,x) gives 1 if y is free of x, or 0 otherwise.
  4692. You can assume y is free of x by iseven(y,x) := 1.
  4693. See also: iscomplex, iseven, isfree, isinteger, islarger, isless, islist,
  4694. isodd, isreal, isratio, issame, isnumber.
  4695. e.g. isfree(a*b,x) gives 1, isfree(x*y,x) gives 0.
  4696.  
  4697. * isinteger                                           internal
  4698. isinteger(x) gives 1 if x is an integer, or 0 otherwise.
  4699. You can assume x is integer by isinteger(x) := 1.
  4700. See also: iscomplex, iseven, isfree, isinteger, islarger, isless, islist,
  4701. isodd, isreal, isratio, issame, isnumber.
  4702. e.g. isinteger(2) gives 1, isinteger(3.2) gives 0.
  4703.  
  4704. * islarger                                            external
  4705. islarger(a,b) gives 1 if a is larger than b, or 0 otherwise. It is extent
  4706. of operator >. It can compare 2 complex number, but the operator > cannot.
  4707. See also: iscomplex, iseven, isfree, isinteger, islarger, isless, islist,
  4708. isodd, isreal, isratio, issame, isnumber.
  4709. isless.
  4710. e.g.
  4711. IN:  islarger(1+i, 1-i)         # is 1+i larger than 1-i ?
  4712. OUT: 1                          # yes
  4713.  
  4714. * isless                                              external
  4715. isless(a,b) gives 1 if a is less than b, or 0 otherwise. It is extent
  4716. of operator <. It can compare 2 complex number, but the operator < cannot.
  4717. See also: iscomplex, iseven, isfree, isinteger, islarger, isless, islist,
  4718. isodd, isreal, isratio, issame, isnumber.
  4719. e.g.
  4720. IN:  isless(1+i, 1-i)           # is 1+i less than 1-i ?
  4721. OUT: 0                          # no
  4722.  
  4723. * islist                                              internal
  4724. islist(x) gives 1 if x is a list, or 0 otherwise.     
  4725. You can assume x is a list by islist(x) := 1.
  4726. See also: iscomplex, iseven, isfree, isinteger, islarger, isless, islist,
  4727. isodd, isreal, isratio, issame, isnumber.
  4728. e.g. islist([a]) gives 1, islist(3.2) gives 0.
  4729.  
  4730. * isodd                                               internal
  4731. isodd(x) gives 1 if x is an odd integer, or 0 otherwise.
  4732. You can assume x is odd by isodd(x) := 1.
  4733. See also: iscomplex, iseven, isfree, isinteger, islarger, isless, islist,
  4734. isodd, isreal, isratio, issame, isnumber.
  4735. e.g. isodd(3) gives 1, isodd(2) gives 0.
  4736.  
  4737. * isratio                                             internal
  4738. isratio(x) gives 1 if x is ratio, or 0 otherwise.
  4739. You can assume x is ratio by isodd(x) := 1.
  4740. See also: iscomplex, iseven, isfree, isinteger, islarger, isless, islist,
  4741. isodd, isreal, isratio, issame, isnumber.
  4742. e.g. isratio(2/3) gives 1, isratio(2) gives 0.
  4743.  
  4744. * isreal                                              internal
  4745. isreal(x) gives 1 if x is real, or 0 otherwise.
  4746. You can assume x is real by isreal(x) := 1.
  4747. See also: iscomplex, iseven, isfree, isinteger, islarger, isless, islist,
  4748. isodd, isreal, isratio, issame, isnumber.
  4749. e.g. isreal(2.2) gives 1, isreal(a) gives 0.
  4750.  
  4751. * issame                                               internal
  4752. issame(a,b) gives 1 if a is the same as b, or 0 otherwise.
  4753. You can assume a is the same as b by issame(a,b) := 1.
  4754. It is simliar to a==b, but a == b left unevaluated if a <> b.
  4755. See also: iscomplex, iseven, isfree, isinteger, islarger, isless, islist,
  4756. isodd, isreal, isratio, issame, isnumber.
  4757. e.g. issame(3,3) gives 1, issame(3,2) gives 0.
  4758.  
  4759. * isnumber                                            internal
  4760. isnumber(x) gives 1 if x is a number, or 0 otherwise.
  4761. You can assume x is a number by isnumber(x) := 1.
  4762. See also: iscomplex, iseven, isfree, isinteger, islarger, isless, islist,
  4763. isodd, isreal, isratio, issame, isnumber.
  4764. e.g. isnumber(2.2) gives 1, isnumber(a) gives 0.
  4765.  
  4766. * laplace                                             external
  4767. laplace(y,x) gives Laplace transform of y.
  4768. e.g. laplace(sin(t),t) gives 1/(1+t^2).
  4769.  
  4770. * last                                                internal
  4771. last        represents the last output, as the built-in variable.
  4772. last[1]     the first element of the last output list.
  4773.  
  4774. * left                                                internal
  4775. left(x=a) gives the left-hand side of an equation and inequality. 
  4776. See also: righ.
  4777. e.g. left(x+y=2) gives x+y, left(a>b) gives a.
  4778.  
  4779. * length                                              internal
  4780. length([a]) gives the length of a list and string (the number of member
  4781. in the list and string).
  4782. See also: list, string.
  4783. e.g. length([a,b]) gives 2, length("abc") gives 3.
  4784.  
  4785. * li                                                   external
  4786. li(x) is the ln integral function, 
  4787. li(x) = inte(1/ln(t), t,0,x) = ei(ln(x)), li'(x)=1/ln(x). 
  4788.  
  4789. li(n,x) is the incomplete ln integral function, li(n,x) =
  4790. inte(ln(t)^n, t,0,x) = ei(n,ln(x)), d(li(n,x),x) = ln(x)^n.
  4791. li(n,0) = 0.
  4792. See also: ei, gamma, erf, ci, si, li.
  4793.  
  4794. * lim                                                 internal
  4795. lim(y, x = x0)
  4796. It finds the limiting value of y when x = x0.
  4797.  
  4798. lim(y, x = x0+zero)
  4799. It finds the right-sided limit as x approches to x0 from the positive
  4800. (+inf) direction (x = x0+).
  4801.  
  4802. lim(y, x = x0-zero)
  4803. It finds the left-sided limit as x approches to x0 from the negative
  4804. (-inf) direction (x = x0-).
  4805.  
  4806. Note that the correct answers are usually for the indeterminate forms:
  4807. 0/0, inf/inf, 0*inf, 0^0, inf^0. 
  4808. See also: zero, replace.
  4809. e.g. lim(sin(x)/x, x = 0) gives 1.
  4810.  
  4811. * line                                                internal
  4812. line(x1,y1,x2,y2) draws a line from point (x1,y1) to (x2,y2).
  4813. line() is graphics function so it only works on graphics mode.
  4814. See also: arc, lineto, linerel, putpixel.
  4815. e.g. graph, line(100,100,200,200), readchar, text
  4816.  
  4817. * lineto                                              internal
  4818. lineto(x2,y2) draws a line from the current point (x,y) to (x2,y2).
  4819. lineto() is graphics function so it only works on graphics mode.
  4820. See also: arc, line, linerel, putpixel.
  4821. e.g. graph, moveto(100,100), lineto(200,200), readchar, text
  4822.  
  4823. * linerel                                             internal
  4824. linerel(dx,dy) draws a line from the current point (x,y) to (x+dx,y+dy).
  4825. linerel() is graphics function so it only works on graphics mode.
  4826. See also: arc, line, lineto, putpixel.
  4827. e.g. graph, moveto(100,100), linerel(100,100), readchar, text
  4828.  
  4829. * list                                                internal
  4830. list(y,x,xmin,xmax,dx)  lists every y when x runs from xmin to xmax on
  4831. step dx. list() is similar to do(), but list() outputs every result at
  4832. every step dx, and cannot accept assignment as y.
  4833. See also: do, repeat, table.
  4834. e.g. [ list(x^2, x,1,3,1) ] gives [1,4,9].
  4835.  
  4836. * listsum                                             external
  4837. listsum(x) converts a list into sum.
  4838. See also: average, max, min.
  4839. e.g. listsum([a,b] gives a+b.
  4840.  
  4841. * ln                                                  internal+external
  4842. ln(x) is the natural logarithmic function of x. Its base is e. It is 
  4843. the inverse to exp(x). Note that if it has multi-values, the ln(x) 
  4844. only gives a principle value (P.V.) and other values are 
  4845. P.V.+2*k*pi*i (where k=0, 1, 2,..., -1, -2, ...).
  4846. If x is complex number (x=A+B*i) then
  4847. ln(x)=ln(abs(x))+i*atan2(A,B).
  4848. See also: exp.
  4849. e.g. ln(e) gives 1.
  4850.  
  4851. * local                                               internal
  4852. local(a,b) declares the variables a and b are local varirables in block().
  4853. local() must be the last arguement within block().
  4854. See also: block
  4855. e.g. f(x_) := block(p:=x^2,p,local(p))
  4856.  
  4857. * log10                                               external
  4858. log10(x) is log with base of 10. log10(x) = ln(x)/ln(10).
  4859. See also: ln.
  4860. e.g. log10(10) gives 1.
  4861.                               
  4862. * lowercase                                           internal
  4863. The swicth of the case conversion.
  4864. lowercase:=on
  4865. It converts the letters to lower-case letters.
  4866. e.g. SIN(x) is converted to sin(x).
  4867.  
  4868. lowercase:=off
  4869. It disables the case convertion, this is default.
  4870. It only effects the input.
  4871.  
  4872. * math                                                internal
  4873. math is a value of the switch output. It forces output in math symbolic
  4874. notation.
  4875. See also: output, off, on, basic, fortran, prolog.
  4876. e.g. output:=math.
  4877.  
  4878. * max                                                 external
  4879. max(x) gives maximum of x.                            
  4880. See also: min, average, listsum, length.
  4881. e.g. max([1,2,3] gives 3.
  4882.  
  4883. * member                                              internal
  4884. member(list,n) gives n-th member of list.
  4885. See also: length, last.
  4886. e.g. member([a,b,c], 2) gives b.
  4887.  
  4888. * min                                                 external
  4889. min(x) gives minimum of x.                            
  4890. See also: max, average, listsum, length.
  4891. e.g. min([1,2,3]) gives 1.
  4892.  
  4893. * mod                                                 internal
  4894. mod(m,n) gives the remainder on division of m by n.
  4895. See also: div.
  4896. e.g. mod(4,3) gives 1.
  4897.  
  4898. * moveto                                              internal
  4899. moveto(x2,y2) moves from the current x,y to x2,y2.
  4900. it is graphics function so it only works on graphics mode.
  4901. See also: arc, line, linerel, putpixel.
  4902. e.g. graph, moveto(100,100), lineto(200,200), readchar, text
  4903.  
  4904. * moverel                                             internal
  4905. moverel(dx,dy) moves from the current x,y to x+dx,y+dy.
  4906. it is graphics function so it only works on graphics mode.
  4907. See also: arc, line, lineto, putpixel.
  4908. e.g. graph, moverel(10,10), linerel(100,100), readchar, text.
  4909.  
  4910. * mult                                                internal+external
  4911. mult(x)                                               internal
  4912. It gives a list of multipliers of x. It converts product into a list of
  4913. multipliers.
  4914. e.g. mult(a*b) gives [a,b].
  4915.  
  4916. mult(x, n)                                            external
  4917. It gives the n-th multiplier of x if possible.
  4918. mult(x_,n_) := member(mult(x), n).
  4919. e.g. mult(a*b*c, 1) gives a.
  4920. See also: mult, term, type.
  4921.  
  4922. * newline                                             internal
  4923. newline writes a new line. The output following the command newline will
  4924. be written on next line.
  4925.  
  4926. * ninte                                               external
  4927. ninte(y, x from xmin to xmax) numerically integrates y.
  4928. See also: inte.
  4929. e.g. ninte(x^2, x from 0 to 1) gives
  4930.  
  4931. * nlim                                                external
  4932. nlim(y, x=x0) numerically limits y when x=x0.
  4933. See also: lim.
  4934. e.g. nlim(sin(x)/x, x=0) gives 1.
  4935.  
  4936. * not                                                 external
  4937. not(x) is logic not. It gives 1 if x=0, or 0 if x=1.
  4938. See also: and, not.
  4939. e.g. not(1) gives 0, not(0) gives 1.
  4940.  
  4941. * nsolve                                              external
  4942. nsolve(cos(x)=x, x)
  4943. It numerically solves equation with default initial x0=1.
  4944.  
  4945. nsolve(x^2=1, x,x0)
  4946. It numerically solves the equation with initial x0.
  4947. It only gives a root near x0 if equation has multi roots.
  4948. See also: solve, dsolve.
  4949. e.g. nsolve(sin(x)=0, x,3) gives 3.14.
  4950.  
  4951. * null                                                internal
  4952. null is a symbol used to indicate the absence of an expression or a
  4953. result. When it appreas as an output expression, no output is printed.
  4954. See also: block, output.
  4955. e.g. block(output:=on, null).
  4956.  
  4957. * num                                                 internal
  4958. num(x) gives the numeric value of x. It converts all numbers
  4959. to the real number.
  4960. See also: numeric.
  4961. e.g. num(pi) gives 3.1416.
  4962.  
  4963. * number                                              internal
  4964. number("1") converts string "1" into number 1.
  4965. See also: string.
  4966.  
  4967. * nume                                                internal
  4968. nume(x) gives numerator of x. It only works for rational number.
  4969. See also: deno.
  4970. e.g. nume(2/3) gives 2.
  4971.  
  4972. * numeric                                           internal
  4973. The switch of numeric calculation.
  4974.  
  4975. numeric:=on       numeric computation.
  4976. numeric:=off      disable numeric computation, this is default.
  4977.  
  4978. See also: num.
  4979.  
  4980. * off                                                 internal
  4981. When the switch is set to off, it is inactive.        
  4982. e.g. numeric:=off, output:=off, expand:=off
  4983.  
  4984. * on                                                  internal
  4985. When the switch is set to on, it is active. 
  4986. See also: off, output.
  4987. e.g. numeric:=on, expand:=on, expandexp:=on, lowercase:=on,
  4988. output:=on
  4989.  
  4990. * openfile                                            internal
  4991. openfile("filename") opens the disk file "filename" for writing. The 
  4992. filename is any MS-DOS file name. After doing something, the file must 
  4993. be closed by closefile("filename").
  4994. See also: closefile, readfile.
  4995.  
  4996. * or                                                  internal
  4997. The logic operator. The result is 1, 0 or unevaluated.
  4998. See also: and.
  4999. e.g. 1 or 0 gives 1.
  5000.  
  5001. * order                                               external
  5002. order(y, x) gives the highest order of x in y. y must be polynomial with
  5003. order < 5.
  5004. See also: coef, coefall.
  5005. e.g.
  5006. IN:  order(x^2+5*x+6, x)
  5007. OUT: 2
  5008.  
  5009. * output                                              internal
  5010. The switch of the output format. 
  5011. See also: math, basic, fortran, on, off.
  5012. e.g. output:=basic, output:=fortran, output:=math, output:=on, output:=off.
  5013.  
  5014. * oval                                                external
  5015. oval(x,y, xRadius,yRadius) draws an oval at point(x,y) with x-radius and
  5016. y-radius. It must be in graphics mode.
  5017. See also: ellipse.
  5018. e.g. graph, oval(200,200,200,100), readchar, text
  5019.  
  5020. * partsum                                             external
  5021. partsum(y,x) gives partial sum of y (symbolic sum).
  5022. See also: infsum, sum.
  5023. e.g. partsum(n^2, n) gives 1/6 n (1 + n) (1 + 2 n)
  5024.  
  5025. * pi                                                  external
  5026. pi=3.1416..., as the built-in constant, pi is converted to 3.1416... 
  5027. when the switch numeric:=on.
  5028. See also: e.
  5029.  
  5030. * plot                                                external
  5031. plot(y,x) plots a function y=f(x) in xy plane with the default values
  5032. x from -5 to 5, and y from -5 to 5.
  5033.  
  5034. plot(y,x,xmin,xmax)
  5035. plot(y,x,xmin,xmax,ymin,ymax)
  5036.  
  5037. See also: dotplot, polar.
  5038. e.g. plot(x^3,x)
  5039.  
  5040. * polar                                                external
  5041. polar(r,t) plots a function r=f(t) in polar coordinates with the default
  5042. values t from 0 to 2 pi, and r from 0 to 5.
  5043.  
  5044. polar(r,t,tmin,tmax)
  5045. polar(r,t,tmin,tmax,rmin,rmax)
  5046.  
  5047. See also: dotplot, polar.
  5048. e.g. polar(1,t)
  5049.  
  5050. * power                                               internal
  5051. power(x^n) gives the power n.
  5052. See also: base, power, type.
  5053. e.g. base(x^n) gives x, type(x^n) gives "^", power(x^n) gives n.
  5054.  
  5055. * prod                                                external
  5056. prod(f,x,xmin,xmax)     with the default step dx = 1.
  5057. prod(f,x,xmin,xmax,dx)  evaluates the product of f when x runs from 
  5058.             xmin to xmax with step dx.
  5059. See also: sum, list, table.
  5060.  
  5061. * prolog                                              internal
  5062. prolog is the value of the switch output. It forces the output in the
  5063. Prolog format, i.e. internal form.
  5064. See also: output, basic, fortran.
  5065. e.g.
  5066. IN:  outout:=prolog
  5067. IN:  a+b
  5068. OUT: plus(var("a"),var("b"))
  5069.  
  5070. * psolve                                              external
  5071. psolve(f(x), x) solves polynomial f(x)=0 for x. The order of polynomial <3.
  5072. See also: solve, nsolve, dsolve.
  5073. e.g. psolve(x^2+5*x+6, x) gives [-2,-3].
  5074.  
  5075. * putpixel                          internal
  5076. pupixel(x,y,color) puts pixel on the point (x,y) with color.
  5077. It only works on the graphics mode.
  5078. See also: line, lineto, linerel.
  5079. e.g. graph, putpixel(100,100,red), readchar, text
  5080.  
  5081. * random                                              internal
  5082. random          gives a uniformly distributed pseudorandom real in 
  5083.         the range 0 to 1.
  5084.  
  5085. random(n)       gives a uniformly distributed pseudorandom integer
  5086.         in the range 0 to n. (n < 36000).
  5087. e.g. random gives 0.11111, random(5) gives 2.
  5088.  
  5089. * ratio                                               internal
  5090. ratio(x) converts x to a rational number. 
  5091. See also: num.
  5092. e.g. ratio(0.5) gives 1/2.
  5093.  
  5094. * re                                                  internal
  5095. re(x) gives the real part of the complex number x. 
  5096. See also: im, abs, sign.
  5097. e.g. re(1+2*i) gives 1.
  5098.  
  5099. * readchar                          internal
  5100. readchar reads a charactor from the keyboard. It is useful to freez
  5101. the graphics by readchar. This is similar to pause, but it returns the
  5102. charactor from the keyboard as its value.
  5103. See also: readchar, readfile, readln, writes.
  5104. e.g. graph, line(100,100,300,300), readchar, text
  5105.  
  5106. * readfile                                            internal
  5107. readfile("file") reads (or runs) the file named "file". The filename
  5108. is any MS-DOS file name.
  5109. See also: readchar, readfile, readline, writes.
  5110.  
  5111. * readline                                              interanl
  5112. readline reads a line of strings from the keyboard.
  5113. See also: readchar, readfile, readline, writes.
  5114.  
  5115. * remove                                              internal
  5116. remove("b", "ab") removes string "a" from string "ab".
  5117. See also: concate.
  5118. e.g. remove("b", "ab") gives "a".
  5119.  
  5120. * repeat                                              internal
  5121. repeat(expr until test) repeats expr until test gives 1.
  5122. See also: do, list.
  5123. e.g.
  5124. IN:  x:=1, repeat(x:=x+1, x>5)
  5125. OUT: x := 6
  5126.  
  5127. * reverse                                             external
  5128. reverse(x) reverses a list x in reverse order.
  5129. See also: member.
  5130. e.g. reverse([1,2,3]) gives [3,2,1].
  5131.  
  5132. * right                                               internal
  5133. right(x=a) gives the right hand side of an equation. 
  5134. See also: left, solve.
  5135. e.g. right(x+y = 3) gives 3.
  5136.  
  5137. * root                                                external
  5138. root(x,n) gives all branch of n-th root. The first member of list is the
  5139. P.V.
  5140. e.g. root(4,2) gives [2,-2].
  5141.  
  5142. * round                                              internal
  5143. round(x) converts x to the rounded integer closest to x. 
  5144. See also: trunc.
  5145. e.g. round(2.4) gives 2, round(2.5) gives 3.
  5146.  
  5147. * sec                                                 external
  5148. sec(x) is the secant function of x. The angle x is measured in 
  5149. radians (multiply by degree to convert from degrees). sec(x)=1/cos(x).
  5150. See also: asec, cos.
  5151.  
  5152. * sech                                                external
  5153. sech(x) is the hyperbolic secant function of x. sech(x)=1/cosh(x).
  5154. See also: asech, cosh.
  5155.  
  5156. * series                                              external
  5157. series(y, x)            gives series expansion of y at x=0 to order of 5.
  5158. series(y, x, order)     gives series expansion of y at x=0 to order.
  5159. See also: sum.
  5160. e.g. series(sin(x),x) gives x - 1/6*x^3 + 1/120*x^5.
  5161.  
  5162. * sequence                                            internal
  5163. sequence(x) gives a sequence. It only work on a list.
  5164. See also: type, argue.
  5165. e.g. sequence( [a,b] ) gives a,b
  5166.  
  5167. * setbkcolor                                          internal
  5168. setbkcolor(x) sets the background color, where the arguement value is 0 
  5169. to 15, or the color word. The default background color is 0 (black).
  5170. It only works on graphics mode.
  5171. e.g. graph, setbkcolor(red), line(100,100,200,200), readchar,
  5172. text.
  5173. See also: setcolor.
  5174.  
  5175. * setcolor                                            internal
  5176. setcolor(x) sets the foreground color, where the arguement value is 0
  5177. to 15, or the color word. The default foreground color is 7 (white).
  5178. It only works on graphics mode.
  5179. e.g. graph, setcolor(red), line(100,100,200,200), readchar, text.
  5180. See also: setbkcolor.
  5181.  
  5182. * setlinestyle                          internal
  5183. setlinestyle(style, direction, thickness) sets the line style, where style 
  5184. is the style name, direction is the line direction, thickness is the 
  5185. thickness of the line.
  5186. it only works on the graphics mode.
  5187. See also: setlinestyle, settextstyle.
  5188. e.g. graph, setlinestyle(2,1,2), line(100,100,300,300), readchar, text
  5189.  
  5190. * settextjustify                                      internal
  5191. settextjusttify(hor,vert) sets text justification values used by writes().
  5192. Text written by writes() after the settextjustify() will be justified
  5193. around the current pointer in the manner specified.
  5194. See also: settextstyle, writes.
  5195.  
  5196. * settextstyle                          internal
  5197. settextstyle(font, direction, size) sets the text style, font, and
  5198. character magnification factor, where font is the font name, direction is
  5199. the text direction, size is the charactor size.
  5200. it only works on the graphics mode.
  5201. e.g. graph, textstyle(2,1,2), writescr("abc"), readchar, text.
  5202. See also: setlinestyle.
  5203.  
  5204. * setviewport                          internal
  5205. setviewport(x1,y1,x2,y2,clip) sets the view port from (x1,y1) to (x2,y2) on 
  5206. the graphics screen. Everything is unvisible if it it out of the (x1,y1) 
  5207. to (x2,y2). It only works on the graphics mode.
  5208. e.g. graph, line(100,100,300,300), setviewport(200,200,300,300,1),
  5209. line(100,200,100,200), readchar, text
  5210. See also: graph, text.
  5211.  
  5212. * si                                                  external
  5213. si(x) is the sin integral, si(x) = inte(sin(x)/x, x).
  5214. See also: ci, ei, gamma, erf.
  5215.  
  5216. * sign                                                 internal
  5217. sign(x) is the sign function of x. Its value is 1, 0 or -1.
  5218.  
  5219.     /  1     if re(x) > 0; or both re(x) = 0 and im(x) > 0.
  5220. sign(x) =  0     if x=0.
  5221.     \ -1    otherwise. 
  5222.  
  5223. the same as the definition by arg(x):
  5224.  
  5225.     / 1     if -pi/2 < arg(x) <= pi/2.
  5226. sign(x) =  0     if x=0.
  5227.     \ -1    otherwise. 
  5228.  
  5229. You can assume x is positive or negative by sign(x) := 1 or sign(x) := -1.
  5230. e.g. sign(2) gives 1, sign(1+i) gives 1.
  5231. See also: abs, arg, re, im, >, <.
  5232.  
  5233. * sin                                                 internal + external
  5234. sin(x) is the sine function of x. The angle x is measured in radians.
  5235. (multiply by degree to convert from degrees).
  5236. See also: asin, csc.
  5237.  
  5238. * sinh                                                external
  5239. sinh(x) is the hyperbolic sine function of x. 
  5240. sinh(x) = (exp(x)-exp(-x))/2.
  5241. See also: asinh, acsch.
  5242.  
  5243. * solve                                               internal
  5244. solve(x^2=0, x)
  5245. It solves a polynomial ordered up to 4.
  5246.  
  5247. solve([expr1=expr2,expr3=expr4], [x,y])
  5248. It solves systems of linear equations.
  5249. It gives all symbolic solutions.
  5250. See also: nsolve.
  5251. e.g. solve(x^2+5*x+6=0, x), solve([x+y=3, x-y=1], [x,y]).
  5252.  
  5253. * sqrt                                                internal
  5254. sqrt(x) is the square root function of x. It is the same as x^0.5.
  5255. It only gives the principal value (P.V.) (sign(sqrt(x)) >= 0).
  5256. root(x,2) gives all branch of square root.
  5257. See also: root, ^.
  5258. e.g. sqrt(4) gives 2, num(sqrt(2*i)) gives 1+i.
  5259.  
  5260. * subs                                                internal
  5261. subs(y, x=x0) substitutes x in y with x0.
  5262. e.g. subs(x^6, x=x0) gives x0^6.
  5263.  
  5264. * sum                                                 external+internal
  5265. sum(f,x,xmin,xmax)                                    external
  5266. It evaluates the sum of f when x runs from xmin to xmax with the default
  5267. step dx=1.
  5268.  
  5269. sum(f,x,xmin,xmax,dx)                                 internal
  5270. It evaluates the sum of f when x runs from xmin to xmax with step dx.
  5271.  
  5272. See also: prod, list, table, infsum, partsum.
  5273. e.g. sum(2^n,n,1,5,1.1), sum(x^n,n,1,5).
  5274.  
  5275. * step                                                external
  5276. step is the comma, the same as the comma , .
  5277. The 6 keywords: from, to, step, then, else, until are the same as comma ,.
  5278. See also: from, to, then, else, until, ,.
  5279.  
  5280. * string                                              internal
  5281. string(x) converts a number x to a string "x".
  5282. See also: number.
  5283. e.g. string(123) gives "123".
  5284.  
  5285. * system                                              internal
  5286. system("DOS") executes the operating system (DOS) command "DOS". 
  5287. e.g. system("dir").
  5288.  
  5289. * table                                               external+internal
  5290. table(f,x)                                            external
  5291. It produces a table of the function values from x=-5 to x=5 with step 1.
  5292.  
  5293. table(f,x,xmin,xmax)                                  external
  5294. It produces a table of the function values from x=-5 to x=5 with the
  5295. default step dx = 1.
  5296.  
  5297. table(f,x,xmin,xmax,dx)                               internal
  5298. It produces a table of the function values when x runs from xmin to xmax
  5299. with step dx.
  5300.  
  5301. table(y[x],x,xmin,xmax,dx)                            internal
  5302. It transforms a list y into a table.
  5303. See also: list, plot.
  5304. e.g. table(x^2,x,1,4,1).
  5305.  
  5306. * tan                                                 internal + external
  5307. tan(x) is the tangent function of x. The angle x is measured in 
  5308. radians (multiply by degree to convert from degrees).
  5309. See also: atan, cot.
  5310.  
  5311. * tanh                                                external
  5312. tanh(x) is the hyperbolic tangent function of x.
  5313. See also: atanh, coth.
  5314.  
  5315. * term                                                internal+external
  5316. term(x)                                               internal
  5317. It gives a list of terms of x. It converts sum into a list of terms.
  5318. e.g. term(a+b) gives [a,b].
  5319.  
  5320. term(x, n)                                            external
  5321. It gives the n-th term of x if possible. term(x_,n_) := member(term(x),n).
  5322. See also: mult, term, type.
  5323. e.g. term(a+b, 1) gives a, term(a+b, 2) gives b, type(a+b) gives "+".
  5324.  
  5325. * text                              internal
  5326. text is the text mode.
  5327. See also: graph.
  5328. e.g.
  5329. IN:  graph, line(100,100,200,200), readchar, text
  5330.  
  5331. * then                                                external
  5332. comma. The same as comma ,.
  5333. The 6 keywords: from, to, step, then, else, until are the same as comma ,.
  5334. See also: from, to, step, else, until, ,.
  5335.  
  5336. * to                                                  external
  5337. to is the comma, the same as the comma (,).
  5338. The 6 keywords: from, to, step, then, else, until are the same as comma ,.
  5339. See also: from, step, then, else, until, ,.
  5340.  
  5341. * trunc                                               internal
  5342. trunc(x) converts x to the truncated integer. 
  5343. See also: round.
  5344. e.g. trunc(2.9) gives 2.
  5345.  
  5346. * type                                                internal
  5347. type(x) gives the type of x. Its value is a string.
  5348.   e.g.
  5349. ------------------------------
  5350. x                   type(x)
  5351.  
  5352. 1                   "integer"
  5353. 1.1                 "real"
  5354. 2/3                 "ratio"
  5355. 1+i                 "complex"
  5356. sin(x)              "sin()"
  5357. [1,2]               "[]"
  5358. a                   "variable"
  5359. a+b                 "+"
  5360. a*b                 "*"
  5361. a^b                 "^"
  5362. "a"                 "string"
  5363. a=b                 "="
  5364. a==b                "=="
  5365. a>b                 ">"
  5366. a>=b                ">="
  5367. a<b                 "<"
  5368. a<=b                "<="
  5369. a<>b                "<>"
  5370. a,b                 ","
  5371. ---------------------------------
  5372.  
  5373.         You also can test x, e.g. if x is type of real number, by
  5374. type(x)=="real".
  5375.  
  5376. * undefined                                           internal
  5377. The built-in constant. It indicates that the value of the expression 
  5378. is undefined, and may be the indeterminate form: 0/0, inf/inf, 0*inf, 0^0.
  5379. You should try again by lim(y, x=x0).
  5380. See also: lim.
  5381.     e.g.
  5382. IN:  f(x_) := sin(x)/x
  5383. IN:  f(0) 
  5384. OUT: undefined
  5385. IN:  lim(f(x), x=0)
  5386. OUT: 1
  5387.  
  5388. * until                                               external
  5389. comma. The same as comma ,.
  5390. The 6 keywords: from, to, step, then, else, until are the same as comma ,.
  5391. See also: from, to, step, then, else, until, ,.
  5392.  
  5393. * writes                                            internal
  5394. writes(x) writes x on the graphics screen.
  5395. It only works on the graphics mode.
  5396. See also: graph, readchar.
  5397.  
  5398. * zero                                                internal
  5399. zero is the positive-directed 0, as the built-in constant. f(x0+zero) is 
  5400. the right-hand sided function value when x approaches to x0 from the
  5401. positive direction, i.e. x = x0+. f(x0-zero) is the left-sided function
  5402. value when x approaches to x0 from the negative direction, i.e. x = x0-.
  5403. e.g. f(1+zero) is the rigth-hand sided function value when x approaches 
  5404. to 1 from the positive (+infinity) direction, f(1-zero) is the left-hand 
  5405. sided function value when x approaches to 1 from the negative (-infinity) 
  5406. direction.
  5407. See also: lim.
  5408. e.g.
  5409. IN:  exp(1/(0+zero)), exp(1/(0-zero))
  5410. OUT: inf, 0
  5411.  
  5412. +       add or positive sign. e.g. a+b.
  5413. -       subtract or negative sign. e.g. a-b, -1.
  5414. *       multiply. e.g. a*b.
  5415. /       divide. e.g. a/b.
  5416. ^       power in BASIC, the same as ** in FORTRAN, e.g. 2^3 gives 8.
  5417. **      power in FORTRAN, the same as ^ in BASIC, e.g. 2**3 gives 8.
  5418. !       factorial, the same as fac(x), e.g. 3! or fac(3) gives 6.
  5419.  
  5420. <       less than.
  5421. <=      less than or equal to.
  5422. >       greater than.
  5423. >=      greater than or equal to.
  5424.  
  5425. <>      unequal
  5426. a <> b gives 1 if a is not equal to b, 0 if a is equal to b, or left 
  5427. unevaluated otherwise. It only test two real numbers.
  5428. e.g. 2 <> 3 gives 1, 2 <> 2 gives 0.
  5429.  
  5430. ==      equal
  5431. a==b gives 1 if a is equal to b, 0 if a is not equal to b, or left 
  5432. unevaluated otherwise. It can test two complex numbers or expressions.
  5433. It gives 1 if a and b are the same expression or left unevaluated otherwise.
  5434. e.g. 2==2 gives 1, a==a gives 1.
  5435.  
  5436. =     equation sign
  5437. e.g. x^6+1 = 0
  5438.  
  5439. :=      assigment.
  5440.  
  5441. ,       comma
  5442. The words from, to, step, then, else and until are the same as ,.
  5443.  
  5444. "    string sign. e.g. "filename.sm".
  5445.  
  5446. |x|     the same as abs(x).
  5447. '       f'(x) is the same as d(f(x),x).
  5448.  
  5449. #       comment statement
  5450. e.g. # this is demo.
  5451.  
  5452. []      list. e.g. [a,b,c]
  5453. ()
  5454. -------------------------------------------------------------------------
  5455.  
  5456.  
  5457.             9.    References
  5458. [1]  Huang, W., Proceedings of the workshop on symbolic and numeric 
  5459.      computation, Helsinki University, Finland, 1991, p 185-186.
  5460. [2]  Huang, W., Int. J. Math. Educ. Sci. Tech., 1992, 23(1), 160-165.
  5461. [3]  Microbit, IEEE Micro, 1992, 12(1), 76.
  5462. [4]  Huang, W., IEEE Micro, 1992, 12(3), 80.
  5463. [5]  Huang, W., Abs. Amer. Math. Soc., 1992, 13(3), 343-344.
  5464. [6]  Huang, W., Abs. Amer. Math. Soc., 1992, 13(5), 518.
  5465. [7]  Huang, W., Abs. Amer. Math. Soc., 1992, 13(6), 535.
  5466. [8]  Huang, W., SIGSMALL/PC Notes, 1992, 18(1&2), 63-64.
  5467. [9]  Long, G., Australian PC World, 1992, June, 117-119.
  5468. [10] Iwaschkin, R., PC Plus, 1993, June, 281.
  5469. [11] Long, G., Australian PC World, 1993, July, 147.
  5470. [12] Arnold, S., Reflections, 1993, May, 18(2), 55-64.
  5471.