home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / comp / sys / hp48 / 5893 < prev    next >
Encoding:
Text File  |  1992-11-23  |  28.7 KB  |  949 lines

  1. Newsgroups: comp.sys.hp48
  2. Path: sparky!uunet!mcsun!chsun!bernina!colbach
  3. From: colbach@nessie.cs.id.ethz.ch (Philippe Colbach)
  4. Subject: Numerical and Analogical Computation (Part 01/02)
  5. Message-ID: <1992Nov23.105822.23880@bernina.ethz.ch>
  6. Sender: news@bernina.ethz.ch (USENET News System)
  7. Organization: Swiss Federal Institute of Technology (ETH), Zurich, CH
  8. Date: Mon, 23 Nov 1992 10:58:22 GMT
  9. Lines: 938
  10.  
  11.  
  12.    Hi!
  13.  
  14. Here's my latest library ("Numerical and Analogical Computation"). I hope
  15. that someone can use it ...
  16. Sorry for my poor English and my inability to write a documentation ...
  17.  
  18.                         Philippe Colbach
  19.                         colbach@nessie.cs.id.ethz.ch
  20.  
  21. N.B. Please contact me in case of errors!! 
  22.  
  23.  
  24.     NUMERICAL AND ANALOGICAL COMPUTATION
  25.     ====================================
  26.  
  27.  
  28. Library "Numerical & Analogical Computation" 
  29. Title: NUM
  30. ROMID: 958
  31. Bytes: 16508
  32. CHKSM: # 97F9h
  33.  
  34. First Menu:
  35. [SOLV]  Solving Equation
  36. [SYST]  Solving System of Equations
  37. [INTG]  Integrating Function
  38. [DIFF]  Computing Differential Equation
  39. [ASIM]  Continual Analogical Simulation
  40.  
  41. Second Menu:
  42. [IPOL]  Interpolation
  43. [CFIT]  Curve Fitting
  44. [TRANS] Transforming Coordinates
  45.  
  46.  
  47.   DOCUMENTATION
  48.   =============
  49.  
  50. FLAG STATE: - 2 CF  symbolic representation (-> [INTG] command!)
  51.             (-2 SF: numerical representation)
  52.  
  53.         -55 CF  LASTARG disabled (probably wrong last arguments 
  54.                 left on the stack in case of errors otherwise).
  55.             (-55 SF: LASTARG enabled)
  56.  
  57.         -60 SF  ALPHA in case of alpha mode (-60 will be set by
  58.                 [DIFF], [CFIT] and [TRANS])
  59.             (-60 CF: 1ALPHA mode)
  60.  
  61. The following programs have been tested for these flag states.
  62.  
  63.  
  64. [SOLV]  SOLVING EQUATION
  65. ========================
  66.  
  67. INPUT:    2: 'F(X)' or 'EQ(X)'
  68.       1: { RealX1 | RealX2 RealX3 | } or RealX
  69.  
  70. OUTPUT:   1: X: Root
  71.  
  72. DISPLAY:  running:     current X (after pressing any key)
  73.           root found:  root interpretation
  74.  
  75. ERROR:    no special error message
  76.  
  77. [SOLV] uses the internal procedure of the [SOLVR] menu. No variable
  78. (f.e. 'EQ' or 'X') is left in the current directory. 'X' has to be the
  79. unknown variable (only 2 inputs!).             ^^^
  80. ^^^^^^^^^^^^^^^^
  81.  
  82. EXAMPLE:  2: 'SIN(X)'
  83.       1: { 3 4 }
  84. RAD Mode    
  85. [SOLV] -> 1: X: 3.14159265359
  86.           DISPLAY: Sign Reversal 
  87.  
  88.  
  89. [SYST]  SOLVING SYSTEM OF EQUATIONS
  90. ===================================
  91.  
  92. INPUT:    4: 'F1(X,Y)' or 'EQ1(X,Y)'
  93.       3: 'F2(X,Y)' or 'EQ2(X,Y)'
  94.       2: RealX
  95.       1: RealY
  96.  
  97. OUTPUT:   1: X: RootX
  98.       2: Y: RootY
  99.  
  100. DISPLAY:  running: current X and Y
  101.  
  102. ERROR:    no special error message
  103.  
  104. [SYST] uses the Newton Algorithm. No variable is left in the current directory.
  105. 'F1(X,Y)' (or 'EQ1(X,Y)') and 'F2(X,Y)' (or 'EQ2(X,Y)') must be DERIVABLE!
  106. 'X' and 'Y' have to be the unknown variables.                   ^^^^^^^^^
  107. ^^^^^^^^^^^                ^^^^^^^^^^^^^^^^^
  108.                                     
  109. EXAMPLE:  4: 'SQ(X)+SQ(Y)=1' circle
  110.       3: 'Y=SQRT(X)'
  111.       2: .5
  112.       1: .5
  113.  
  114. As no root interpretation procedure is included, the program doesn't interrupt
  115. the computation at a sign reversal or in case of no root! The program can be 
  116. interrupted any time by pressing [ON].
  117.  
  118. [SYST] -> 2: .618033988751
  119.           1: .786151377759
  120.  
  121. P.S. Any suggestion concerning root interpretation?
  122.  
  123.  
  124. [INTG]  INTEGRATING FUNCTION
  125. ============================
  126.  
  127. INPUT:    2: 'F(X)'
  128.           1: { LowerLimit UpperLimit }
  129.  
  130. OUTPUT:   1: S: Integral
  131.  
  132. DISPLAY:  message displayed in case of numerical computation (computation
  133.       time can be long!)
  134.  
  135. ERROR:    no special error message
  136.  
  137. [INTG] first tries an algebraic integration, then a numerical one (message
  138. displayed). No variable is left in the current directory. In case of
  139. numerical computation, accuracy is defined by current display mode
  140. (STD, FIX, ENG, SCI; STD allows the best accuracy, but can take a long
  141. computation time, too!). 'X' has to be the unknown variable (only 2 inputs!).
  142.                  ^^^           ^^^^^^^^^^^^^^^^
  143. [INTG] supposes that flag -2 is CLEARED!
  144.  
  145. EXAMPLE:  2: 'SIN(X)'               2: 'SIN(ABS(X))'
  146.       1: { 0 '2*pi' }        1: { 0 '2*pi' }
  147. RAD and STD mode selected
  148.           (algebraic computation)   (numerical computation)
  149. [INTG] -> 1: S: 0                1: S: -3.67374857952E-12
  150.  
  151. EXAMPLE:  2: 'LN(X)'
  152.       1: { 0 e }
  153.       (algebraic computation)
  154. [INTG] -> 1: S: 0
  155.  
  156.  
  157. [DIFF]  COMPUTING DIFFERENTIAL EQUATION
  158. =======================================
  159.  
  160. INPUT:    none
  161.  
  162. OUTPUT:   none
  163.  
  164. ERROR:    no special error message
  165.  
  166. [DIFF] enables you to compute differential equations:
  167.  
  168. First EXAMPLE
  169. vvvvvvvvvvvvv
  170.  
  171. [DIFF] -> |Enter Differential EQ
  172.       | Y'=f(X,Y.l):
  173.  
  174. Algebraic enter mode is activated. 1ALPHA in case of alpha mode. l (lambda; 
  175. blue-shift [NXT]) represents the length of the curve arc. EDIT menu is
  176. activated (-> [->STK] command).
  177.  
  178.           |'TAN(SQ(l)/2) <ENTER>
  179.  
  180.       |Enter Initial Values
  181.       | X0 and Y0:
  182.  
  183. l0 (lambda0)=0 by default! EDIT menu in now desactivated ([left-shift] [+/-]
  184. ^^^^^^^^^^^^^^             to reactivate).
  185.  
  186.       | 0 <SPACE> 0 <ENTER>
  187.  
  188.       |Enter Computation step
  189.       | +/-dH:
  190.     
  191. Later, you can choose between two different algorithms: either dH represents
  192. dX or SQRT(dX^2+dY^2) (distance between points is constant=dH; this allows
  193. to compute differential equations representing circles f.e.).
  194.  
  195.       | .05 <ENTER>
  196.  
  197.       |>ae]-90 90[ >ae[0 360]    \
  198.       |dx=h        dx=h*cosa      > Algorithm formulae 
  199.       |dy=h*tana   dy=h*sina     /
  200.       |Var: none   Var: l=Eh     (l=current length of curve arc)*
  201.       |>4th Order  >2nd Order    Order of computation**
  202.       |[ ] /\ [ ] [ ] /\ [ ]     Press [/\] to choose algorthm
  203.  
  204. *   First alogorithm is unable to compute the current length of the curve arc.
  205.     The computation time would have been too long!
  206.  
  207. **  The first algorithm computes at a better accuracy in case of FLAT curves,
  208.     but fails in case of GREAT gradients (around +/-90 degrees) because dX=dH
  209.     is constant (choose the second algorithm: dH=SQRT(dX^2+dY^2)!). A 4th
  210.     order computation in case of a variable dX would have been too difficult
  211.     to program and the calculation too long, too!
  212.  
  213. During computation of the second algorithm, RAD mode is automatically selected
  214. for programming reasons.                    ^^^^^^^^
  215.  
  216.       |              </\>
  217.  
  218.       |Enter Number of Steps
  219.       | No:
  220.       |
  221.       | 100 <ENTER>
  222.  
  223. 100 points ( [ Xn Yn ] ) are computed and stored in '>]DAT'. The result 
  224. is then drawn as a scale curve (if no error occures). 
  225.  
  226. Second EXAMPLE
  227. vvvvvvvvvvvvvv
  228.  
  229. '>]DAT' PURGE
  230.  
  231. Data points would be appended to the former computation!
  232.  
  233. [DIFF] -> |'-SIN(X) <ENTER>        Y'=-SIN(X) Differential equation
  234.       | 0 <SPACE> 1 <ENTER>    X0=0 and Y0=1 Initial values
  235.       | .1 <ENTER>             dH=.1 Computation step
  236.           |   </\>                 First algorithm (dH=dX)
  237.  
  238. During computation of the first algorithm, RAD mode is *NOT* selected
  239. automatically as during the second one: [left-shift] [1] to select RAD.
  240.  
  241.       |Enter Storage Interval
  242.       | [Xb Xe]:
  243.  
  244. Xb >= X0! | 0 <SPACE> 6.3 <ENTER>
  245. ^^^^^^^^
  246. These data points are used by the second example of [IPOL] command!
  247.  
  248.  
  249. [ASIM]  CONTINUAL ANALOGICAL SIMULATION
  250. =======================================
  251.  
  252. INPUT:    none
  253.  
  254. OUTPUT:   none
  255.  
  256. [ASIM] activates a special menu:
  257.  
  258. [()-[> ]  DEFINE, RECALL or CLEAR Blocks
  259. [()-()-]  CHANGE Parameter of Blocks
  260. [<< >> ]  COMPILE analogical Structure
  261. [ E [> ]  STORE Blocks during Computation
  262. [ o-[] ]  SIMULATE analogical Structure
  263. [|__/\_]  DRAW Block Curve
  264.  
  265. These commands enable to define blocks and to combine them to an analogical
  266. structure.
  267.  
  268. DEFINITION (Schaum's outline series: Theory of feedback and control systems):
  269. A system is an arrangement of physical components connected or related in such 
  270. a manner as to form and/or act as an entire unit. Systems are classified into 
  271. two general categories: OPEN-LOOP and CLOSED-LOOP systems. The distinction is 
  272. determined by the CONTROL ACTION, which is that quantity responsible for 
  273. activating the system to produce the output:
  274.  - an OPEN-LOOP control system is one in which the control action is 
  275.    independent of the output.
  276.  - an CLOSED-LOOP control system is one in which the control action is somehow
  277.    dependent on the output.
  278. Both OPEN-LOOP and CLOSED-LOOP control systems can be combined.
  279.  
  280. ATTENTION:
  281. A CLOSED-LOOP system MUST ALWAYS contain at least ONE INTEGRATOR (block type 
  282. 50,51 or 52)! Analogical systems simulated by the [ASIM]-Program MUST ALWAYS 
  283. include at least ONE INTEGRATOR, even in case of an OPEN-LOOP! Otherwise the 
  284. [<< >> ]-compiler errors ("Integrator missing" or
  285. "Short Circuit in **"; refer to [<< >> ]).
  286.  
  287. EXAMPLES
  288. vvvvvvvv
  289.  
  290.      INPUT         OUTPUT-< ]-INPUT    -[I>- INTEGRATOR
  291.        |           |
  292. INPUT-[ >-OUTPUT         INPUT          (t)- CURRENT TIME
  293.  
  294.  
  295. (t)---[ >---[ >---[I>---[ >---[ >     (t)---[ >---[ >---[I>---[ >
  296.       |         |                      |           |
  297.        -------[ >----                        ----< ]----
  298.  
  299.            ----< ]----       -[ >     (t)---[ >---[ >---[ >---[I>
  300.       |           |     |                   |        |
  301. (t)---[ >---[ >---[I>---[ >-                     --[ >---
  302.           |           |     |
  303.            ----< ]----      |         [ >---[I>---[ >---[ >---[ >
  304.                 |           |              |     |
  305.                  -----------                [ >----------
  306.  
  307. NOTE: -The accuracy is corresponding to the accuracy of computation of a
  308.        differential equation using the Runge-Kutta algorithm of the
  309.        first order ([DIFF] uses both the second and the forth order).
  310.  
  311.       -In fact, simulating an analogical structure means to compute
  312.        a system of differential equations. 
  313.  
  314. [()-[> ], [<< >> ] and [ E [> ] create several variables in the current menu
  315. (named 'Omega***'). Before defining an analogical system, create a new
  316. directory! (Character 'Omega' = [right-shift] [EVAL])
  317.  
  318.  
  319. [()-[> ] DEFINE, RECALL or CLEAR Blocks
  320. ---------------------------------------
  321.  
  322.          DEFINE BLOCK        CLEAR BLOCK        RECALL BLOCK
  323.          vvvvvvvvvvvv        vvvvvvvvvvv        vvvvvvvvvvvv
  324.  
  325. INPUT:   4: Block Number
  326.      3: Block Type
  327.      2: { Entries }      2: Block Number
  328.      1: { Parameters }   1: 0               1: Block Number
  329.  
  330. OUTPUT:  none                none               4: Block Number
  331.                         3: Block Type
  332.                         2: { Entries }
  333.                         1: { Parameters }
  334.  
  335. DEFINE BLOCK:
  336. Every block has several inputs (from other blocks or parameters), but only
  337. ONE output. A block is defined by its block number (its "name"), its block
  338. type (defining its action), its entries (from other blocks) and its
  339. parameters. There are special block types without any entry (0,56,60 and 100).
  340. Block number 100 represents the current time during computation. [()-[> ]
  341. always owerwrites former block definitions.
  342. 50 different block types are predefined (refer to block list at the end of
  343. this documentation), some types are undefined (f.e. 14). The creation of
  344. user-defined block types is possible: just create a program called
  345. 'Omega***' (*** > 100) computing the exact number of entries and parameters
  346. you indicated in the { Entires } and { Parameters } lists during definition.
  347. The count of E's and P's is not tested as for the predefined blocks!
  348.  
  349. RECALL BLOCK:
  350. To recall a block definition, just enter its number. Block number, block type,
  351. entry list and parameter list are then put on stack.
  352.  
  353. CLEAR BLOCK:
  354. To clear an already defined block, enter its number and a zero. In fact,
  355. blocks are not cleared, but replaced by the block type 60 (Null).
  356.  
  357. Note: - user-defined block type program form:
  358.     << -> E1 E2 P1 P2 P2 << ... >> >>
  359.     Block entries (E) BEFORE parameters (P)!
  360.  
  361.       - A negative block entry means that the sign of the input from this
  362.         block is automatically changed (refer to the example).
  363.  
  364.       - { } means NO entry or parameter (E=0 or/and P=0 in block list).
  365.  
  366.       - Character Omega = [right-shift] [EVAL]
  367.  
  368. VARIABLES:
  369. OmegaBLC   block entries
  370. OmegaPAR   block parameters
  371. OmegaTYP   block types
  372. OmegaINT   Integrators
  373. OmegaDER   d/dt blocks
  374. OmegaINIT  initial values of integrators
  375.  
  376. ERRORS: 
  377. "Wrong Entry Count"     Refer to block list under column E
  378. "Wrong Parameter Count" Refer to block list under column P
  379. "Type ** undefined"     Refer to block list under column NBR & ACTION
  380. "Block ** undefined"    Trying to recall an undefined block
  381.        
  382.  
  383. [()-()-] CHANGE Parameter of Blocks
  384. -----------------------------------
  385.  
  386. INPUT:   2: Block Number
  387.      1: { Parameters } or Parameter (Initial Value of Integrator)
  388.  
  389. OUTPUT:  none
  390.  
  391. This command allows to change the parameters of an ALREADY defined block.
  392. To simply change the initial value of an integrator (block number 50,51,52),
  393. just enter its block number and the initial value (not included in a list).
  394.  
  395. ERRORS: 
  396. "Wrong Parameter Count" Refer to block list under column P
  397. "Block ** undefined"    Trying to change the parameters of an undefined block
  398.  
  399.  
  400. [<< >> ] COMPILE analogical Structure
  401. -------------------------------------
  402.  
  403. INPUT:   none
  404.  
  405. OUTPUT:  none
  406.  
  407. Before a system can be simulated, it has to be compiled. The compiled
  408. system (program) is stored under global variable 'OmegaPRG'.
  409.  
  410. IMPORTANT: AFTER every change (block definition or just a parameter), the 
  411.            system has to be compiled BEFORE it can be simulated!
  412.  
  413. VARIABLES:
  414. OmegaORD   order of block output computation
  415. OmegaPRG   compiled system
  416.  
  417. ERRORS: 
  418. "Integrator missing"  No integrator at all was defined
  419. "Short Circuit in **" Closed-loop (containing block **) without integrator
  420. "Block ** undefined"  Block entry from an undefined block
  421.  
  422.  
  423. [ E [> ] STORE Blocks during Computation
  424. ----------------------------------------
  425.  
  426. INPUT:   1: { Block Numbers } or { 0 }
  427.  
  428. OUTPUT:  none
  429.  
  430. Not every block output is important. You can pick out all the outputs you are 
  431. interested in. { 0 } means that ALL blocks are stored during computation. 
  432. Remember that block number 100 represents the current time. [ E [> ] creates 
  433. a program stored under global variable 'OmegaSTO'. [ E [> ] changes don't have
  434. to be compiled, but the storage list has to be defined before the system can
  435. be simulated!
  436.  
  437. VARIABLES:
  438. OmegaSTP   list of blocks to be stored during simulation
  439. OmegaSTO   program to store blocks during simulation
  440.  
  441. ERRORS: no special error message
  442.  
  443.  
  444. [ o-[] ] SIMULATE analogical Structure
  445. --------------------------------------
  446.  
  447. INPUT:   none
  448.  
  449. OUTPUT:  none
  450.  
  451. [ o-[] ] -> |Simulation Interval:
  452.  
  453. Enter the time interval (f.e. from 0 to 100, unit depends always on the 
  454. current system):
  455.  
  456.         |0 <SPACE> 100 <ENTER>
  457.  
  458.         |Computation Step:
  459.  
  460. Enter the time step of computation (f.e. 0.1):
  461.  
  462.         |.1 <ENTER>
  463.  
  464.         |Storage Step:
  465.  
  466. Enter the time step of storing the blocks indicated by the command [ E [> ]:
  467.  
  468.         |1 <ENTER>
  469.  
  470.         | SIMULATING
  471.  
  472. Simulation begins ... Blocks are stored under global variable '>]DAT'
  473.  
  474. ERRORS: 
  475. "Structure not compiled" Trying to simulate a non-compiled system. Refer to
  476.              [<< >> ] command.
  477. "Storage List missing"   Trying to simulate without indicating the blocks
  478.               to be stored during computation. Refer to [ E [> ]
  479.               command.
  480.  
  481.  
  482. [|__/\_] DRAW Block Curve
  483. -------------------------
  484.  
  485. INPUT:   1: Block Number
  486.  
  487. OUTPUT:  none
  488.  
  489. Just enter the number of the block of which you want to draw the result curve.
  490.  
  491. ERRORS: 
  492. "Block ** undefined" Trying to draw the result curve of an undefined block
  493. "Block ** unstored"  Trying to draw the result curve of an unstored block
  494.  
  495.  
  496. BLOCK TYPE DEFINITIONS at the end of documentation
  497. ----------------------
  498.  
  499. EXAMPLE
  500. -------
  501. __
  502.   \___  affluent R [m^3/h]
  503.       \___________         weir W [m^3/h]
  504.                 \ area A [m^2]  ___     
  505.                  \~~~~~~~~~~~~~| | \    ^
  506.                   \   depth H  | |      |
  507.                    \    [m]    | |      | initial depth of water H0=20m
  508.                     \          | |      | 
  509.                      \_________| |      v
  510.                  | |dam: heigth=21m, width=4m
  511.                                  
  512.                                    Area(H)
  513.                             [m2]  --------
  514.                                ------<Omega102|<---
  515.                                   | (A)   --------     |
  516.                               |            *6*        |
  517.                               |              |
  518.           Affluent(t)                  (1/3600)       |                  |
  519. Time  [h]  --------  [m3/h]               |           v        INTEGRATOR  |
  520. (100)---->|Omega101>--------> --  [m3/h]  --  [m3/s]  -- [m/s]   ----  [m] |
  521.            --------  (R) (+) |15>------->|20>------->|18>--->(1)| 50 >-----|
  522.              *1*         ---> --          --          -- (dH)    ----  (H) |
  523.                         |(-)  *2*         *3*         *4*        |  *5*    |
  524.                         |                         (20)=(H0)   |
  525.    *BlockNumber*        |                           |
  526.      ---------          |                     Wire(H) *7*   |
  527.     |BlockType>         |                             [m3/h]  --------     |
  528.      ---------           ------------------------------------<Omega103|<---
  529.                                   (W)     --------
  530. Blocks 2,3,4,5,7 are forming a CLOSED-LOOP.                   |    |
  531. Blocks 4,5,6 are also forming a CLOSED-LOOP.               (21) (4)
  532. Both CLOSED-LOOPs contain block 5 as INTEGRATOR.       Dam height   Dam width
  533. Block 2: the input -from block 1- sign is (+),
  534. input -from block 7- sign is (-) ( -> outlet ).
  535.  
  536. Block Definition:
  537.  
  538. NBR TYPE  ENTRIES  PARAMETERS
  539.  
  540.   1  101  { 100 }   { }        [()-[> ]
  541.   2   15  { 1 -7 }  { }        [()-[> ]    Note input signs!
  542.   3   20  { 2 }     { 3.6 }    [()-[> ]
  543.   4   18  { 3 6 }   { }        [()-[> ]
  544.   5   50  { 4 }     { 20 1 }   [()-[> ]
  545.   6  102  { 5 }     { }        [()-[> ]
  546.   7  103  { 5 }     { 21 4 }   [()-[> ]
  547.  
  548. User-defined block types:
  549.  
  550. Block type 101: (Affluent)
  551. << -> E1 << ... >> >>
  552. 'Omega101' STO
  553.  
  554. Block type 102: (Area: function of depth H)
  555. << -> E1 << ... >> >>
  556. 'Omega102' STO
  557.  
  558. Block type 103: (Wire: function of depth H, dam height and dam width)
  559. << -> E1 P1 P2 << ... >> >>     Block entires (E) BEFORE parameters (P)!
  560. 'Omega103' STO
  561.  
  562. Compiling:                [<< >> ]
  563. Storage List:  { 1 5 7 }  [ E [> ]
  564.  
  565. Simulating:               [ o-[] ] -> |0 <SPACE> 24 <ENTER>  Time Interval [h]
  566.                       |.1 <ENTER>            Comp. Step
  567.                       |.4 <ENTER>            Storage Step
  568.  
  569. Draw Curve:         5     [|__/\_]  Depth Curve
  570.             
  571.  
  572. [IPOL]  INTERPOLATION
  573. =====================
  574.  
  575. INPUT:    1: RealX
  576.  
  577. OUTPUT:   2: d: Derivative
  578.       1: Y: RealY
  579.  
  580. DISPLAY:  no special message displayed
  581.  
  582. ERROR:    "Bad >]DAT Data"    >]DAT is either unexistant or not an array
  583.           "Wrong >]DAT Size"  >]DAT size has to be { n 2 }
  584.  
  585. [IPOL] allows you to interpolate data points stored in growing order
  586. in '>]DAT':
  587.  
  588. |*> [IPOL], [CFIT] and [TRANS] need '>]DAT' data under a special form:
  589. |*>
  590. |*>   - '>]DAT' size = { n 2 }
  591. |*>   - First column of '>]DAT' = Xn
  592. |*>   - Second column of '>]DAT' = Yn
  593. |*>   - [IPOL] ONLY: X-column in GROWING order, Xn > Xn-1!
  594. |*>     ^^^^^^^^^^^              ^^^^^^^
  595. |*>     [DIFF] command creates '>]DAT' in growing order if:
  596. |*>     - dX=dH>0 (first algorithm)
  597. |*>     - dH>0 & dX>0 (second algorithm) 
  598.  
  599.         (Y)
  600.          ^             (n) 
  601.    (1)   |              x
  602.     x  (2)          (n-1)
  603.         x|            x
  604.         :|   x     x  :
  605.         :|      x     :
  606.         :|              :
  607. --------:-------------:------> (X)
  608.     :|            :
  609.         :             :
  610. -------><-------------><--------
  611.   2nd         5th          2nd      polynomial degree (of interpolation)
  612.  
  613. First EXAMPLE
  614. vvvvvvvvvvvvv
  615.  
  616. Let's create such a '>]DAT' variable:
  617.  
  618. '>]DAT' PURGE  ([DIFF] appends data points to former computation)
  619.  
  620. [DIFF] -> | l <ENTER>                  Y'=l (lambda)  
  621.       | 0 <SPACE> 1 <RETURN>       X0=0, Y0=1
  622.       | .1 <ENTER>                   dH=.1
  623.       |             </\>           second algorithm (2nd order, var: l)
  624.       | 10 <ENTER>               10 points
  625.  
  626. Differential equation Y'=l [Gradient a function of the length of the curve arc]
  627.                    => Y=COSH(X) !!
  628. That's why I proposed the initial values X0=0 and Y0=1!
  629.  
  630. [IPOL] interpolates the data points from the '>]DAT' variable:
  631.  
  632. .5 [IPOL]  ->  d(.5)/dX= 0.510410896178     | SINH(0.5)= 0.521095305494
  633.                       Y= 1.127241126120     | COSH(0.5)= 1.127625965210
  634.  
  635. These data points are also used by the example of [CFIT] command.
  636.  
  637. Second EXAMPLE
  638. vvvvvvvvvvvvvv
  639.  
  640. Use the data points from the second example of [DIFF] command.
  641.  
  642. As Y'=-SIN(X), Y=COS(X). Let's try to find the root X=pi/2 by using [IPOL]
  643. and [SOLV]. As [IPOL] has two tagged outputs, we have to create a program
  644. (function form) which has only the (real) output Y:
  645. <<  ->  X  <<  X  IPOL  SWAP  DROP  0  +  >>  >>  'FCN'  STO
  646.  
  647.           2: 'FCN(X)'
  648.           1: { 1 2 }
  649.  
  650. [SOLV] -> 1: X: 1.57077308547      
  651. and:      pi/2= 1.57079632680
  652.  
  653. Note: -Program with Y output (as real):
  654.        <<  ->  X  <<  X  IPOL  SWAP  DROP  0  +  >>  >>
  655.       -Program with dY/dX output (as real):
  656.        <<  ->  X  <<  X  IPOL  DROP  0  +  >>  >>
  657. Internal ROOT and DRAW commands don't accept tagged arguments; neither do 
  658. [SOLV] and [INTG]!
  659.  
  660.  
  661. [CFIT]  CURVE FITTING
  662. =====================
  663.  
  664. INPUT:    none
  665.  
  666. OUTPUT:   1: Correlation
  667.  
  668. ERROR:    "Bad >]DAT Data"    >]DAT is either unexistant or not an array
  669.       "Wrong >]DAT Size"  >]DAT size has to be { n 2 }
  670.  
  671. [CFIT] fits the data points from the '>]DAT' variable. HP48 Curve Fitting 
  672. program offers only 4 base modles, but [CFIT] allows user modles:
  673.  
  674. For this example, we use the data points from the first example of [IPOL].
  675.  
  676. [CFIT] -> | Curve Fitting Modles
  677.       |LIN: B + f(X)*M = g(Y)
  678.       |PWR: B * f(X)^M = g(Y)
  679.       |
  680.       |[LIN] [] [] [] [] [PWR]
  681.  
  682. [CFIT] proposes 2 base modles, f(X) and g(Y) can be ANY function of X and Y!
  683.                             ^^^^^^^^^^^^^^^^^^^^^^^
  684.       |[LIN]
  685.  
  686.       |Modle: LINFIT
  687.       |B + f(X) *M= g(Y)
  688.       |Enter Function f(X):
  689.                 ^
  690. Algebraic enter mode is activated. 1ALPHA in case of alpha mode. EDIT menu
  691. is activated (-> [->STK] command).
  692.  
  693.       |'COSH(X) <ENTER>
  694.  
  695. Just typing <ENTER> would mean that g(X)=X!
  696.  
  697.       |Modle: LINFIT
  698.       |B + f(X) *M= g(Y)
  699.       |Enter Function g(Y):
  700.                 ^
  701.       |' <ENTER>
  702.  
  703. Typing just <ENTER> means that g(Y)=Y.
  704.  
  705.       |Enter >]LINE Name:
  706.  
  707. ALPHA mode is activated. You can enter a function name for the curve.
  708.  
  709.       |APRX <ENTER>
  710.  
  711.       |Defining >]LINE FCN
  712.  
  713.       1: Correlation:
  714.          .999999996453
  715.  
  716. Test: 0.5 [APRX]  ->  1.12739143401 (accuracy better then [IPOL]!)
  717.       0.5 [IPOL]  ->  1.12724112612
  718.       0.5 [COSH]  ->  1.12762596521
  719.  
  720.  
  721. [TRANS]  TRANSFORMING COORDINATES
  722. =================================
  723.  
  724. INPUT:    none
  725.  
  726. OUTPUT:   none   
  727.  
  728. ERROR:    "Bad >]DAT Data"    >]DAT is either unexistant or not an array
  729.           "Wrong >]DAT Size"  >]DAT size has to be { n 2 }
  730.  
  731. [TRANS] transforms data points from the '>]DAT' variable.
  732.  
  733. '>]DAT' PURGE
  734. [DIFF] -> |'TAN(l) <ENTER>        (lambda: [right-shift] [NXT])
  735.       | 0 <SPACE> -1 <ENTER>  X0=0 and Y0=-1
  736.       | .1 <ENTER>          dH=.1
  737.       |             </\>      algorithm able to compute l (lambda)
  738.       | 63 <ENTER>            63 points
  739.  
  740. [TRANS] -> |Enter X-Transformation
  741.            |X1=f(X,Y,a,r)
  742.  
  743. a = ATAN(Y/X)            >[blue-shift] [A]
  744. r = SQRT(SQ(X)+SQ(Y))    >[blue-shift] [->]
  745. [X Y] = cartesian coordinates
  746. [a r] = polar coordinates
  747.  
  748. Algebraic enter mode is activated. 1ALPHA is case of alpha mode. EDIT menu
  749. is activated (-> [->STK] command).
  750.  
  751.        |'X*SIN(2*a) <ENTER> 
  752.  
  753. Just typing <ENTER> would mean that X1=X!
  754.  
  755.        |Enter Y-Transformation
  756.            |Y1=g(X,Y,a,r)
  757.  
  758.        |'Y*SIN(2*a) <ENTER>  
  759.  
  760. Just typing <ENTER> would mean that Y1=Y!
  761.  
  762.        |Transforming (X,Y)
  763.  
  764. Data points are transformed and drawn as a scale curve.
  765.  
  766.  
  767. BLOC DEFINITIONS
  768. ================
  769.  
  770. NBR   TYPE                      ACTION                                  E  P
  771.  
  772.   0*  NULL ENTRY                E0=0                    -  -
  773.   1   ABSOLUTE VALUE           E0=ABS(E1)                1  0
  774.   2   SIGN                   E0=SIGN(E1)                1  0
  775.   3   NEGATIVE VALUE           E0=-E1                    1  0
  776.   4   SIGN TRANFER             E0=E1*SIGN(E2)                2  0
  777.   5   CLIP NEGATIVE            E0=IFTE(E1>0,E1,0)            1  0
  778.   6   CLIP POSITIVE            E0=IFTE(E1>0,0,E1)            1  0
  779.   7   FREE SPACE               E0= * [see below]                       1  2
  780.   8   LIMIT            E0= * [see below]                     1  2
  781.   9   SCALE              E0= * [see below]             1  3
  782.  10   RELAY 1                  E0=IFTE(E1>=0,E2,E3)            3  0
  783.  11   RELAY 2                  E0=IFTE(E1>0,E2,0)            2  0
  784.  12   MINIMUM                  E0=MIN(E1,E2)                2  0
  785.  13   MAXIMUM                  E0=MAX(E1,E2)                2  0
  786.  14*
  787.  15   ADDITION 2               E0=E1+E2                2  0
  788.  16   ADDITION 3               E0=E1+E2+E3                3  0
  789.  17   MULTIPLICATION           E0=E1*E2                2  0
  790.  18   DIVISION                 E0=E1/E2                2  0
  791.  19   ADDITION CONSTANT          E0=E1+P1                1  1
  792.  20   MULTIPLICATION CONSTANT   E0=E1*P1                1  1
  793.  21   ADD+MUL 2                E0=E1*P1+E2*P2                2  2
  794.  22   ADD+MUL 3                 E0=E1*P1+E2*P2+E3*P3                3  3
  795.  23*                              
  796.  24*
  797.  25   INVERSE                   E0=INV(E1)                1  0
  798.  26   SQUARE                   E0=SQ(E1)                1  0
  799.  27   SQUARE ROOT              E0=SQRT(E1)                1  0
  800.  28   POWER            E0=E1^E2                2  0
  801.  29   POLYNOMIAL        E0=P1+P2*E1+P3*E1^2            1  3
  802.  30   COMMON LOGARITHM        E0=P1*LOG(E1+P2)+P3            1  3
  803.  31   COMMON EXPONENTIAL        E0=P1*ALOG(E1*P2)+P3            1  3
  804.  32   NATURAL LOGARITHM        E0=P1*LN(E1+P2)+P3            1  3
  805.  33   NATURAL EXPONENTIAL       E0=P1*EXP(E1*P2)+P3            1  3
  806.  34*
  807.  35*
  808.  36   SINE            E0=P1*SIN(E1*P2+P3)            1  3
  809.  37   COSINE            E0=P1*COS(E1*P2+P3)            1  3
  810.  38   TANGENT            E0=P1*TAN(E1*P2+P3)            1  3
  811.  39   ARC SINE            E0=P1*ASIN(E1*P2+P3)            1  3
  812.  40   ARC COSINE        E0=P1*ACOS(E1*P2+P3)            1  3
  813.  41   ARC TANGENT        E0=P1*ATAN(E1*P2+P3)            1  3
  814.  42   SINE HYPERBOLIC        E0=P1*SINH(E1*P2+P3)            1  3
  815.  43   COSINE HYPERBOLIC        E0=P1*COSH(E1*P2+P3)            1  3
  816.  44   TANGENT HYPERBOLIC        E0=P1*TANH(E1*P2+P3)            1  3
  817.  45   ARC SINE HYPERBOLIC       E0=P1*ASINH(E1*P2+P3)            1  3
  818.  46   ARC COSINE HYPERBOLIC     E0=P1*ACOSH(E1*P2+P3)            1  3
  819.  47   ARC TANGENT HYPERBOLIC    E0=P1*ATANH(E1*P2+P3)            1  3
  820.  48*
  821.  49*
  822.  50   INTEGRATION 1             E0=P1+Integral[E1*P2]dt            1  2
  823.  51   INTEGRATION 2        E0=P1+Integral[E1*P2+E2*P3]dt        2  3
  824.  52   LIMIT INTEGRATION         E0=P1+Integral[E1]dt,P2<=E0<=P3         1  3
  825.  53   DERIVATIVE ** [see below] E0=dE1/dt                1  0
  826.  54*
  827.  55*
  828.  56   RANDOM            E0=RAND                    0  0
  829.  57   CONSTANT            E0=P1                    0  1
  830.  58   QUIT            quit if E1>E2                2  0
  831.  59*
  832.  60   NULL            E0=0                    0  0
  833.  61*
  834.  62*
  835.  63*
  836.  64*
  837.  65*
  838.  66*
  839.  67*
  840.  68*
  841.  69*
  842.  70*
  843.  71*
  844.  72*
  845.  73*
  846.  74*
  847.  75*
  848.  76*
  849.  77*
  850.  78*
  851.  79*
  852.  80*
  853.  81*
  854.  82*
  855.  83*
  856.  84*
  857.  85*
  858.  86*
  859.  87*
  860.  88*
  861.  89*
  862.  90*
  863.  91*
  864.  92*
  865.  93*
  866.  94*
  867.  95*
  868.  96*
  869.  97*
  870.  98*
  871.  99*
  872. 100*  CURRENT TIME        E0=current time                -  -
  873.  
  874.  nn*  undefined block type
  875.   0*  can only be used to determine a null entry (En=0) in entry list
  876. 100*  can only be used as time input in entry list
  877.  
  878. ** Block 53: derivative through the last 3 points
  879.  
  880.    Note: - Input E---[D>---O Output    
  881.            O=dE/dt 
  882.  
  883.          - Input E---[I>---[D>---O Output 
  884.            O is NOT equal to E for algorithm reasons:
  885.  
  886.              TIME t   INPUT E   INTEGRAL I   OUTPUT O
  887.               tn        En         In          On-1 (using In-3, In-2 and In-1)
  888.               tn+1      En+1       In+1        On   (using In-2, In-1 and In)
  889.            
  890.            On(tn+1)=En(tn)!
  891.           
  892. *** > 100   USER DEFINED BLOCKS
  893.  
  894. N.B. Any suggestion about new block types? 
  895.  
  896.  
  897. Block 7
  898. -------
  899.  
  900.           ^                ^             /                  ^          
  901.           |                |            /         \         |          
  902.           |        /       |       1:1 /           \ 1:1    |          
  903.           |   1:1 /        |          /             \       |          
  904.     P1    |      /         |  P1     /               \      |P1        
  905. ----:=====|=====:--->    --|--:=====:-------->    ----:=====|=:-------> 
  906.    /      |    P2          | /     P2                 P2    |  \       
  907.   /       |                |/                               |   \      
  908.  / 1:1    |                / 1:1                            |1:1 \     
  909. /         |               /|                                |     \    
  910.           |                |                                |      \   
  911.  
  912.        P1 < P2                 P1 < P2                   P1 > P2
  913.  
  914.  
  915. Block 8
  916. -------
  917.  
  918.         P2-    ------      ^                                ^          
  919.           |   /          P2-      ------------    -------   - -P2      
  920.           |  / 1:1         |     /                       \  |          
  921.           | /              |    / 1:1                 1:1 \ |          
  922.       P1  |/               |   /                           \|   P1     
  923. ------:---|----:---->    ---P1-                   ------:---|----:----> 
  924.          /|   P2           |                            P2  |\         
  925.     1:1 / |                | P1                             | \        
  926.        /  |              --|--:---:---------->              |  \ 1:1   
  927. -------   -P1              |     P2                         |   \      
  928.           |                |                            -P1 -    ------
  929.  
  930.        P1 < P2                  P1 < P2                  P1 > P2
  931.        
  932.  
  933. Block 9
  934. -------
  935.                     P2>0
  936.   ^                          <------->                      ^          
  937.   |            ------        P1    |                        |          
  938.   - P3        /          ====:-----|-:------->    --------- - P3       
  939.   |          /                \    | P1+P2                 \|         
  940.   |         / P3:P2            \   |                        \          
  941.   |        /                    \  |                        |\ P3:P2    
  942.   |       /                P3:P2 \ |                        | \        
  943.   |      /                        \|                  P1+P2 |  \       
  944. ==|=====:------:---->              \              --------:-|---:=====>
  945.   |     P1   P1+P2                 |\                       |  P1      
  946.   |     <------>                 P3- ---------            <----->      
  947.           P2>0                                              P2<0
  948.  
  949.