APL with a Mathematical AccentTable of ContentsClifford A. Reiter and William R. Jones, Brooks-Cole Publishing Co., Pacific Grove (1990) (now distributed by CRC Press)ISBN 0-534-12864-5 |
CHAPTER 1 First Steps With APL 1
1.1 Interacting with APL 1 1.2 Order of Execution 2 1.3 Negative Sign, Minus Sign 2 1.4 Assignment and Variable Names 3 1.5 Example: Heron's Formula 4 1.6 The Equals Function 4 1.7 Examples: Right Triangle Test, Conditional Incrementing 4 1.8 Dyadic, Monadic Functions 4 1.9 Functions with Vector Arguments 5 1.10 Examples: Some Uses of Vector Arithmetic 6 1.11 Shape, Reduction Operator 7 1.12 Examples: Average, Dot Product 7 1.13 More on the Reduction Operator 8 1.14 Index Generator 8 1.15 Examples: A Partial Sum, A Sequence for e 9 1.16 Number Forms and Print Precision 9 1.17 Workspaces, System Commands 9 1.18 Exiting APL 10 Exercises 10
CHAPTER 2 Fundamentals of Arrays 12
2.1 Example: Polynomial Evaluation 12 2.2 Elementwise Arithmetic 13 2.3 Reshape: Defining Arravs 14 2.4 Reduction 14 2.5 Outer Product 15 2.6 Example: Evaluation of Polynomials at Several Points 15 2.7 Catenation 16 2.8 Catenation of Matrices 16 2.9 Example: Forming a Blockwise Diagonal Matrix 17 2.10 Catenation of Matrices with Vectors 18 2.11 Indexing 18 2.12 Example: Elementary Row Operations on Matrices 19 2.13 Shape 20 2.14 Empty Arrays 22 Exercises 22
CHAPTER 3 Elementary Function Definition 26
3.1 Function Definition 26 3.2 Example: A Function for Polynomial Evaluation 28 3.3 Example: Approximating Areas Using Right-Hand Endpoints 28 3.4 Random Integers, Random Reals 30 3.5 Correcting a Function Line 30 3.6 Commands for Editing Functions 31 3.7 Suspended Functions; Interrupts 32 3.8 System Commands 33 3.9 Branching: Simple Loops 34 3.10 Example: Newton's Method 35 3.11 Statement Separation, Diamond 36 3.12 Explicit Output 37 3.13 Example: Fibonacci Numbers 38 Exercises 38
CHAPTER 4 Matrix Algebra 41
4.1 Matrix Product 41 4.2 Example: Markov Processes 42 4.3 Solving Linear Systems, Matrix Divide 43 4.4 Example: Some Solutions of Linear Systems 44 4.5 Outer Product 45 4.6 Example: Polynomial Interpolation 46 4.7 Example: Polynomial Evaluation Revisited 46 4.8 Least-Squares Solutions of Linear Systems 47 4.9 Example: Least-Squares Polynomial Curve Fitting 48 4.10 Matrix Inverse 49 4.11 Matrix Transpose 49 4.12 Example: A Formula Using Transpose 50 4.13 Example: Gram-Schmidt Orthogonalization 50 4.14 Example: Testing for Orthonormality 50 4.15 The Power Method 51 Exercises 53
CHAPTER 5 Data Comparison and Logical Functions 57
5.1 Relational Functions: Comparatives 57 5.2 Example: Averages on Selected Scores 58 5.3 Logical Functions 59 5.4 Example: Frequency Distribution 60 5.5 Generalized Inner Product: Vectors 60 5.6 Example: Weighted Average 61 5.7 Generalized Inner Product: General Arrays 61 5.8 Example: Paths in Graphs 63 5.9 Floor, Ceiling 64 5.10 Example: Rounding to a Decimal Position 65 5.11 Membership Function 65 5.12 Comparison Tolerance 66 Exercises 67
CHAPTER 6 Simulation and More Mathematical Functions 69
6.1 Roll, Deal, and Random Link 69 6.2 Example: Matching Partners 70 6.3 Example: Simulating A Classical Probability Experiment 71 6.4 Example: Polya's Um Scheme 72 6.5 ]Factorial and Binomial 74 6.6 Example: Binomial Distribution 74 6.7 Example: Polynomial Translation 75 6.8 Trigonometric Functions 77 6.9 Example: Monte Carlo Integration 78 Exercises 79
CHAPTER 7 Statistics and Graphics 81
7.1 Mean and Standard Deviation 81 7.2 Maximum and Minimum 82 7.3 Example: Range 82 7.4 Grade Up 83 7.5 Example: Median 83 7.6 Character Arrays 84 7.7 Example: Frequencies 84 7.8 Example: Histograms 85 7.9 Replicate on Vectors 86 7.10 Example: Separating Data 87 7.11 Scan 88 7.12 Example: Cumulative Histogram 88 7.13 Plotting X-Y Points 89 7.14 Example: Least-Squares Line Fitting 90 7.15 Sampling 93 7.16 Example: Sampling from an Exponential Population 93 7.17 Example: Sampling from a Binomial Distribution 94 7.18 Example: Sampling from a Normal Population 94 Exercises 95
CHAPTER 8 More Array Manipuladon 99
8.1 Take and Drop on Vectors 99 8.2 Example: Polynomial Addition 100 8.3 Take and Drop on Matrices 100 8.4 Ravel 101 8.5 Replicate, Compression, and Expansion 102 8.6 Example: Constructing Data with a Given Distribution 103 8.7 Reverse 104 8.8 Rotate 104 8.9 Example: Polynomial Multiplication 105 8.10 Dyadic Transpose 106 8.11 Transpose on Higher Dimensional Arrays 106 8.12 Laminate 108 8.13 Example: Constructing Banded Matrices 109 Exercises 109
CHAPTER 9 Sorting and Coding 113
9.1 Grade Up, Grade Down 113 9.2 Grade Up, Grade Down on Matrices 114 9.3 Example: Manipulation of Grade Point Average Statistics 115 9.4 Index Relative to a Vector 115 9.5 Example: Alphabetization 116 9.6 Example: Removing Duplicates and Frequency Revisited 116 9.7 Index Origin 118 9.8 Example: Polynomial Evaluation in Both Index Origins 119 9.9 Residue: Modular Reduction 119 9.10 Example: Finite Field Tables 120 9.11 Example: Alphabetization with Mixed-Case Letters 120 9.12 Represent 121 9.13 Base Value 122 9.14 Example: Polynomial Evaluation, Finis 122 9.15 Represent and Base Value on Arrays 123 9.16 Atomic Vector 124 9.17 Example: Encoding a String into Binary 124 9.18 Example: Hamming Code for Error Correction 125 9.19 Example: Hamming Code on Natural Text 127 Exercises 131
CHAPTER 10 More Function Definition 134
10.1 Functions for Programming Uses 134 10.2 Example: Descriptive Statistics 136 10.3 Branching 136 10.4 Line Labels 138 10.5 Examples: Aggregating Preferential Ballots 139 10.6 Multioption Branches 141 10.7 Example: The Bisection Method 141 10.8 Recursive Functions 142 10.9 Example: Generating Permutations 143 10.10 Example: Adaptive Integration 144 10.11 Quad: Input and Output 145 10.12 Quote-Quad: Input and Output 146 10.13 Example: Entering a Matrix Name-List 148 10.14 Example: More Adaptive Integration 149 10.15 Format 150 10.16 Example: Formatting an Interest Table 151 10.17 Execute 152 10.18 Example: Entering a Matrix Name-List, Revisited 153 10.19 Example: Matrix to a Power-of-2 Power 153 10.20 Functions as Arguments of Functions 154 Exercises 155
APPENDIX A Help, Error Messages, and Debugging 159
A. I Surprises for New Users 159 A.2 Error Messages 160 A.3 Suspended Functions 165 A.4 Example: Debugging with Quad Output 167 A.5 Setting Traces and Stops 169
APPENDIX B Workspace Environment 172
B. I Workspace Contents: Saving and Loading 172 B.2 Workspace Management 174 B.3 System Commands 175 B.4 System Variables 176 B.5 System Reports and System Functions 177
APPENDIX C Keyboards 180
APPENDIX D Answers to Selected Exercises 182
Bibliography 196 References 197 Index 198