home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / teach.zip / TEACH21A.ATF < prev    next >
Text File  |  1997-09-19  |  54KB  |  659 lines

  1. XNÉIO 0 1                                                                      °
  2. XNÉCT 0 1E²13                                                                  °
  3. XCÉFC 1 6 .,*0_²                                                               °
  4. XNÉRL 0 34075629                                                               °
  5. XCÉPR 1 1                                                                      °
  6. XCÉLX 1 5 TEACH                                                                °
  7. *(1996 4 6 16 11 29 328)                                                       °
  8.  FBIND ÉFX 'BIND' 'Σ Binding rules of APL2'                                    °
  9.   '''  1. Brackets bind to the left'''                                         °
  10.   '''  2. Left arrow binds to the left'''                                      °
  11.   '''  3. Dyadic operator binds to the right'''                                °
  12.   '''  4. Strand notation binding'''                                           °
  13.   '''  5. Operator binds to its left'''                                        °
  14.   '''  6. Function binds to its left'''                                        °
  15.   '''  7. Function binds to its right'''                                       °
  16. X '''  8. Left arrow binds to its right'',r'                                   °
  17. *(1997 8 21 13 22 23 416)                                                      °
  18.  FCOSINES ÉFX 'u╜a COSINES w' 'ΣDD'                                            °
  19. X 'u╜²2Ω(a+.⌡φw)÷((+/a*2)°.⌡+/w*2)*0.5'                                        °
  20. *(1996 4 6 16 11 29 328)                                                       °
  21. XFDEGREES ÉFX 'U╜DEGREES W' 'U╜180⌡W÷Ω1'                                       °
  22. *(1997 9 14 12 30 44 504)                                                      °
  23. XFDISCLAIMER ÉFX 'DISCLAIMER' 'Σ Copyright statement' 'disclaimer'             °
  24. *(1996 4 6 16 11 29 328)                                                       °
  25.  FDISPLAY ÉFX 'D╜S DISPLAY A;ÉIO;R;C;HL;HC;HT;HB;VL;VB;V;W;N;B'                °
  26.   'Σ DISPLAY A GENERAL ARRAY IN PICTORIAL FORM'                                °
  27.   'Σ  NORMAL CALL IS MONADIC.  DYADIC CALL USED ONLY IN'                       °
  28.   'Σ    RECURSION TO SPECIFY DISPLAY RANK, SHAPE, AND DEPTH.' 'ÉIO╜0'          °
  29.   '»(0=ÉNC ''S'')/''S╜µA''' 'R╜╞µ,S                   Σ PSEUDO RANK.'          °
  30.   'C╜''┐┌└┘''                 Σ UR, UL, LL, AND LR CORNERS.'                   °
  31.   'HL╜''─''                   Σ HORIZONTAL LINE.'                              °
  32.   'HC╜HL,''Θ╕'',HL,''~+ε''      Σ HORIZONTAL BORDERS.'                         °
  33.   'HT╜HC[(0<R)⌡1+0<╞²1╞,S]' 'ΣW╜,0╧■╞0µΓ(1⌐µA)╞A'                              °
  34.   'HB╜HC[3+3╛(''2⌡~A╧«A'' ÉEA ''1+╞ε0⌡(1⌐⌡/µA)╞,A'')+3⌡1<µµS]'                 °
  35.   'VL╜''│''                   Σ VERTICAL LINE.'                                °
  36.   'VB╜VL,''Φ╟''               Σ VERTICAL BORDER.'                              °
  37.   'V╜VB[(1<R)⌡1+0<²1╞²1╟,S]'                                                   °
  38.   '»(0εµA)/''A╜(1⌐µA)µΓ╞A''   Σ SHOW PROTOTYPE OF EMPTIES.'                    °
  39.   '╕(1<╧A)/GEN' '╕(2<µµA)/D3'                                                  °
  40.   'D╜«A                     Σ SIMPLE ARRAYS.' 'W╜1╞µD╜(²2╞1 1,µD)µD'           °
  41.   'N╜²1+1╟µD' '╕(0=µµA)/SS'                                                    °
  42.   'D╜(C[1],V,((W-1)µVL),C[2]),((HT,NµHL),[0]D,[0]HB,NµHL),C[0],(WµVL),C[       °
  43.  3]' '╕0' 'SS:HB╜((0 '' '')=╞0µΓA)/'' -'''                                     °
  44.   'D╜'' '',('' '',[0]D,[0]HB,Nµ'' ''),'' ''' '╕0'                              °
  45.   'GEN:D╜«DISPLAY■A          Σ ENCLOSED ...' 'N╜Dδ.⌠'' '''                     °
  46.   'D╜(Nδ~1ΦN)≡D' 'D╜(δ≡~''  ''╤D)/D' 'D╜((1,µS)µS)DISPLAY D'                   °
  47.   '╕(2≥µ,S)╟D3E,0' 'D3:D╜0 ²1╟0 1╟«ΓA         Σ MULT-DIMENSIONAL ...'          °
  48.   'W╜1╞µD' 'N╜²1+1╟µD'                                                         °
  49.   'D╜(C[1],V,((W-1)µVL),C[2]),((HT,NµHL),[0]D,[0]HB,NµHL),C[0],(WµVL),C[       °
  50.  3]' 'D3E:N╜²2+µ,S'                                                            °
  51. X 'V╜C[Nµ1],[0]VB[1+0<²2╟,S],[0](((²3+╞µD),N)µVL),[0]C[Nµ2]' 'D╜V,D'           °
  52. *(1996 4 6 16 11 29 328)                                                       °
  53.  FEXIT ÉFX 'EXIT' 'Σ Exit from function' '''To log off type:   )OFF'''         °
  54. X '╕'                                                                          °
  55. *(1996 4 6 16 11 29 328)                                                       °
  56.  FGO ÉFX 'GO;T;E;B' 'Σ Expression driver' 'L0:B╜E╜''''' 'æ╜''      '''         °
  57.   'T╜æ' '╕(^/'' ''=T)/L0' '╕((^/'')OFF ''=5╞6╟T)doif ''EXIT'')/0'              °
  58.   '╕(('':''εT)doif ''B╜evaldd (+/^\'''' ''''=T)╟T'')/L0'                       °
  59.   '''E╜ÉEM'' ÉEA T' '╕(0=µ,E)/L0' '╕B/L0'                                      °
  60.   '''This is not a valid APL2 expression''' 'æ╜''*'''                          °
  61. X '╕(''?''⌠╞1╟æ)/L0' 'E' '╕L0'                                                 °
  62. *(1997 8 21 13 20 56 540)                                                      °
  63.  FHELP ÉFX 'HELP;N;I;T' 'Σ Help to student' '''WHAT TO DO'',r'                 °
  64.   '''  ° To get out of the lesson''' '''       ENTER: EXIT'''                  °
  65.   '''  ° To log off APL2'''                                                    °
  66.   '''       FIRST, ENTER: EXIT  THEN ENTER: )OFF'''                            °
  67.   '''  ° To get help''' '''       ENTER: HELP'''                               °
  68.   '''  ° When you see the prompt on a blank line'''                            °
  69.   '''       ENTER AN APL2 EXPRESSION - OR JUST PRESS: ENTER''' 'do'            °
  70.   '''  ° If you get this line'',r'                                             °
  71.   '''This is not a valid APL2 expression'',r,''*'',r'                          °
  72.   '''        YOU CAN EITHER''' '''           A. PRESS: ENTER'''                °
  73.   '''           B. PRESS: ? and then ENTER to see what was incorrect'''        °
  74.   '''              in your expression causing that response'',r' 'do'          °
  75.   '''HINTS'',r'                                                                °
  76.   '''This lesson is made up of '',(«N╜7),'' components named TEACHx, whe       °
  77.  re''' '''the x stands for a digit:'',r' 'I╜0'                                 °
  78.   'L0:T╜''TEACH'',(«I╜I+1)' 'T,'' '',1╟notb(ÉCR T)[2;]' '╕(N>I)/L0'            °
  79.   'do'                                                                         °
  80.   '''You may review either of these components separately. To do that,''       °
  81.  '                                                                             °
  82.   '''first enter EXIT (and RETURN), then enter the name of the lesson.''       °
  83.  ' '''component (e.g. TEACH4).'',r'                                            °
  84.   '''To re-start the lesson, just enter TEACH'',r'                             °
  85.   '''When the screen fills up, it is a good idea to move the cursor to''       °
  86.  ' '''the start of a convenient paragraph, and press ENTER'',r'                °
  87.   '''You may also wish to press PAGE UP to review the prevous pages.'''        °
  88.   'do' '''RESOURCES'',r' '''You may also enter the following word'',r'         °
  89. X '''BIND   List of binding rules''' 'endd'                                    °
  90. *(1997 8 21 13 21 54 536)                                                      °
  91. XFID ÉFX 'u╜ID w' 'ΣDD' 'u╜(2µw)µ1,wµ0'                                        °
  92.  NIX 2 4 4 0.1844660194174758 ²0.002773925104022206 0.0915395284327323         °
  93.   ²0.3079056865464632 0.07281553398058252 0.138002773925104                    °
  94.   ²0.05409153952843274 ²0.1816920943134535 ²0.03883495145631069                °
  95.   ²0.1497919556171983 ²0.05686546463245491 0.3730929264909847                  °
  96.   ²0.1213592233009709 0.1033287101248266 0.09015256588072122                   °
  97. X ²0.03051317614424412                                                         °
  98.  NIY 2 4 4 1.761904761904763 ²0.3333333333333336 ²0.9761904761904766           °
  99.   0.7142857142857147 ²5.714285714285718 1.000000000000001                      °
  100.   3.071428571428573 ²1.857142857142859 4.523809523809526                       °
  101.   ²0.6666666666666673 ²2.452380952380954 1.42857142857143                      °
  102.   ²2.619047619047621 0.3333333333333337 1.761904761904763                      °
  103. X ²1.142857142857144                                                           °
  104. XNQ 2 3 3 162 179 153 179 262 194 153 194 214                                  °
  105. *(1996 4 6 16 11 30 332)                                                       °
  106. XFRADIANS ÉFX 'U╜RADIANS W' 'U╜ΩW÷180'                                         °
  107. *(1997 9 6 11 18 12 292)                                                       °
  108.  FTEACH ÉFX 'TEACH' 'Σ Start lesson #21: APL2 by Zdenek V JIZBA'               °
  109.   'exit ''TEACH''' 'initialize' 'TEACH1 Σ Matrix algebra'                      °
  110.   'TEACH2 Σ Rotation matrix; vectors and vector length'                        °
  111.   'TEACH3 Σ Dot product'                                                       °
  112.   'TEACH4 Σ Introduction to matrix inverse; diagonal matrices'                 °
  113.   'TEACH5 Σ Grocery store example ; calculating matrix inverse'                °
  114.   'TEACH6 Σ Properties of square matrices; positive definite'                  °
  115. X 'TEACH7 Σ Domino applied to numeric vectors' 'problems'                      °
  116. *(1997 7 22 12 3 51 448)                                                       °
  117.  FTEACH1 ÉFX 'TEACH1;T;X;Y' 'Σ Geometrical interpretation of matrices'         °
  118.   '''In lesson 10 we studied elementary operations on numeric arrays'''        °
  119.   '''called MATRICES. To refresh your memory, we learned that two'''           °
  120.   '''numeric matrices can be added (or subtracted) provided their shape'       °
  121.  '' '''is the same'',r' 'show ''É╜X╜2 3µ∞6'' ''É╜Y╜?2 3µ8'' ''X+Y'''           °
  122.   '''A matrix can be added to (or multiplied by) a scalar'',r'                 °
  123.   'show ''X+0'' ''X⌡2'' ''X-5'' ''X÷2'''                                       °
  124.   '''We also learned that two matrices can be multiplied, but the rules'       °
  125.  '' '''of multiplication require that the last dimension of the left'''        °
  126.   '''matrix be the same as the first dimension of the right matrix.'',r'       °
  127.   'show ''X+.⌡φY'' ''(φX)+.⌡Y'''                                               °
  128.   '''Also, the product is not COMMUTATIVE'',r'                                 °
  129.   'show ''X+.⌡φY'' ''Y+.⌡φX'''                                                 °
  130.   '''Finally, we learned that there is a special matrix, called the'''         °
  131.   '''IDENTITY MATRIX, that returns the original matrix unchanged by'''         °
  132.   '''multiplication'',r' 'T╜ÉEX ''ID'''                                        °
  133.   '1 show ''ID:(2µ∙)µ1,∙µ0'' ''ID 3'' ''X+.⌡ID 3'' ''(ID 2)+.⌡X'''             °
  134.   '''Because of the properties just summarized above, it is possible to'       °
  135.  ''                                                                            °
  136.   '''develop an ALGEBRA based on matrices. We can, for example define'''       °
  137.   '''matrix polynomials. We will define the SQUARE of a matrix as'',r'         °
  138.   'show ''X+.⌡φX'''                                                            °
  139.   '''(To insure that dimensions will match, we have to use ID 2 3)'''          °
  140.   'show ''ID 2 3'' ''5 + (-5⌡X+.⌡φID 2 3) + (X+.⌡φX)'''                        °
  141.   '''This would be roughly equivalent to polynomial Y╜5 + (-5X) + XX'''        °
  142.   '''The only difference is that instead of scalars, X is a numeric matr       °
  143.  ix.''' 'do'                                                                   °
  144.   '''Actually most matrix polynomials deal with SQUARE matrices. In thes       °
  145.  e,''' '''the number of rows and columns is the same'',r'                      °
  146.   'show ''X╜2 2µ∞4'' ''5 + (-5⌡X) + (X+.⌡φX)'''                                °
  147.   '''There are many practical applications of matrix algebra. Some of th       °
  148.  e'''                                                                          °
  149.   '''theoretical foundation of this field is treated in a very abstract'       °
  150.  '' '''and general way. We will attempt to give a simple geometrical'''        °
  151.   '''interpretation of some of these ideas. However, it should be pointe       °
  152.  d'''                                                                          °
  153.   '''out, that these simple geometrical representations cannot always be       °
  154. X''' '''extended to more general cases.''' 'endd'                              °
  155. *(1997 7 22 12 17 40 460)                                                      °
  156.  FTEACH2 ÉFX 'TEACH2;R;V;X;Y;R3;R4'                                            °
  157.   'Σ Rotation matrix, scaling and inversion'                                   °
  158.   '''Consider the following 2⌡2 matrix'',r'                                    °
  159.   'show ''É╜R╜2 2µ.6 ².8 .8 .6'''                                              °
  160.   '''This matrix has the interesting property that its SQUARE is the'''        °
  161.   '''UNIT matrix (we define ''''square'''' here as the expression R+.⌡φR       °
  162.  )'',r' 'show ''R+.⌡φR'''                                                      °
  163.   '''The technical name for such a matrix is UNITARY, but we will call''       °
  164.  '                                                                             °
  165.   '''it a ROTATION MATRIX. To explain why, consider the matrix product''       °
  166.  ' '''(X+.⌡R). First we define X'',r'                                          °
  167.   'show ''É╜X╜4 2µ6 8 5 0 1 3 6 ²2'' ''É╜Y╜X+.⌡R'''                            °
  168.   '''We end up with another numeric array Y. What we want to know is wha       °
  169.  t''' '''does this new array mean?''' 'do' 'show ''X+.⌡φX'' ''Y+.⌡φY'''        °
  170.   '''For one, the square of both X and Y are the same. This means that''       °
  171.  '                                                                             °
  172.   '''the values in Y remain in the same relationship to each other as'''       °
  173.   '''in the original matrix X. If you treat the rows of X as points to b       °
  174.  e'''                                                                          °
  175.   '''plotted on a cartesian graph, then it is easy to explain the effect       °
  176.  '''                                                                           °
  177.   '''of matrix R. When the rows of Y are plotted on the same graph, the'       °
  178.  ''                                                                            °
  179.   '''new points have been moved as if rotated on an axis perpendicular t       °
  180.  o'''                                                                          °
  181.   '''the plane of the plot, and passing through the origin of the graph.       °
  182.  ''' 'do'                                                                      °
  183.   '''In fact, the rotation is counter clockwise, and the cosine of the''       °
  184.  ' '''angle is'',r' 'show ''²3Ω÷/ΦR[1;]'''                                     °
  185.   '''Just to verify that this INVARIANCE applies to matrices of any size       °
  186.  ,''' '''let us try some more examples'',r'                                    °
  187.   'show ''É╜R3╜3 3µ.01⌡64 ²60 ²48 48 80 ²36 60 0 80'''                         °
  188.   '''R3 is a three dimensional rotation matrix'',r'                            °
  189.   'show ''15«R3+.⌡φR3'' ''É╜X╜3 3µ4 8 ²4 5 15 16 ²3 ²6 13'' ''É╜Y╜X+.⌡R3       °
  190.  ''' '''The squares X+.⌡φX and Y+.⌡φY should be the same'',r'                  °
  191.   'show ''X+.⌡φX'' ''Y+.⌡φY'''                                                 °
  192.   '''We can also try a four dimensional unitary matrix'',r'                    °
  193.   'R4╜4 4µ0.01⌡64 ²48 ²36 ²48 48 64 48 ²36 ²36 ²48 64 ²48 48 ²36 48 64'        °
  194.   'X╜3 4µ18 1 19 8 4 8 ²4 7 2 ²6 ²5 10'                                        °
  195.   'show ''R4'' ''15«R4+.⌡φR4'' ''X'' ''É╜Y╜X+.⌡R4'' ''X+.⌡φX'' ''Y+.⌡φY'       °
  196.  '' '''WORKING WITH VECTORS'',r'                                               °
  197.   '''To better understand what these numeric manipulations mean, it is''       °
  198.  '                                                                             °
  199.   '''useful to discuss the concept of VECTORS. Consider the point V2 on'       °
  200.  '' '''the following graph'',r' 'vec ''X'' ''V2'' ''Y'''                       °
  201.   '''The directed line starting at the origin and ending at point V2 is'       °
  202.  ''                                                                            °
  203.   '''called a VECTOR. It''''s coordinates are 2 2, and its length by the       °
  204.  '''                                                                           °
  205.   '''theorem of Pythagoras is 8*.5 (or 2⌡2*2). Suppose now that we add''       °
  206.  '                                                                             °
  207.   '''another number to vector V2╜2 2, say another 2 (V3╜2 2 2). Then we'       °
  208.  ''                                                                            °
  209.   '''can display the vector V2 against this new value. (We shall call th       °
  210.  is''' '''new coordinate Z)''' 'do' '''..⌡'' vec ''V2'' ''V3'' ''Z'''          °
  211.   '''By theorem of Pythagoras, the length of vector V3 is ((V2*2)+2*2)*.       °
  212.  5'''                                                                          °
  213.   '''or 12*.5 (or 3⌡2*2). We can add yet more elements to the vector. Ea       °
  214.  ch'''                                                                         °
  215.   '''time the length of the new vector can be found by adding the square       °
  216.  '''                                                                           °
  217.   '''of the new coordinate to the sum of squares of the preceeding ones,       °
  218.  ''' '''and taking the square root of the sum.''' 'do'                         °
  219.   '''In other words, given vector V'',r' 'show ''V╜?5µ10'' ''V'''              °
  220.   '''the expressions'',r' 'show ''(+/V*2)*.5'' ''(V+.⌡φV)*.5'''                °
  221.   '''return the length of vector V, NO MATTER HOW MANY ELEMENTS V has!''       °
  222.  '                                                                             °
  223.   '''Note that the expression V+.⌡φV produces the same result as +/V*2.'       °
  224.  ''                                                                            °
  225.   '''There is a good reason for this expression as we will see next.'''        °
  226. X 'endd'                                                                       °
  227. *(1997 7 22 12 21 37 464)                                                      °
  228.  FTEACH3 ÉFX 'TEACH3;A;B;T;X;Y;Va;Vb;LX;LY;R3' 'Σ Dot product'                 °
  229.   '''DOT PRODUCT'',r'                                                          °
  230.   '''Consider two vectors Va and Vb. We can ask for the meanimg of the''       °
  231.  ' '''expression Va+.⌡φVb'',r' 'show ''(Va╜2 4 6 3)+.⌡φVb╜1 5 7 2'''           °
  232.   '''This expression is known as the DOT PRODUCT. Recalling that rotatio       °
  233.  n'''                                                                          °
  234.   '''does not change the result, we can align Va with the X axis, and pl       °
  235.  ace''' '''Vb in the X,Y plane'',r'                                            °
  236.   '''...|.⌡Va'' vec '' X'' ''Vb'' ''Y''' 'do'                                  °
  237.   '''In this orientation, the X component of Va is the length of Va. The       °
  238.  '''                                                                           °
  239.   '''components of Va in all other dimensions are zero. The X component'       °
  240.  ''                                                                            °
  241.   '''of Vb along the X axis is Vb⌡2Ωα, where α is the angle between the'       °
  242.  ''                                                                            °
  243.   '''two vectors. It follows therefore that the expression Va+.⌡φVb give       °
  244.  s'''                                                                          °
  245.   '''the product of the lengths of the two vectors times the COSINE of t       °
  246.  he''' '''angle between them.''' 'do'                                          °
  247.   '''In the above example, we have'',r'                                        °
  248.   'show ''É╜A╜(+/Va*2)*.5'' ''É╜B╜(+/Vb*2)*.5'''                               °
  249.   '''Even though the two vectors have four components (four dimensions),       °
  250.  '''                                                                           °
  251.   '''we can readily calculate the angle between them. First we define'',       °
  252.  r' 'T╜ÉEX ''COSINES'''                                                        °
  253.   '1 show ''COSINES:²2Ω(α+.⌡φ∙)÷((+/α*2)°.⌡+/∙*2)*.5'''                        °
  254.   'show ''DEGREES Va COSINES Vb'''                                             °
  255.   '''With this knowledge, we can now explain the geometric meaning of'''       °
  256.   '''a rotation matrix'',r' 'R3╜3 3µ0.01⌡64 ²60 ²48 48 80 ²36 60 0 80'         °
  257.   'show ''R3'' ''+/R3*2'' ''15«R3+.⌡φR3'''                                     °
  258.   '''The second expression shows that the vectors of a rotation matrix''       °
  259.  '                                                                             °
  260.   '''have length 1. The last expression shows that the three vectors are       °
  261.  '''                                                                           °
  262.   '''at right angles to each other, since the COS of 90 degrees is zero.       °
  263.  ''' 'do'                                                                      °
  264.   '''Finally, we can also explain why rotation does not change the resul       °
  265.  t''' '''of expression X+.⌡φX where X is a numeric array'',r'                  °
  266.   'X╜3 4µ18 1 19 8 4 8 ²4 7 2 ²6 ²5 10'                                        °
  267.   'Y╜3 4µ9 ²20 10 ²13 11.2 2.6 3.2 1.6 5 ²6 ²2 10'                             °
  268.   '''In our previous example we had'',r'                                       °
  269.   'show ''X'' ''X+.⌡φX'' ''Y'' ''Y+.⌡φY'''                                     °
  270.   '''We can verify that the vectors (rows) of X have the same length as'       °
  271.  '' '''the rows of Y'',r'                                                      °
  272.   'show ''É╜LX╜(+/X*2)*.5'' ''É╜LY╜(+/Y*2)*.5'''                               °
  273.   '''And the angles between each pair of these vectors is the same'',r'        °
  274. X 'show ''DEGREES X COSINES X'' ''DEGREES Y COSINES Y''' 'endd'                °
  275. *(1997 7 22 12 28 36 488)                                                      °
  276.  FTEACH4 ÉFX 'TEACH4;R3;C;D;R;S;X;Y;DI' 'Σ The inverse of a matrix'            °
  277.   '''THE MATRIX INVERSE'',r'                                                   °
  278.   '''It is not our intention here to give a lecture on matrix algebra.''       °
  279.  '                                                                             °
  280.   '''Actually we are leading towards the introduction of an important'''       °
  281.   '''primitive function of APL2 called the MATRIX INVERSE. If this'''          °
  282.   '''function is to make any sense at all, some elementary concepts'''         °
  283.   '''such as those discussed above are useful. Before we introduce the''       °
  284.  '                                                                             °
  285.   '''inverse, we have to describe yet another type of matrix, called'''        °
  286.   '''a DIAGONAL matrix'',r' 'R3╜3 3µ0.01⌡64 ²60 ²48 48 80 ²36 60 0 80'         °
  287.   'show ''É╜D╜3 3µ2 5 4'' ''1 1φD'''                                           °
  288.   '''(You will recall from lesson 8 that the expression 1 1φ extracts th       °
  289.  e''' '''diagonal elements of an array of rank 2.)'',r'                        °
  290.   'show ''D╜D⌡ID 3'' ''D'''                                                    °
  291.   '''One way to form a diagonal matrix is to first generate one that'''        °
  292.   '''has the desired values in the diagonal as illustrated by the first'       °
  293.  ''                                                                            °
  294.   '''expression. Simple multiplication of this matrix by the identity'''       °
  295.   '''matrix sets all of-diagonal values to zero.''' 'do'                       °
  296.   '''To see what effect a diagonal matrix has, we do a matrix product wi       °
  297.  th''' '''the rotation matrix R3'',r' 'show ''R3'' ''É╜R╜D+.⌡R3'''             °
  298.   '''The rows of this product matrix have been multiplied by the values'       °
  299.  '' '''in the diagonal (2 5 4). To multiply the columns, we write'',r'         °
  300.   'show ''É╜C╜R3+.⌡D'''                                                        °
  301.   '''Suppose now that we desire to reverse the process. What we need is'       °
  302.  ''                                                                            °
  303.   '''to be able to divide the rows and columns by the elements of the'''       °
  304.   '''diagonal. One way to do that is to generate another diagonal matrix       °
  305.  ''' '''with elements that are reciprocals of the values in D'',r'             °
  306.   'show ''É╜DI╜(ID 3)⌡3 3µ÷2 5 4'' ''C+.⌡DI'' ''DI+.⌡R'''                      °
  307.   '''Actually, there is a simpler way to find DI, the INVERSE of D'',r'        °
  308.   'show ''ÆD'''                                                                °
  309.   '''The symbol Æ (press Alt and ⌡) is called the DOMINO. When used'''         °
  310.   '''monadically it generates a matrix INVERSE. Basically, the inverse''       °
  311.  ' '''can be thought of as a generalization of the divide symbol ÷'',r'        °
  312.   'show ''÷2 5'' ''Æ■2 5'''                                                    °
  313.   '''and as the example above shows, will produce the same results when'       °
  314.  ''                                                                            °
  315.   '''applied to numeric scalars. However for the same reason that we get       °
  316.  ''' '''a DOMAIN ERROR with'',r' 'show ''÷2 4 0'''                             °
  317.   '''there are some special matrices (called SINGULAR) that also have'''       °
  318.   '''no inverse'',r' 'show ''É╜S╜(ID 3)⌡3 3µ2 4 0'' ''ÆS'''                    °
  319.   '''What effect does matrix product with a diagonal matrix have? It'''        °
  320.   '''can be thought of as re-scaling of the axes'',r'                          °
  321.   'show ''15«R3+.⌡φR3'' ''R+.⌡φR'''                                            °
  322.   '''The components of R no longer have unit lengths. If the vectors for       °
  323.  ming'''                                                                       °
  324.   '''a matrix are not orthogonal, then a product with the diagonal also'       °
  325.  '' '''changes the angles'',r'                                                 °
  326.   'show ''É╜X╜2 3µ4 8 ²4 5 15 16'' ''Y╜X+.⌡D'' ''X COSINES X'' ''Y COSIN       °
  327. XES Y''' 'endd'                                                                °
  328. *(1997 7 22 12 36 28 488)                                                      °
  329.  FTEACH5 ÉFX 'TEACH5;L;INB;BUY;PRICE;COST' 'Σ Solving linear equations'        °
  330.   '''Naturally, there is more to the inverse than just taking the recipr       °
  331.  ocals'''                                                                      °
  332.   '''of a diagonal matrix. To illustrate a general case of matrix invers       °
  333.  e,''' '''we will use the following example:'',r'                              °
  334.   '''Suppose that a grocery store sells certain fruit by the piece: an a       °
  335.  pple'''                                                                       °
  336.   '''for 30 cents, an orange for 40 cents, and a banana for 50 cents. On       °
  337.  e'''                                                                          °
  338.   '''customer buys two apples one orange and one banana, and pays $1.50'       °
  339.  ''                                                                            °
  340.   '''While a second customer pays $2.10 for one apple, two oranges and''       °
  341.  '                                                                             °
  342.   '''two bananas. A third customer is charged $2.20 for three apples,'''       °
  343.   '''two oranges and one banana.''' 'do'                                       °
  344.   '''We can readily calculate the tab for each customer using matrix'''        °
  345.   '''multiplication. To do that, we define a matrix BUY, with rows'''          °
  346.   '''corresponding to customers, and columns corresponding to the items'       °
  347.  '' '''being purchased'',r' 'show ''É╜BUY╜3 3µ2 1 1 1 2 2 3 2 1'''             °
  348.   '''We also have the array PRICE for the cost of individual items'',r'        °
  349.   'show ''É╜PRICE╜0.30 0.40 0.50'''                                            °
  350.   '''To find out how much each customer has to pay, we multiply BUY by''       °
  351.  ' '''PRICE to get COST'',r' 'show ''É╜COST╜BUY+.⌡PRICE'''                     °
  352.   '''But now suppose we forgot the values in PRICE. Can we recover this'       °
  353.  ''                                                                            °
  354.   '''information from BUY and COST? The answer is yes. One way is to'''        °
  355.   '''find the INVERSE of BUY'',r'                                              °
  356.   'show ''INB╜ÆBUY'' ''('''' $0.59'''')«INB+.⌡COST'''                          °
  357.   '''The process of generating the inverse is a fairly simple procedure'       °
  358.  ''                                                                            °
  359.   '''There are many algorithms to do it, but the fastest one still takes       °
  360.  '''                                                                           °
  361.   '''N*3 times, so it is a cubic algorithm. Here is an example of how'''       °
  362.   '''you might do it with a pencil and paper. Given'',r' 'show ''BUY'''        °
  363.   '''we want to calculate'',r' 'show ''ÆBUY'''                                 °
  364.   '''We begin by catenating BUY with ID 3''' 'show ''É╜L╜BUY,ID 3'''           °
  365.   '''We follow these two rules:'',r'                                           °
  366.   '''     1. Any row can be multiplied by a constant'''                        °
  367.   '''     2. Any row can be replaced by adding another row to it'',r'          °
  368.   '''With these two rules, we try to convert the first three columns'''        °
  369.   '''to an identity (diagonal) matrix. We begin by adding ²1 times the''       °
  370.  '                                                                             °
  371.   '''third row to the first row. Our plan of action is to first set the'       °
  372.  ''                                                                            °
  373.   '''upper off diagonals to zero. Then we set the lower off diagonals to       °
  374.  ''' '''zero, and finally we set the diagonal values to one'',r'               °
  375.   'show ''L[1;]╜-≡L[1 3;]'' ''L''' 'show ''L[2;]╜L[2;]-2⌡L[3;]'' ''L'''        °
  376.   'show ''L[1;]╜-L[2;]-2⌡L[1;]'' ''L'''                                        °
  377.   'show ''L[2;]╜(5⌡L[1;])+3⌡L[2;]'' ''L'''                                     °
  378.   'show ''L[3;]╜-≡L[1 3;]'' ''L''' 'show ''L[3;]╜L[2;]-3⌡L[3;]'' ''L'''        °
  379.   'show ''L╜L÷3'' ''L'''                                                       °
  380.   'show ''L[2;]╜L[2;]÷²2'' ''L'' ''0 3╟L'' ''INB'''                            °
  381.   '''The example we have used to illustrate the usage of matrix inverse'       °
  382.  ''                                                                            °
  383.   '''is actually best solved using the dyadic form of the domino functio       °
  384. Xn.''' '''We will study that in the next lesson.''' 'endd'                     °
  385. *(1997 7 23 13 29 8 388)                                                       °
  386.  FTEACH6 ÉFX 'TEACH6;R4' 'Σ Properties of the inverse'                         °
  387.   '''   PROPERTIES OF THE MATRIX INVERSE'',r'                                  °
  388.   '''We will finish this lesson with a brief summary of the more'''            °
  389.   '''important relationships in matrix algebra.'',r'                           °
  390.   '''We have already seen that matrix multiplication is not commutative.       °
  391.  '''                                                                           °
  392.   '''This word means that for any two numeric arrays X and Y, the inner'       °
  393.  '' '''products X+.⌡Y and Y+.⌡X are not the same'',r'                          °
  394.   'show ''É╜X╜?3 4µ10'' ''É╜Y╜?4 3µ10'' ''X+.⌡Y'' ''Y+.⌡X'''                   °
  395.   '''The two products do not even have the same dimensions. Their diagon       °
  396.  als,''' '''however, have the same sum'',r'                                    °
  397.   'show ''+/1 1φX+.⌡Y ╪ +/1 1 φY+.⌡X'''                                        °
  398.   '''When both X and Y are square and of the same size, we can say a lot       °
  399.  ''' '''more about their product'',r'                                          °
  400.   'show ''É╜X╜?4 4µ10'' ''É╜Y╜?4 4µ10'''                                       °
  401.   '''The two ways of forming the inner product can be related'',r'             °
  402.   'show ''φX+.⌡Y'' ''(φY)+.⌡φX'''                                              °
  403.   '''The rule that applies here can be phrased as follows: THE TRANSPOSE       °
  404.  '''                                                                           °
  405.   '''OF A PRODUCT IS THE SAME AS THE PRODUCT OF THE TRANSPOSES IN REVERS       °
  406.  E''' '''ORDER.'',r' 'do'                                                      °
  407.   '''The inverse of a matrix exists only for a special kind of square'''       °
  408.   '''matrices called NON-SINGULAR. (The odds are that both X and Y are''       °
  409.  ' '''non singular. If in the following expressions you get a DOMAIN'''        °
  410.   '''ERROR, re-define X [or Y] and try again.) We form the inverses of''       °
  411.  ' '''X and Y'',r' 'show ''IX╜ÆX'' ''IY╜ÆY'''                                  °
  412.   '''First let us see the products of X and IX'',r'                            °
  413.   'show ''X+.⌡IX'' ''IX+.⌡X'''                                                 °
  414.   '''Both products return the identity matrix accurate to at least 15'''       °
  415.   '''significant digits. This should be no surprise, since the transpose       °
  416.  '''                                                                           °
  417.   '''of the identity matrix is also the identity matrix. But now let us'       °
  418.  '' '''try to invert the product of X and Y''' 'do'                            °
  419.   'show ''ÆX+.⌡Y'' ''IY+.⌡IX'''                                                °
  420.   '''This is very analogous to the transpose of of a product. Indeed we'       °
  421.  ''                                                                            °
  422.   '''have the following rule: THE INVERSE OF A PRODUCT IS THE SAME AS TH       °
  423.  E''' '''PRODUCT OF THE INVERSES IN REVERSE ORDER.''' 'do'                     °
  424.   '''Now what about UNITARY (rotation matrices)? Consider R4'',r'              °
  425.   'R4╜4 4µ0.01⌡64 ²48 ²36 ²48 48 64 48 ²36 ²36 ²48 64 ²48 48 ²36 48 64'        °
  426.   'show ''R4'' ''R4+.⌡φR4'' ''R4+.⌡ÆR4'''                                      °
  427.   '''Since both the transpose and the inverse produce the same identity'       °
  428.  '' '''matrix, it follows that the two are the same'',r'                       °
  429.   'show ''(φR4)╧ÆR4'''                                                         °
  430.   '''Finally, we should make a remark about the product of a matrix'''         °
  431.   '''(not necesarily square) with its own transpose. Before we do that''       °
  432.  ' '''consider the following polynomial'',r'                                   °
  433.   ''' (X+Y)*2 ╜ ╕ (X*2) + (2⌡X⌡Y) + Y*2''' 'do'                                °
  434.   '''We can write this in the form of an array'',r'                            °
  435.   '''       X*2     X⌡Y''' '''       X⌡Y     Y*2'',r'                          °
  436.   '''We can even generalize this'',r'                                          °
  437.   ''' (X+Y+Z)*2 ╜ ╕ (X*2) + (Y*2) + (Z*2) + (2⌡X⌡Y) + (2⌡X⌡Z) + 2⌡Y⌡Z'',       °
  438.  r' '''and in tabular form'',r' '''       X*2     X⌡Y    X⌡Z'''                °
  439.   '''       X⌡Y     Y*2    Y⌡Z''' '''       X⌡Z     Y⌡Z    Z*2'',r'            °
  440.   '''Now, when we define X as''' 'do' 'show ''É╜X╜?3 5µ10'''                   °
  441.   '''We can think of each row as a VECTOR. The product X+.⌡φX therefore'       °
  442.  ''                                                                            °
  443.   '''represents a DOT product of each vector with every other vector.'',       °
  444.  r' 'show ''É╜Q╜X+.⌡φX'''                                                      °
  445.   '''The diagonals contain the SUM OF SQUARES of the vectors of X, and t       °
  446.  he'''                                                                         °
  447.   '''off diagonals are the dot products of vector pairs. Because of the'       °
  448.  ''                                                                            °
  449.   '''analogy with squares of polynomials (actually it is more than that)       °
  450.  '''                                                                           °
  451.   '''the resuting array has a special name. It is called a QUADRATIC FOR       °
  452.  M.'''                                                                         °
  453.   '''The matrix Q also has many interesting, and computationally importa       °
  454.  nt'''                                                                         °
  455.   '''properties. It is often referred to by one of its properties, namel       °
  456. Xy''' '''a POSITIVE DEFINITE matrix.''' 'endd'                                 °
  457. *(1997 7 23 13 33 34 508)                                                      °
  458.  FTEACH7 ÉFX 'TEACH7' 'Σ Domino with vectors'                                  °
  459.   '''VECTOR ARGUMENT TO DOMINO'',r'                                            °
  460.   '''Finally, if the domino is applied to a vector, the result will'''         °
  461.   '''be another vector'',r' 'show ''É╜V2╜ÆV1╜2 3 4'''                          °
  462.   '''The dot product of these two vectors is 1'',r' 'show ''V1+.⌡V2'''         °
  463. X 'endd'                                                                       °
  464. *(1996 4 6 16 11 30 332)                                                       °
  465.  FTIME ÉFX 'U╜V TIME W;T' 'Σ Measure execution time of W'                      °
  466. X 'U╜60 60 1000¥²3╞ÉTS' 'T╜»■VµΓW' 'U╜(,-U-60 60 1000¥²3╞ÉTS)÷V'               °
  467. XNV1 1 3 2 3 4                                                                 °
  468. XNV2 1 3 0.06896551724137931 0.103448275862069 0.1379310344827586              °
  469. XNX 2 3 5 10 1 6 4 3 10 6 5 10 1 8 8 9 2 1                                     °
  470. XNY 2 4 4 3 3 4 2 5 9 10 1 10 6 6 4 10 5 3 1                                   °
  471. *(1997 7 13 12 28 49 504)                                                      °
  472.  Faddquote ÉFX 'u╜addquote w'                                                  °
  473.   'Σ Put quotes around a string, and double existing quotes'                   °
  474. X 'u╜ÉAV[40],((1+w=ÉAV[40])/w),ÉAV[40]'                                        °
  475. *(1996 4 6 16 11 30 332)                                                       °
  476. XFaq ÉFX 'U╜aq W' 'U╜Γaddquote W'                                              °
  477. *(1997 7 24 13 20 38 476)                                                      °
  478.  Fav ÉFX 'av;A;N;I;ÉIO' 'Σ Display characters in ÉAV' 'ÉIO╜0'                  °
  479.   'A╜22 78µ'' ''' 'N╜3 0«φ12 22µ1+∞356' 'A[;,(6⌡∞12)°.+2 3 4]╜N'               °
  480.   'A[;6+6⌡∞12]╜φ12 22µÉAV' 'ΣA[8 10 13;6]╜'' ''' 'A[13;6]╜'' '''               °
  481. X 'A[14+∞8;68 69 70 72]╜'' ''' 'A'                                             °
  482. *(1991 11 11 8 25 13 316)                                                      °
  483.  Fdate ÉFX 'u╜date w' 'Σ Format date and time of day' 'u╜«6╞w'                 °
  484. X 'u╜('' ''⌠u)Γu' 'u╜εu,■''-- .. '''                                           °
  485. XCdig 1 10 1234567890                                                          °
  486. *(1997 9 9 13 0 45 372)                                                        °
  487.  Fdisclaimer ÉFX 'disclaimer' 'Σ Copyright statement'                          °
  488.   '(10µ'' ''),''Copyright, Z. V. Jizba, 1995,1996,1997'',r'                    °
  489.   ''' This and subsequent workspaces labelled TEACHxx are made available       °
  490.  '''                                                                           °
  491.   '''at no cost to anyone who desires to learn how to use effectively'''       °
  492.   '''the IBM/OS2 version of APL2.'',r'                                         °
  493.   '''This software is provided "AS IS" with no WARRANTY of any kind, eit       °
  494.  her'''                                                                        °
  495.   '''express or implied. Any risk in its use resides with you, the user        °
  496.  of''' '''these tutorials.'',r' '''     ACKNOWLEDGEMENTS'',r'                  °
  497.   ''' In writing these tutorials, I am greatly indebted to Roy Sykes, wh       °
  498.  ose'''                                                                        °
  499.   '''excellent lectures increased my understanding of the language.'''         °
  500.   '''Discussions with the late Harry Bertucelli clarified a number of'''       °
  501.   '''concepts and caused me to change some improper terminology that was       °
  502.  '''                                                                           °
  503.   '''used in previous versions of these tutorials. Mr. Benjamin Archer''       °
  504.  '                                                                             °
  505.   '''kindly checked out a nearly final version, bringing to my attention       °
  506.  ''' '''some ommisions, misspellings, and invalid terminology.'',r'            °
  507. X '''(PRESS ENTER to continue)'''                                              °
  508. *(1997 7 13 12 28 50 508)                                                      °
  509.  Fdo ÉFX 'do;T;E' 'Σ Expression driver' 'E╜''''' 'æ╜''      ''' 'T╜æ'          °
  510.   '╕(^/'' ''=T)/0'                                                             °
  511.   '╕(('':''εT)doif ''B╜evaldd (+/^\'''' ''''=T)╟T'')/2'                        °
  512.   '''E╜ÉEM'' ÉEA T' '╕(0=µ,E)/2'                                               °
  513.   '''This is not a valid APL2 expression''' 'æ╜''*''' '╕(''?''⌠╞1╟æ)/2'        °
  514. X 'E' '╕2'                                                                     °
  515. *(1997 7 13 12 28 50 508)                                                      °
  516.  Fdoif ÉFX 'U╢╜V╢ doif W╢;t╢' 'Σ Rule' '╕(^/~U╢╜V╢)/0'                         °
  517. X '''U╢╜V╢ doif■ W╢'' ÉEA ''»V╢/W╢'''                                          °
  518. *(1997 9 9 12 50 14 444)                                                       °
  519.  Fendd ÉFX 'endd' 'Σ end of special feature' '20µ''²'' ╪ ╕(4<µÉLC)/0'          °
  520. X 'do'                                                                         °
  521. *(1997 8 21 13 16 53 512)                                                      °
  522.  Ferase ÉFX                                                                    °
  523.   'erase;t;EXIT;GO;HELP;DISPLAY;BIND;TIME;ID;DEGREES;RADIANS;COSINES;DIS       °
  524.  CLAIMER' 'Σ Erase all global functions and variables' 't╜ÉNL 3'               °
  525.   't╜(~t^.εlc,'' '')≡t' 't╜ÉEX(~t[;∞5]^.=''TEACH'')≡t' 't╜ÉNL 2'               °
  526. X 't╜ÉEX(~t^.εlc,'' '')≡t' 't╜ÉNL 4' 't╜ÉEX(~t^.εlc,'' '')≡t'                  °
  527. *(1997 7 27 13 47 41 608)                                                      °
  528.  Fevaldd ÉFX 'u╜evaldd w;c;n' 'Σ Evaluate direct definition' 'u╜0'             °
  529.   'n╜(w∞''Σ'')-1' 'c╜(((n╞w)⌠'':'')Γn╞w),Γ''ΣDD '',(n+1)╟w'                    °
  530.   '╕((1 label╞c)doif ''''''Invalid label'''''')/0'                             °
  531.   '╕((2=µc)doif ''u╜showdd 1╙c'')/0'                                           °
  532.   '╕((3=ÉNC╞c)doif ''u╜⌡µÉ╜(╞c),'''' is already defined.'''''')/0'             °
  533.   '╕((3=µc)doif ''u╜simdd c'')/0' 'c╜(Γ''α∙ aw'')replace■c'                    °
  534.   'u╜ε''u╜'',((''a''εεc[2 3 4])/''a ''),(╞c),'' w;t;b'''                       °
  535.   'u╜u(5πc)(''b╜(t╜'',(3πc),'')/'',addquote ''u╜'',4πc)'                       °
  536. X 'u╜u,''╕(t doif b)/0''(''u╜'',2πc)' 'u╜╧ÉFX u'                               °
  537. *(1997 7 25 13 27 52 564)                                                      °
  538.  Fexit ÉFX 'V exit W;T' 'Σ Exit if too many suspended functions'               °
  539.   '╕(0⌠ÉNC ''V'')/L0 ╪ V╜10' 'L0:╕(V>µÉLC)/0'                                  °
  540.   '''There are too many suspended functions''' '''Please enter '',W'           °
  541. X '╕'                                                                          °
  542. *(1997 7 26 12 33 39 536)                                                      °
  543.  Fget ÉFX 'U╜V get W;t;T;ÉPR' 'Σ Prompt for response from keyboard'            °
  544.   'ÉPR╜T╜ÉAV[ÉIO+255] ╪ ╕(0⌠ÉNC ''V'')/L0 ╪ V╜1' 'L0:V╜V╧1' 'æ╜W ╪ t╜æ'        °
  545.   'U╜(+/^\t=T)╟t' '╕(''╕''⌠╞U)/L1 ╪ ╕' 'L1:╕V/0' 't╜(U⌠'' '')ΓU'               °
  546. X 'U╜(µt),(ΓU),t'                                                              °
  547. *(1997 7 28 13 33 8 424)                                                       °
  548.  Fglobals ÉFX 'globals' 'Σ Initialize useful global variables'                 °
  549.   'uc╜''ABCDEFGHIJKLMNOPQRSTUVWXYZ'''                                          °
  550.   'lc╜''abcdefghijklmnopqrstuvwxyz''' 'dig╜''1234567890'''                     °
  551. X 'r╜ÉAV[13+ÉIO]' 'q╜'''''''''                                                 °
  552. *(1997 7 3 12 47 6 368)                                                        °
  553.  Finitialize ÉFX 'initialize;T' 'Σ Initialize workspace'                       °
  554.   '''AT ALL TIMES, TO CONTINUE, PRESS RETURN!'',r'                             °
  555.   '''To see disclaimers enter:'',r,''    disclaimer''' 'do' 'erase'            °
  556.   'globals'                                                                    °
  557.   '''Make sure the CAP LOCK light on your keyboard (upper right) is ON!'       °
  558. X'' 'endd'                                                                     °
  559. *(1997 7 27 13 14 33 444)                                                      °
  560.  Flabel ÉFX 'u╜v label w'                                                      °
  561.   'Σ Return 1 if label w does not begin with a cap'                            °
  562.   '╕(0⌠ÉNC ''v'')/L0 ╪ v╜0' 'L0:v╜v╧1 ╪ w╜εw ╪ ╕v/L1 ╪ ╕(u╜0⌠ÉNC w)/0'         °
  563. X 'L1:╕(u╜~^/wεlc,uc,dig)/0' 'u╜w[1]εlc,dig'                                   °
  564. XClc 1 26 abcdefghijklmnopqrstuvwxyz                                           °
  565. *(1997 7 13 12 28 55 528)                                                      °
  566.  Fnon ÉFX 'non;T;RC;ET;R' 'Σ Ignore keyboard entry' 'æ╜''      ''' 'T╜æ'       °
  567.   '╕(0=µ(T⌠'' '')/T)/0' '(RC ET R)╜ÉEC T' '╕(0=RC)/2'                          °
  568. X '╕((1=RC)doif ''R'')/2' '╕2'                                                 °
  569. *(1997 7 13 12 28 55 528)                                                      °
  570.  Fnotb ÉFX 'u╜notb w' 'Σ Remove trailing blanks'                               °
  571.   '╕((1<╧w)doif ''u╜notb■ w'')/0' '╕((1<µµw)doif ''u╜πnotb Γ[2]w'')/0'         °
  572. X 'u╜(1-(,'' ''⌠Φw)∞1)╟w'                                                      °
  573. *(1996 4 6 16 11 30 332)                                                       °
  574.  Fpause ÉFX 'V pause W;T'                                                      °
  575.   'Σ Pause, then print W V spaces right and return'                            °
  576. X 'T╜(0=ÉNC ''V'')doif ''V╜6''' 'do' '(Vµ'' ''),W' 'do'                        °
  577. *(1997 7 27 12 55 6 496)                                                       °
  578.  Fproblems ÉFX 'problems' 'Σ Problems'                                         °
  579.   '''That is all for this lesson. Remember, if you want to practice,'''        °
  580.   '''and plan to use direct definitions, be sure to first enter GO.'''         °
  581.   '''Direct definitions will then be accepted. To exit GO, enter EXIT.''       °
  582.  ,r'                                                                           °
  583.   '''To erase a previously defined DIRECT DEFINITION FUNCTION, enter'',r       °
  584.  ' '''       )ERASE functionname'',r'                                          °
  585. X '''WARNING! do not use )ERASE on other labels.'',r'                          °
  586. XCq 0 '                                                                        °
  587. XCr 0                                                                         °
  588. *(1997 7 13 12 28 56 532)                                                      °
  589.  Freplace ÉFX 'u╜v replace u;i;r;s' 'Σ Replace elements in v in u'             °
  590.   'i╜Γ∞µu' 's╜2πv╜(v⌠'' '')Γv' 'i╜⌡r╜i⌡■Γ[1]u°.=╞v'                            °
  591. X 'u[(εi)/εr]╜s[(εi)/εi⌡■∞µs]'                                                 °
  592. *(1997 7 13 12 28 56 532)                                                      °
  593.  Fround ÉFX 'U╜V round W' 'Σ Half adjust to V th decimal'                      °
  594. X 'U╜(╛0.5+W⌡10*V)÷10*V'                                                       °
  595. *(1997 7 13 12 28 57 536)                                                      °
  596.  Fshow ÉFX '╢V show ╢W;╢T;╢B' 'Σ Display and execute ╢W'                       °
  597.   '╢T╜(0=ÉNC ''╢V'')doif ''╢V╜0'''                                             °
  598.   '╕((0=╧╢W)doif ''show ╢W,'''' '''''')/0'                                     °
  599.   '╕((1<╧╢W)doif ''╢V show ■╢W'')/0' '''      '',╢W'                           °
  600. X '╕((╢V^'':''ε╢W)doif ''╢T╜evaldd ╢W'')/L0' '''ÉEM'' ÉEA ╢W' 'L0:do'          °
  601. *(1997 7 13 12 28 57 536)                                                      °
  602.  Fshowdd ÉFX 'u╜showdd w;a;b;c;r'                                              °
  603.   'Σ Display a direct definition function'                                     °
  604.   '╕((1=╧w)doif ''u╜showdd Γw'')/u╜0'                                          °
  605.   '╕((3⌠ÉNC╞w)doif ''(ε╞w),'''' is not a function'''''')/0'                    °
  606.   'c╜Γ[2]ÉCR╞w' 'c╜notb(2╞c),(Γ''aw α∙'')replace■2╟c'                          °
  607.   '╕((~''ΣDD''╧3╞2πc)doif ''''''Not a direct definition function'''''')/       °
  608.  0' 'u╜1' 'b╜('' ''⌠╞c)Γ╞c' 'a╜''      ''' 'r╜2╟3πc'                           °
  609.   '╕((3=µc)doif ''a,(╞w),'''':'''',r,(3<µ2πc)/''''   Σ'''',3╟2πc'')/0'         °
  610.   'a╜a,(╞w),'':'',(2╟5πc),'':''' 'b╜(+\r=''('')-+\r='')''' 'b╜b∞0'             °
  611. X 'a╜a,(²3╟(b-1)╞3╟r),'':'',2╟»(b+2)╟r' 'a,(3<µ2πc)/''  Σ'',3╟2πc'             °
  612. *(1997 7 13 12 28 57 536)                                                      °
  613.  Fshowfn ÉFX 'U╜V showfn W;F;N;T;ÉIO' 'Σ Simulate ╖W[É]'                       °
  614.   'T╜(0=ÉNC ''V'')doif ''V╜0''' 'ÉIO╜0'                                        °
  615.   'U╜r,''      '',''╖'',W,''[É]'',(╞V)╞''╖''' 'N╜1╞µF╜ÉCR W' 'N╜«∞N'           °
  616.   'N╜(N⌠'' '')ΓN' 'F╜(π''['',■N,■Γ''] ''),F'                                   °
  617.   'T╜(1<µ,V)doif ''F╜F[1╟V;]'' ''U╜''''''''''' 'U╜²1╟U,r,,F,r'                 °
  618. X 'U╜((-+/^\'' ''=ΦU)╟U),('' ╖'')[╞V],r'                                       °
  619. *(1997 7 13 12 28 58 540)                                                      °
  620.  Fsimdd ÉFX 'u╜simdd w;e' 'Σ Direct definition mode' 'u╜0'                     °
  621.   '╕((0⌠ÉNC╞w)doif ''''''Already defined'''''')/0' 'e╜''α''ε2πw'               °
  622.   'w[2]╜Γ''u╜'',''α∙ aw'' replace 2πw' 'w╜w[1 3 2]'                            °
  623. X 'w[1]╜Γε''u╜'',(e/''a ''),w[1],'' w''' 'u╜╧ÉFX w'                            °
  624. *(1992 6 3 9 59 17 424)                                                        °
  625.  Ftab ÉFX 'U╜V tab W;T;A;B;C;D;E;F;G;M;ÉPW' 'Σ Tabulate list W'                °
  626.   'T╜(0=ÉNC ''V'')doif ''V╜0''' 'M╜''Invalid data for tabulation'''            °
  627.   'V╜4╞V' 'ÉPW╜130╛30⌐G╜V[2]+79⌡V[2]=0'                                        °
  628.   'L1:╕((1<╧W)doif ''''''W╜∞0'''' ÉEA ''''W╜πW'''''')/L1'                      °
  629.   '╕(((0=µεW)δ2<µµW)doif ''U╜(~V╧4╞0)/M'')/0'                                  °
  630.   'T╜(1≥µµU╜«W)doif ''U╜πW╜(U⌠'''' '''')ΓU'''                                  °
  631.   'T╜(0<V[1])doif ''U╜(«(Φ1,╞µW)µ(V[3]µ'''' ''''),∞(╞µW)-V[3]),'''' ''''       °
  632.  ,U''' '╕(G<30)/0' 'T╜(F╜µεV[4])+C╜1╟B╜µA╜(V[3],0)╟U'                          °
  633.   'T╜⌐(1╞B)÷1⌐╛(ÉPW+F)÷T' 'U╜(E╜(V[3],C)╞U),[1](B╜T,1╟B)╞A'                    °
  634.   '''D╜εV[4]'' ÉEA ''D╜ÉAV[εV[4]+33⌡V[4]=0]''' 'L0:A╜(T,0)╟A'                  °
  635. X '╕(0=1╞µA)/0' 'U╜U,(((T+V[3]),µD)µD),E,[1]B╞A' '╕L0'                         °
  636. *(1997 7 13 12 28 59 544)                                                      °
  637.  Ftest ÉFX 'U╜V test W;P'                                                      °
  638.   'Σ Describe problem in W, (correct answer in V)' 'U╜2' 'L1:W'                °
  639.   'É╜''      ''' 'P╜æ' '''╕L0'' ÉEA ''P╜»P''' '╕(V╧P)/0'                       °
  640. X 'L0:╕(0=U╜U-1)/0' '''Incorrect. Try again''' '╕L1'                           °
  641. XCuc 1 26 ABCDEFGHIJKLMNOPQRSTUVWXYZ                                           °
  642. *(1997 8 21 13 15 13 348)                                                      °
  643.  Fupdate ÉFX 'update'                                                          °
  644.   '''This version of APL2 lessons has been updated in the summer of 1997       °
  645.  '''                                                                           °
  646.   '''Any subsequent updates will be announced to the APL news group.'''        °
  647.   '''You may also e-mail me at jizba@kaiwan.com for additional details.'       °
  648.  '' '''Any constructive comments will be welcome.'',r'                         °
  649.   '''For an update of these lessons, mail a self addressed stamped'''          °
  650.   '''floppy disk mailer with two HD 3.5 inch blank floppies to:'',r'           °
  651.   '''                  Zdenek V. Jizba'''                                      °
  652.   '''                  1341 Rebecca Dr.'''                                     °
  653. X '''                 La Habra, CA 90631'''                                    °
  654. *(1996 4 6 16 11 30 332)                                                       °
  655.  Fvec ÉFX 'U╜V vec W;T' 'Σ Draw 2d vector in plane'                            °
  656.   'T╜(0=ÉNC ''V'')doif ''V╜'''''''''''                                         °
  657.   'U╜r,'' '',W[3],r,''2-        +'',W[2],r '':      °'',r,''1-    °'',r'       °
  658. X 'U╜U,'' :  °'',r,''0|....|....|.'',V,,'' '',W[1],r,'' 0    1    2'',r'       °
  659.