REDUCE User's Manual
Total Page:16
File Type:pdf, Size:1020Kb
REDUCE User’s Manual Version 3.8 Anthony C. Hearn Santa Monica, CA, USA Email: [email protected] February 2004 Copyright c 2004 Anthony C. Hearn. All rights reserved. Registered system holders may reproduce all or any part of this publication for internal purposes, provided that the source of the material is clearly acknowledged, and the copyright notice is retained. Contents Abstract 11 1 Introductory Information 15 2 Structure of Programs 19 2.1 The REDUCE Standard Character Set............... 19 2.2 Numbers............................... 19 2.3 Identifiers.............................. 21 2.4 Variables.............................. 22 2.5 Strings................................ 23 2.6 Comments.............................. 23 2.7 Operators.............................. 24 3 Expressions 27 3.1 Scalar Expressions......................... 27 3.2 Integer Expressions......................... 28 3.3 Boolean Expressions........................ 29 3.4 Equations.............................. 30 3.5 Proper Statements as Expressions................. 31 4 Lists 33 4.1 Operations on Lists......................... 33 4.1.1 LIST............................ 34 4.1.2 FIRST............................ 34 1 2 CONTENTS 4.1.3 SECOND.......................... 34 4.1.4 THIRD........................... 34 4.1.5 REST............................ 34 4.1.6 : (Cons) Operator...................... 34 4.1.7 APPEND.......................... 34 4.1.8 REVERSE......................... 35 4.1.9 List Arguments of Other Operators............ 35 4.1.10 Caveats and Examples................... 35 5 Statements 37 5.1 Assignment Statements....................... 38 5.1.1 Set Statement........................ 38 5.2 Group Statements.......................... 39 5.3 Conditional Statements....................... 39 5.4 FOR Statements........................... 40 5.5 WHILE . DO........................... 42 5.6 REPEAT . UNTIL......................... 43 5.7 Compound Statements....................... 43 5.7.1 Compound Statements with GO TO............ 45 5.7.2 Labels and GO TO Statements............... 45 5.7.3 RETURN Statements.................... 46 6 Commands and Declarations 49 6.1 Array Declarations......................... 49 6.2 Mode Handling Declarations.................... 50 6.3 END................................. 51 6.4 BYE Command........................... 51 6.5 SHOWTIME Command...................... 51 6.6 DEFINE Command......................... 51 7 Built-in Prefix Operators 53 7.1 Numerical Operators........................ 53 CONTENTS 3 7.1.1 ABS............................. 53 7.1.2 CEILING.......................... 54 7.1.3 CONJ............................ 54 7.1.4 FACTORIAL........................ 54 7.1.5 FIX............................. 54 7.1.6 FLOOR........................... 55 7.1.7 IMPART.......................... 55 7.1.8 MAX/MIN......................... 55 7.1.9 NEXTPRIME........................ 55 7.1.10 RANDOM......................... 56 7.1.11 RANDOM NEW SEED.................. 56 7.1.12 REPART.......................... 56 7.1.13 ROUND.......................... 57 7.1.14 SIGN............................ 57 7.2 Mathematical Functions....................... 57 7.3 DF Operator............................. 61 7.3.1 Adding Differentiation Rules................ 61 7.4 INT Operator............................ 62 7.4.1 Options........................... 63 7.4.2 Advanced Use....................... 63 7.4.3 References......................... 63 7.5 LENGTH Operator......................... 64 7.6 MAP Operator........................... 64 7.7 MKID Operator........................... 65 7.8 PF Operator............................. 66 7.9 SELECT Operator......................... 67 7.10 SOLVE Operator.......................... 68 7.10.1 Handling of Undetermined Solutions........... 69 7.10.2 Solutions of Equations Involving Cubics and Quartics.. 71 7.10.3 Other Options........................ 73 4 CONTENTS 7.10.4 Parameters and Variable Dependency........... 74 7.11 Even and Odd Operators...................... 78 7.12 Linear Operators.......................... 78 7.13 Non-Commuting Operators..................... 79 7.14 Symmetric and Antisymmetric Operators............. 80 7.15 Declaring New Prefix Operators.................. 80 7.16 Declaring New Infix Operators................... 81 7.17 Creating/Removing Variable Dependency............. 82 8 Display and Structuring of Expressions 83 8.1 Kernels............................... 83 8.2 The Expression Workspace..................... 84 8.3 Output of Expressions........................ 85 8.3.1 LINELENGTH Operator.................. 86 8.3.2 Output Declarations.................... 86 8.3.3 Output Control Switches.................. 87 8.3.4 WRITE Command..................... 91 8.3.5 Suppression of Zeros.................... 93 8.3.6 FORTRAN Style Output Of Expressions......... 93 8.3.7 Saving Expressions for Later Use as Input......... 96 8.3.8 Displaying Expression Structure.............. 96 8.4 Changing the Internal Order of Variables.............. 99 8.5 Obtaining Parts of Algebraic Expressions............. 99 8.5.1 COEFF Operator...................... 99 8.5.2 COEFFN Operator..................... 100 8.5.3 PART Operator....................... 100 8.5.4 Substituting for Parts of Expressions............ 102 9 Polynomials and Rationals 103 9.1 Controlling the Expansion of Expressions............. 104 9.2 Factorization of Polynomials.................... 104 CONTENTS 5 9.3 Cancellation of Common Factors.................. 106 9.3.1 Determining the GCD of Two Polynomials........ 107 9.4 Working with Least Common Multiples.............. 108 9.5 Controlling Use of Common Denominators............ 108 9.6 REMAINDER Operator...................... 108 9.7 RESULTANT Operator....................... 109 9.8 DECOMPOSE Operator...................... 110 9.9 INTERPOL operator........................ 111 9.10 Obtaining Parts of Polynomials and Rationals........... 111 9.10.1 DEG Operator....................... 111 9.10.2 DEN Operator....................... 112 9.10.3 LCOF Operator....................... 112 9.10.4 LPOWER Operator..................... 113 9.10.5 LTERM Operator...................... 113 9.10.6 MAINVAR Operator.................... 113 9.10.7 NUM Operator....................... 114 9.10.8 REDUCT Operator..................... 114 9.11 Polynomial Coefficient Arithmetic................. 115 9.11.1 Rational Coefficients in Polynomials............ 115 9.11.2 Real Coefficients in Polynomials.............. 115 9.11.3 Modular Number Coefficients in Polynomials....... 117 9.11.4 Complex Number Coefficients in Polynomials...... 117 10 Substitution Commands 119 10.1 SUB Operator............................ 119 10.2 LET Rules.............................. 120 10.2.1 FOR ALL . LET..................... 122 10.2.2 FOR ALL . SUCH THAT . LET............ 123 10.2.3 Removing Assignments and Substitution Rules...... 124 10.2.4 Overlapping LET Rules.................. 124 10.2.5 Substitutions for General Expressions........... 125 6 CONTENTS 10.3 Rule Lists.............................. 127 10.4 Asymptotic Commands....................... 133 11 File Handling Commands 135 11.1 IN Command............................ 135 11.2 OUT Command........................... 136 11.3 SHUT Command.......................... 136 12 Commands for Interactive Use 137 12.1 Referencing Previous Results.................... 137 12.2 Interactive Editing.......................... 138 12.3 Interactive File Control....................... 139 13 Matrix Calculations 141 13.1 MAT Operator............................ 141 13.2 Matrix Variables........................... 142 13.3 Matrix Expressions......................... 142 13.4 Operators with Matrix Arguments................. 143 13.4.1 DET Operator........................ 143 13.4.2 MATEIGEN Operator................... 144 13.4.3 TP Operator......................... 145 13.4.4 Trace Operator....................... 145 13.4.5 Matrix Cofactors...................... 145 13.4.6 NULLSPACE Operator................... 146 13.4.7 RANK Operator...................... 147 13.5 Matrix Assignments......................... 147 13.6 Evaluating Matrix Elements.................... 147 14 Procedures 149 14.1 Procedure Heading......................... 150 14.2 Procedure Body........................... 151 14.3 Using LET Inside Procedures.................... 153 CONTENTS 7 14.4 LET Rules as Procedures...................... 154 15 User Contributed Packages 157 15.1 ALGINT: Integration of square roots................ 157 15.2 APPLYSYM: Infinitesimal symmetries of differential equations. 158 15.3 ARNUM: An algebraic number package.............. 158 15.4 ASSIST: Useful utilities for various applications.......... 158 15.5 AVECTOR: A vector algebra and calculus package........ 159 15.6 BOOLEAN: A package for boolean algebra............ 159 15.7 CALI: A package for computational commutative algebra..... 159 15.8 CAMAL: Calculations in celestial mechanics........... 159 15.9 CHANGEVR: Change of Independent Variable(s) in DEs..... 160 15.10COMPACT: Package for compacting expressions......... 160 15.11CRACK: Solving overdetermined systems of PDEs or ODEs... 160 15.12CVIT: Fast calculation of Dirac gamma matrix traces....... 161 15.13DEFINT: A definite integration interface.............. 161 15.14DESIR: Differential linear homogeneous equation solutions in the neighborhood of irregular and regular singular points....... 161 15.15DFPART: Derivatives of generic functions............. 161 15.16DUMMY: Canonical form of expressions with dummy variables.