reduce user's manual, free version september 21, 2019 · reduce user’s manual free version...

1124
REDUCE User’s Manual Free Version Anthony C. Hearn and Rainer Schöpf https://reduce-algebra.sourceforge.io/ September 21, 2019

Upload: others

Post on 24-Aug-2020

3 views

Category:

Documents


0 download

TRANSCRIPT

  • REDUCEUser’s Manual

    Free Version

    Anthony C. Hearn and Rainer Schöpf

    https://reduce-algebra.sourceforge.io/

    September 21, 2019

    https://reduce-algebra.sourceforge.io/

  • Copyright c©2004–2019 Anthony C. Hearn, Rainer Schöpf and contributors to theReduce project. All rights reserved.

    Reproduction of this manual is allowed, provided that the source of the material isclearly acknowledged, and the copyright notice is retained.

  • Contents

    Abstract 27

    1 Introductory Information 31

    2 Structure of Programs 35

    2.1 The REDUCE Standard Character Set . . . . . . . . . . . . . . . 35

    2.2 Numbers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36

    2.3 Identifiers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37

    2.4 Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38

    2.5 Strings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39

    2.6 Comments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40

    2.7 Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40

    3 Expressions 45

    3.1 Scalar Expressions . . . . . . . . . . . . . . . . . . . . . . . . . 45

    3.2 Integer Expressions . . . . . . . . . . . . . . . . . . . . . . . . . 46

    3.3 Boolean Expressions . . . . . . . . . . . . . . . . . . . . . . . . 47

    3.4 Equations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48

    3.5 Proper Statements as Expressions . . . . . . . . . . . . . . . . . 49

    4 Lists 51

    4.1 Operations on Lists . . . . . . . . . . . . . . . . . . . . . . . . . 51

    4.1.1 LIST . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52

    4.1.2 FIRST . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52

    1

  • 2 CONTENTS

    4.1.3 SECOND . . . . . . . . . . . . . . . . . . . . . . . . . . 52

    4.1.4 THIRD . . . . . . . . . . . . . . . . . . . . . . . . . . . 52

    4.1.5 REST . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52

    4.1.6 . (Cons) Operator . . . . . . . . . . . . . . . . . . . . . . 52

    4.1.7 APPEND . . . . . . . . . . . . . . . . . . . . . . . . . . 52

    4.1.8 REVERSE . . . . . . . . . . . . . . . . . . . . . . . . . 53

    4.1.9 List Arguments of Other Operators . . . . . . . . . . . . 53

    4.1.10 Caveats and Examples . . . . . . . . . . . . . . . . . . . 53

    5 Statements 55

    5.1 Assignment Statements . . . . . . . . . . . . . . . . . . . . . . . 56

    5.1.1 Set and Unset Statements . . . . . . . . . . . . . . . . . . 56

    5.2 Group Statements . . . . . . . . . . . . . . . . . . . . . . . . . . 57

    5.3 Conditional Statements . . . . . . . . . . . . . . . . . . . . . . . 57

    5.4 FOR Statements . . . . . . . . . . . . . . . . . . . . . . . . . . . 59

    5.5 WHILE . . . DO . . . . . . . . . . . . . . . . . . . . . . . . . . . 60

    5.6 REPEAT . . . UNTIL . . . . . . . . . . . . . . . . . . . . . . . . . 61

    5.7 Compound Statements . . . . . . . . . . . . . . . . . . . . . . . 62

    5.7.1 Compound Statements with GO TO . . . . . . . . . . . . 63

    5.7.2 Labels and GO TO Statements . . . . . . . . . . . . . . . 64

    5.7.3 RETURN Statements . . . . . . . . . . . . . . . . . . . . 64

    6 Commands and Declarations 67

    6.1 Array Declarations . . . . . . . . . . . . . . . . . . . . . . . . . 67

    6.2 Mode Handling Declarations . . . . . . . . . . . . . . . . . . . . 68

    6.3 END . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69

    6.4 BYE Command . . . . . . . . . . . . . . . . . . . . . . . . . . . 69

    6.5 SHOWTIME Command . . . . . . . . . . . . . . . . . . . . . . 69

    6.6 DEFINE Command . . . . . . . . . . . . . . . . . . . . . . . . . 69

    7 Built-in Prefix Operators 71

    7.1 Numerical Operators . . . . . . . . . . . . . . . . . . . . . . . . 71

  • CONTENTS 3

    7.1.1 ABS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71

    7.1.2 CEILING . . . . . . . . . . . . . . . . . . . . . . . . . . 72

    7.1.3 CONJ . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72

    7.1.4 FACTORIAL . . . . . . . . . . . . . . . . . . . . . . . . 73

    7.1.5 FIX . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73

    7.1.6 FLOOR . . . . . . . . . . . . . . . . . . . . . . . . . . . 73

    7.1.7 IMPART . . . . . . . . . . . . . . . . . . . . . . . . . . 73

    7.1.8 MAX/MIN . . . . . . . . . . . . . . . . . . . . . . . . . 74

    7.1.9 NEXTPRIME . . . . . . . . . . . . . . . . . . . . . . . . 74

    7.1.10 RANDOM . . . . . . . . . . . . . . . . . . . . . . . . . 74

    7.1.11 RANDOM_NEW_SEED . . . . . . . . . . . . . . . . . . 74

    7.1.12 REPART . . . . . . . . . . . . . . . . . . . . . . . . . . 75

    7.1.13 ROUND . . . . . . . . . . . . . . . . . . . . . . . . . . 75

    7.1.14 SIGN . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75

    7.2 Mathematical Functions . . . . . . . . . . . . . . . . . . . . . . . 76

    7.3 Bernoulli Numbers and Euler Numbers . . . . . . . . . . . . . . 80

    7.4 Fibonacci Numbers and Fibonacci Polynomials . . . . . . . . . . 80

    7.5 Motzkin numbers . . . . . . . . . . . . . . . . . . . . . . . . . . 81

    7.6 CHANGEVAR operator . . . . . . . . . . . . . . . . . . . . . . 81

    7.6.1 CHANGEVAR example: The 2-dim. Laplace Equation . . . 83

    7.6.2 Another CHANGEVAR example: An Euler Equation . . . . 83

    7.7 CONTINUED_FRACTION Operator . . . . . . . . . . . . . . . 84

    7.8 DF Operator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86

    7.8.1 Switches influencing differentiation . . . . . . . . . . . . 87

    7.8.2 Adding Differentiation Rules . . . . . . . . . . . . . . . . 88

    7.9 INT Operator . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89

    7.9.1 Options . . . . . . . . . . . . . . . . . . . . . . . . . . . 90

    7.9.2 Advanced Use . . . . . . . . . . . . . . . . . . . . . . . 90

    7.9.3 References . . . . . . . . . . . . . . . . . . . . . . . . . 91

    7.10 LENGTH Operator . . . . . . . . . . . . . . . . . . . . . . . . . 91

  • 4 CONTENTS

    7.11 MAP Operator . . . . . . . . . . . . . . . . . . . . . . . . . . . 91

    7.12 MKID Operator . . . . . . . . . . . . . . . . . . . . . . . . . . . 92

    7.13 The Pochhammer Notation . . . . . . . . . . . . . . . . . . . . . 93

    7.14 PF Operator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93

    7.15 SELECT Operator . . . . . . . . . . . . . . . . . . . . . . . . . 94

    7.16 SOLVE Operator . . . . . . . . . . . . . . . . . . . . . . . . . . 96

    7.16.1 Handling of Undetermined Solutions . . . . . . . . . . . 97

    7.16.2 Solutions of Equations Involving Cubics and Quartics . . 98

    7.16.3 Other Options . . . . . . . . . . . . . . . . . . . . . . . . 100

    7.16.4 Parameters and Variable Dependency . . . . . . . . . . . 101

    7.17 Even and Odd Operators . . . . . . . . . . . . . . . . . . . . . . 103

    7.18 Linear Operators . . . . . . . . . . . . . . . . . . . . . . . . . . 104

    7.19 Non-Commuting Operators . . . . . . . . . . . . . . . . . . . . . 105

    7.20 Symmetric and Antisymmetric Operators . . . . . . . . . . . . . 105

    7.21 Declaring New Prefix Operators . . . . . . . . . . . . . . . . . . 106

    7.22 Declaring New Infix Operators . . . . . . . . . . . . . . . . . . . 107

    7.23 Creating/Removing Variable Dependency . . . . . . . . . . . . . 107

    8 Display and Structuring of Expressions 109

    8.1 Kernels . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109

    8.2 The Expression Workspace . . . . . . . . . . . . . . . . . . . . . 110

    8.3 Output of Expressions . . . . . . . . . . . . . . . . . . . . . . . . 111

    8.3.1 LINELENGTH Operator . . . . . . . . . . . . . . . . . . 112

    8.3.2 Output Declarations . . . . . . . . . . . . . . . . . . . . 112

    8.3.3 Output Control Switches . . . . . . . . . . . . . . . . . . 113

    8.3.4 WRITE Command . . . . . . . . . . . . . . . . . . . . . 116

    8.3.5 Suppression of Zeros . . . . . . . . . . . . . . . . . . . . 119

    8.3.6 FORTRAN Style Output Of Expressions . . . . . . . . . 119

    8.3.7 Saving Expressions for Later Use as Input . . . . . . . . . 121

    8.3.8 Displaying Expression Structure . . . . . . . . . . . . . . 122

    8.4 Changing the Internal Order of Variables . . . . . . . . . . . . . . 123

  • CONTENTS 5

    8.5 Obtaining Parts of Algebraic Expressions . . . . . . . . . . . . . 124

    8.5.1 COEFF Operator . . . . . . . . . . . . . . . . . . . . . . 124

    8.5.2 COEFFN Operator . . . . . . . . . . . . . . . . . . . . . 125

    8.5.3 PART Operator . . . . . . . . . . . . . . . . . . . . . . . 125

    8.5.4 Substituting for Parts of Expressions . . . . . . . . . . . . 126

    9 Polynomials and Rationals 129

    9.1 Controlling the Expansion of Expressions . . . . . . . . . . . . . 130

    9.2 Factorization of Polynomials . . . . . . . . . . . . . . . . . . . . 130

    9.3 Cancellation of Common Factors . . . . . . . . . . . . . . . . . . 132

    9.3.1 Determining the GCD of Two Polynomials . . . . . . . . 133

    9.4 Working with Least Common Multiples . . . . . . . . . . . . . . 134

    9.5 Controlling Use of Common Denominators . . . . . . . . . . . . 134

    9.6 divide and mod / remainder Operators . . . . . . . . . . . . 135

    9.7 Polynomial Pseudo-Division . . . . . . . . . . . . . . . . . . . . 136

    9.8 RESULTANT Operator . . . . . . . . . . . . . . . . . . . . . . . 139

    9.9 DECOMPOSE Operator . . . . . . . . . . . . . . . . . . . . . . 140

    9.10 INTERPOL operator . . . . . . . . . . . . . . . . . . . . . . . . 141

    9.11 Obtaining Parts of Polynomials and Rationals . . . . . . . . . . . 141

    9.11.1 DEG Operator . . . . . . . . . . . . . . . . . . . . . . . 141

    9.11.2 DEN Operator . . . . . . . . . . . . . . . . . . . . . . . 142

    9.11.3 LCOF Operator . . . . . . . . . . . . . . . . . . . . . . . 142

    9.11.4 LPOWER Operator . . . . . . . . . . . . . . . . . . . . . 142

    9.11.5 LTERM Operator . . . . . . . . . . . . . . . . . . . . . . 143

    9.11.6 MAINVAR Operator . . . . . . . . . . . . . . . . . . . . 143

    9.11.7 NUM Operator . . . . . . . . . . . . . . . . . . . . . . . 143

    9.11.8 REDUCT Operator . . . . . . . . . . . . . . . . . . . . . 144

    9.11.9 TOTALDEG Operator . . . . . . . . . . . . . . . . . . . 144

    9.12 Polynomial Coefficient Arithmetic . . . . . . . . . . . . . . . . . 145

    9.12.1 Rational Coefficients in Polynomials . . . . . . . . . . . . 145

    9.12.2 Real Coefficients in Polynomials . . . . . . . . . . . . . . 145

  • 6 CONTENTS

    9.12.3 Modular Number Coefficients in Polynomials . . . . . . . 147

    9.12.4 Complex Number Coefficients in Polynomials . . . . . . 147

    9.13 ROOT_VAL Operator . . . . . . . . . . . . . . . . . . . . . . . . 148

    10 Assigning and Testing Algebraic Properties 149

    10.1 REALVALUED Declaration and Check . . . . . . . . . . . . . . 149

    10.2 SELFCONJUGATE Declaration . . . . . . . . . . . . . . . . . . 150

    10.3 Declaring Expressions Positive or Negative . . . . . . . . . . . . 151

    11 Substitution Commands 153

    11.1 SUB Operator . . . . . . . . . . . . . . . . . . . . . . . . . . . . 153

    11.2 LET Rules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 154

    11.2.1 FOR ALL . . . LET . . . . . . . . . . . . . . . . . . . . . 156

    11.2.2 FOR ALL . . . SUCH THAT . . . LET . . . . . . . . . . . 157

    11.2.3 Removing Assignments and Substitution Rules . . . . . . 157

    11.2.4 Overlapping LET Rules . . . . . . . . . . . . . . . . . . 158

    11.2.5 Substitutions for General Expressions . . . . . . . . . . . 159

    11.3 Rule Lists . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 161

    11.4 Asymptotic Commands . . . . . . . . . . . . . . . . . . . . . . . 167

    12 File Handling Commands 169

    12.1 IN Command . . . . . . . . . . . . . . . . . . . . . . . . . . . . 169

    12.2 OUT Command . . . . . . . . . . . . . . . . . . . . . . . . . . . 170

    12.3 SHUT Command . . . . . . . . . . . . . . . . . . . . . . . . . . 170

    12.4 REDUCE startup file . . . . . . . . . . . . . . . . . . . . . . . . 171

    13 Commands for Interactive Use 173

    13.1 Referencing Previous Results . . . . . . . . . . . . . . . . . . . . 173

    13.2 Interactive Editing . . . . . . . . . . . . . . . . . . . . . . . . . . 174

    13.3 Interactive File Control . . . . . . . . . . . . . . . . . . . . . . . 175

    14 Matrix Calculations 177

    14.1 MAT Operator . . . . . . . . . . . . . . . . . . . . . . . . . . . . 177

  • CONTENTS 7

    14.2 Matrix Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . 177

    14.3 Matrix Expressions . . . . . . . . . . . . . . . . . . . . . . . . . 178

    14.4 Operators with Matrix Arguments . . . . . . . . . . . . . . . . . 179

    14.4.1 DET Operator . . . . . . . . . . . . . . . . . . . . . . . . 179

    14.4.2 MATEIGEN Operator . . . . . . . . . . . . . . . . . . . 180

    14.4.3 TP Operator . . . . . . . . . . . . . . . . . . . . . . . . . 181

    14.4.4 Trace Operator . . . . . . . . . . . . . . . . . . . . . . . 181

    14.4.5 Matrix Cofactors . . . . . . . . . . . . . . . . . . . . . . 181

    14.4.6 NULLSPACE Operator . . . . . . . . . . . . . . . . . . . 181

    14.4.7 RANK Operator . . . . . . . . . . . . . . . . . . . . . . 182

    14.5 Matrix Assignments . . . . . . . . . . . . . . . . . . . . . . . . . 183

    14.6 Evaluating Matrix Elements . . . . . . . . . . . . . . . . . . . . 183

    15 Procedures 185

    15.1 Procedure Heading . . . . . . . . . . . . . . . . . . . . . . . . . 186

    15.2 Procedure Body . . . . . . . . . . . . . . . . . . . . . . . . . . . 187

    15.3 Matrix-valued Procedures . . . . . . . . . . . . . . . . . . . . . . 188

    15.4 Using LET Inside Procedures . . . . . . . . . . . . . . . . . . . . 189

    15.5 LET Rules as Procedures . . . . . . . . . . . . . . . . . . . . . . 190

    15.6 REMEMBER Statement . . . . . . . . . . . . . . . . . . . . . . 191

    16 User Contributed Packages 193

    16.1 ALGINT: Integration of square roots . . . . . . . . . . . . . . . . 194

    16.2 APPLYSYM: Infinitesimal symmetries of differential equations . 195

    16.2.1 Introduction and overview of the symmetry method . . . . 195

    16.2.2 Applying symmetries with APPLYSYM . . . . . . . . . . 201

    16.2.3 Solving quasilinear PDEs . . . . . . . . . . . . . . . . . 210

    16.2.4 Transformation of DEs . . . . . . . . . . . . . . . . . . . 213

    Bibliography . . . . . . . . . . . . . . . . . . . . . . . . . . . . 215

    16.3 ARNUM: An algebraic number package . . . . . . . . . . . . . . 218

    Bibliography . . . . . . . . . . . . . . . . . . . . . . . . . . . . 223

  • 8 CONTENTS

    16.4 ASSERT: Dynamic Verification of Assertions on Function Types . 224

    16.4.1 Loading and Using . . . . . . . . . . . . . . . . . . . . . 224

    16.4.2 Type Definitions . . . . . . . . . . . . . . . . . . . . . . 224

    16.4.3 Assertions . . . . . . . . . . . . . . . . . . . . . . . . . . 225

    16.4.4 Dynamic Checking of Assertions . . . . . . . . . . . . . 225

    16.4.5 Switches . . . . . . . . . . . . . . . . . . . . . . . . . . 227

    16.4.6 Efficiency . . . . . . . . . . . . . . . . . . . . . . . . . . 227

    16.4.7 Possible Extensions . . . . . . . . . . . . . . . . . . . . . 229

    16.5 ASSIST: Useful utilities for various applications . . . . . . . . . . 230

    16.5.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . 230

    16.5.2 Survey of the Available New Facilities . . . . . . . . . . 230

    16.5.3 Control of Switches . . . . . . . . . . . . . . . . . . . . 232

    16.5.4 Manipulation of the List Structure . . . . . . . . . . . . . 233

    16.5.5 The Bag Structure and its Associated Functions . . . . . 238

    16.5.6 Sets and their Manipulation Functions . . . . . . . . . . . 240

    16.5.7 General Purpose Utility Functions . . . . . . . . . . . . . 241

    16.5.8 Properties and Flags . . . . . . . . . . . . . . . . . . . . 248

    16.5.9 Control Functions . . . . . . . . . . . . . . . . . . . . . 249

    16.5.10 Handling of Polynomials . . . . . . . . . . . . . . . . . . 252

    16.5.11 Handling of Transcendental Functions . . . . . . . . . . . 253

    16.5.12 Handling of n–dimensional Vectors . . . . . . . . . . . . 255

    16.5.13 Handling of Grassmann Operators . . . . . . . . . . . . . 255

    16.5.14 Handling of Matrices . . . . . . . . . . . . . . . . . . . . 256

    16.6 AVECTOR: A vector algebra and calculus package . . . . . . . . 260

    16.6.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . 260

    16.6.2 Vector declaration and initialisation . . . . . . . . . . . . 260

    16.6.3 Vector algebra . . . . . . . . . . . . . . . . . . . . . . . 261

    16.6.4 Vector calculus . . . . . . . . . . . . . . . . . . . . . . . 262

    16.6.5 Volume and Line Integration . . . . . . . . . . . . . . . . 264

    16.6.6 Defining new functions and procedures . . . . . . . . . . 266

  • CONTENTS 9

    16.6.7 Acknowledgements . . . . . . . . . . . . . . . . . . . . . 266

    16.7 BIBASIS: A Package for Calculating Boolean Involutive Bases . . 267

    16.7.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . 267

    16.7.2 Boolean Ring . . . . . . . . . . . . . . . . . . . . . . . . 267

    16.7.3 Pommaret Involutive Algorithm . . . . . . . . . . . . . . 268

    16.7.4 BIBASIS Package . . . . . . . . . . . . . . . . . . . . . 269

    16.7.5 Examples . . . . . . . . . . . . . . . . . . . . . . . . . . 270

    Bibliography . . . . . . . . . . . . . . . . . . . . . . . . . . . . 273

    16.8 BOOLEAN: A package for boolean algebra . . . . . . . . . . . . 274

    16.8.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . 274

    16.8.2 Entering boolean expressions . . . . . . . . . . . . . . . 274

    16.8.3 Normal forms . . . . . . . . . . . . . . . . . . . . . . . . 275

    16.8.4 Evaluation of a boolean expression . . . . . . . . . . . . 276

    16.9 CALI: A package for computational commutative algebra . . . . . 278

    16.9.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . 278

    16.9.2 The Computational Model . . . . . . . . . . . . . . . . . 285

    16.9.3 Basic Data Structures . . . . . . . . . . . . . . . . . . . . 294

    16.9.4 About the Algorithms Implemented in CALI . . . . . . . 300

    16.9.5 A Short Description of Procedures Available in AlgebraicMode . . . . . . . . . . . . . . . . . . . . . . . . . . . . 316

    16.9.6 The CALI Module Structure . . . . . . . . . . . . . . . . 326

    Bibliography . . . . . . . . . . . . . . . . . . . . . . . . . . . . 327

    16.10CAMAL: Calculations in celestial mechanics . . . . . . . . . . . 329

    16.10.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . 329

    16.10.2 How CAMAL Worked . . . . . . . . . . . . . . . . . . . 330

    16.10.3 Towards a CAMAL Module . . . . . . . . . . . . . . . . 333

    16.10.4 Integration with REDUCE . . . . . . . . . . . . . . . . . 335

    16.10.5 The Simple Experiments . . . . . . . . . . . . . . . . . . 336

    16.10.6 A Medium-Sized Problem . . . . . . . . . . . . . . . . . 337

    16.10.7 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . 339

    Bibliography . . . . . . . . . . . . . . . . . . . . . . . . . . . . 342

  • 10 CONTENTS

    16.11CANTENS: A Package for Manipulations and Simplifications ofIndexed Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . 343

    16.11.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . 343

    16.11.2 Handling of space(s) . . . . . . . . . . . . . . . . . . . . 344

    16.11.3 Generic tensors and their manipulation . . . . . . . . . . 348

    16.11.4 Specific tensors . . . . . . . . . . . . . . . . . . . . . . . 362

    16.11.5 The simplification function CANONICAL . . . . . . . . . 378

    16.12CDE: A package for integrability of PDEs . . . . . . . . . . . . . 397

    16.12.1 Introduction: why CDE? . . . . . . . . . . . . . . . . . . 397

    16.12.2 Jet space of even and odd variables, and total derivatives . 398

    16.12.3 Differential equations in even and odd variables . . . . . . 402

    16.12.4 Calculus of variations . . . . . . . . . . . . . . . . . . . 404

    16.12.5 C-differential operators . . . . . . . . . . . . . . . . . . . 404

    16.12.6 C-differential operators as superfunctions . . . . . . . . . 407

    16.12.7 The Schouten bracket . . . . . . . . . . . . . . . . . . . . 408

    16.12.8 Computing linearization and its adjoint . . . . . . . . . . 409

    16.12.9 Higher symmetries . . . . . . . . . . . . . . . . . . . . . 412

    16.12.10Setting up the jet space and the differential equation. . . . 413

    16.12.11Solving the problem via dimensional analysis. . . . . . . 413

    16.12.12Solving the problem using CRACK . . . . . . . . . . . . 417

    16.12.13Local conservation laws . . . . . . . . . . . . . . . . . . 418

    16.12.14Local Hamiltonian operators . . . . . . . . . . . . . . . . 419

    16.12.15Korteweg–de Vries equation . . . . . . . . . . . . . . . . 420

    16.12.16Boussinesq equation . . . . . . . . . . . . . . . . . . . . 423

    16.12.17Kadomtsev–Petviashvili equation . . . . . . . . . . . . . 424

    16.12.18Examples of Schouten bracket of local Hamiltonian operators425

    16.12.19Bi-Hamiltonian structure of the KdV equation . . . . . . . 426

    16.12.20Bi-Hamiltonian structure of the WDVV equation . . . . . 427

    16.12.21Schouten bracket of multidimensional operators . . . . . . 431

    16.12.22Non-local operators . . . . . . . . . . . . . . . . . . . . . 433

  • CONTENTS 11

    16.12.23Non-local Hamiltonian operators for the Korteweg–de Vriesequation . . . . . . . . . . . . . . . . . . . . . . . . . . . 433

    16.12.24Non-local recursion operator for the Korteweg–de Vriesequation . . . . . . . . . . . . . . . . . . . . . . . . . . . 436

    16.12.25Non-local Hamiltonian-recursion operators for Plebanskiequation . . . . . . . . . . . . . . . . . . . . . . . . . . . 436

    16.12.26Appendix: old versions of CDE . . . . . . . . . . . . . . 438

    Bibliography . . . . . . . . . . . . . . . . . . . . . . . . . . . . 439

    16.13CDIFF: A package for computations in geometry of DifferentialEquations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 442

    16.13.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . 442

    16.13.2 Computing with CDIFF . . . . . . . . . . . . . . . . . . 443

    Bibliography . . . . . . . . . . . . . . . . . . . . . . . . . . . . 466

    16.14CGB: Computing Comprehensive Gröbner Bases . . . . . . . . . 467

    16.14.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . 467

    16.14.2 Using the REDLOG Package . . . . . . . . . . . . . . . . 467

    16.14.3 Term Ordering Mode . . . . . . . . . . . . . . . . . . . . 468

    16.14.4 CGB: Comprehensive Gröbner Basis . . . . . . . . . . . 468

    16.14.5 GSYS: Gröbner System . . . . . . . . . . . . . . . . . . 468

    16.14.6 GSYS2CGB: Gröbner System to CGB . . . . . . . . . . 470

    16.14.7 Switch CGBREAL: Computing over the Real Numbers . . 470

    16.14.8 Switches . . . . . . . . . . . . . . . . . . . . . . . . . . 471

    Bibliography . . . . . . . . . . . . . . . . . . . . . . . . . . . . 471

    16.15COMPACT: Package for compacting expressions . . . . . . . . . 472

    16.16CRACK: Solving overdetermined systems of PDEs or ODEs . . . 473

    16.17CVIT: Fast calculation of Dirac gamma matrix traces . . . . . . . 474

    16.18DEFINT: A definite integration interface . . . . . . . . . . . . . . 483

    16.18.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . 483

    16.18.2 Integration between zero and infinity . . . . . . . . . . . 483

    16.18.3 Integration over other ranges . . . . . . . . . . . . . . . . 484

    16.18.4 Using the definite integration package . . . . . . . . . . . 485

    16.18.5 Integral Transforms . . . . . . . . . . . . . . . . . . . . . 487

  • 12 CONTENTS

    16.18.6 Additional Meijer G-function Definitions . . . . . . . . . 489

    16.18.7 The print_conditions function . . . . . . . . . . . . . . . 490

    16.18.8 Tracing . . . . . . . . . . . . . . . . . . . . . . . . . . . 491

    16.18.9 Acknowledgements . . . . . . . . . . . . . . . . . . . . . 491

    Bibliography . . . . . . . . . . . . . . . . . . . . . . . . . . . . 491

    16.19DESIR: Differential linear homogeneous equation solutions in theneighborhood of irregular and regular singular points . . . . . . . 493

    16.19.1 INTRODUCTION . . . . . . . . . . . . . . . . . . . . . 493

    16.19.2 FORMS OF SOLUTIONS . . . . . . . . . . . . . . . . . 494

    16.19.3 INTERACTIVE USE . . . . . . . . . . . . . . . . . . . . 495

    16.19.4 DIRECT USE . . . . . . . . . . . . . . . . . . . . . . . 495

    16.19.5 USEFUL FUNCTIONS . . . . . . . . . . . . . . . . . . 496

    16.19.6 LIMITATIONS . . . . . . . . . . . . . . . . . . . . . . . 499

    16.20DFPART: Derivatives of generic functions . . . . . . . . . . . . . 500

    16.20.1 Generic Functions . . . . . . . . . . . . . . . . . . . . . 500

    16.20.2 Partial Derivatives . . . . . . . . . . . . . . . . . . . . . 501

    16.20.3 Substitutions . . . . . . . . . . . . . . . . . . . . . . . . 503

    16.21DUMMY: Canonical form of expressions with dummy variables . 505

    16.21.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . 505

    16.21.2 Dummy variables and dummy summations . . . . . . . . 506

    16.21.3 The Operators and their Properties . . . . . . . . . . . . . 508

    16.21.4 The Function CANONICAL . . . . . . . . . . . . . . . . 509

    16.21.5 Bibliography . . . . . . . . . . . . . . . . . . . . . . . . 510

    16.22EXCALC: A differential geometry package . . . . . . . . . . . . 512

    16.22.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . 512

    16.22.2 Declarations . . . . . . . . . . . . . . . . . . . . . . . . 513

    16.22.3 Exterior Multiplication . . . . . . . . . . . . . . . . . . . 514

    16.22.4 Partial Differentiation . . . . . . . . . . . . . . . . . . . 515

    16.22.5 Exterior Differentiation . . . . . . . . . . . . . . . . . . . 516

    16.22.6 Inner Product . . . . . . . . . . . . . . . . . . . . . . . . 518

    16.22.7 Lie Derivative . . . . . . . . . . . . . . . . . . . . . . . . 519

  • CONTENTS 13

    16.22.8 Hodge-* Duality Operator . . . . . . . . . . . . . . . . . 519

    16.22.9 Variational Derivative . . . . . . . . . . . . . . . . . . . 520

    16.22.10Handling of Indices . . . . . . . . . . . . . . . . . . . . . 521

    16.22.11Metric Structures . . . . . . . . . . . . . . . . . . . . . . 524

    16.22.12Riemannian Connections . . . . . . . . . . . . . . . . . . 528

    16.22.13Killing Vectors . . . . . . . . . . . . . . . . . . . . . . . 529

    16.22.14Ordering and Structuring . . . . . . . . . . . . . . . . . . 530

    16.22.15Summary of Operators and Commands . . . . . . . . . . 532

    16.22.16Examples . . . . . . . . . . . . . . . . . . . . . . . . . . 533

    16.23FIDE: Finite difference method for partial differential equations . 544

    16.23.1 Abstract . . . . . . . . . . . . . . . . . . . . . . . . . . . 544

    16.23.2 EXPRES . . . . . . . . . . . . . . . . . . . . . . . . . . 545

    16.23.3 IIMET . . . . . . . . . . . . . . . . . . . . . . . . . . . 548

    16.23.4 APPROX . . . . . . . . . . . . . . . . . . . . . . . . . . 561

    16.23.5 CHARPOL . . . . . . . . . . . . . . . . . . . . . . . . . 564

    16.23.6 HURWP . . . . . . . . . . . . . . . . . . . . . . . . . . 567

    16.23.7 LINBAND . . . . . . . . . . . . . . . . . . . . . . . . . 568

    16.24FPS: Automatic calculation of formal power series . . . . . . . . 572

    16.24.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . 572

    16.24.2 REDUCE operator FPS . . . . . . . . . . . . . . . . . . 572

    16.24.3 REDUCE operator SimpleDE . . . . . . . . . . . . . . 574

    16.24.4 Problems in the current version . . . . . . . . . . . . . . 574

    Bibliography . . . . . . . . . . . . . . . . . . . . . . . . . . . . 574

    16.25GCREF: A Graph Cross Referencer . . . . . . . . . . . . . . . . 576

    16.25.1 Basic Usage . . . . . . . . . . . . . . . . . . . . . . . . . 576

    16.25.2 Shell Script "gcref" . . . . . . . . . . . . . . . . . . . . . 576

    16.25.3 Redering with yED . . . . . . . . . . . . . . . . . . . . . 576

    16.26GENTRAN: A code generation package . . . . . . . . . . . . . . 578

    16.27GNUPLOT: Display of functions and surfaces . . . . . . . . . . . 579

    16.27.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . 579

  • 14 CONTENTS

    16.27.2 Command plot . . . . . . . . . . . . . . . . . . . . . . 579

    16.27.3 Paper output . . . . . . . . . . . . . . . . . . . . . . . . 583

    16.27.4 Mesh generation for implicit curves . . . . . . . . . . . . 583

    16.27.5 Mesh generation for surfaces . . . . . . . . . . . . . . . . 584

    16.27.6 GNUPLOT operation . . . . . . . . . . . . . . . . . . . . 584

    16.27.7 Saving GNUPLOT command sequences . . . . . . . . . . 584

    16.27.8 Direct Call of GNUPLOT . . . . . . . . . . . . . . . . . . 585

    16.27.9 Examples . . . . . . . . . . . . . . . . . . . . . . . . . . 585

    16.28GROEBNER: A Gröbner basis package . . . . . . . . . . . . . . 590

    16.28.1 Background . . . . . . . . . . . . . . . . . . . . . . . . . 590

    16.28.2 Loading of the Package . . . . . . . . . . . . . . . . . . . 593

    16.28.3 The Basic Operators . . . . . . . . . . . . . . . . . . . . 593

    16.28.4 Ideal Decomposition & Equation System Solving . . . . . 613

    16.28.5 Calculations “by Hand” . . . . . . . . . . . . . . . . . . 617

    Bibliography . . . . . . . . . . . . . . . . . . . . . . . . . . . . 620

    16.29GUARDIAN: Guarded Expressions in Practice . . . . . . . . . . 622

    16.29.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . 622

    16.29.2 An outline of our method . . . . . . . . . . . . . . . . . . 623

    16.29.3 Examples . . . . . . . . . . . . . . . . . . . . . . . . . . 632

    16.29.4 Outlook . . . . . . . . . . . . . . . . . . . . . . . . . . . 634

    16.29.5 Conclusions . . . . . . . . . . . . . . . . . . . . . . . . . 637

    Bibliography . . . . . . . . . . . . . . . . . . . . . . . . . . . . 637

    16.30IDEALS: Arithmetic for polynomial ideals . . . . . . . . . . . . 639

    16.30.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . 639

    16.30.2 Initialization . . . . . . . . . . . . . . . . . . . . . . . . 639

    16.30.3 Bases . . . . . . . . . . . . . . . . . . . . . . . . . . . . 639

    16.30.4 Algorithms . . . . . . . . . . . . . . . . . . . . . . . . . 640

    16.30.5 Examples . . . . . . . . . . . . . . . . . . . . . . . . . . 641

    16.31INEQ: Support for solving inequalities . . . . . . . . . . . . . . . 642

    16.32INVBASE: A package for computing involutive bases . . . . . . . 644

  • CONTENTS 15

    16.32.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . 644

    16.32.2 The Basic Operators . . . . . . . . . . . . . . . . . . . . 645

    Bibliography . . . . . . . . . . . . . . . . . . . . . . . . . . . . 647

    16.33LALR: A parser generator . . . . . . . . . . . . . . . . . . . . . 648

    16.33.1 Limitations . . . . . . . . . . . . . . . . . . . . . . . . . 649

    16.33.2 An example . . . . . . . . . . . . . . . . . . . . . . . . . 650

    16.34LAPLACE: Laplace transforms . . . . . . . . . . . . . . . . . . . 651

    16.35LIE: Functions for the classification of real n-dimensional Lie al-gebras . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 653

    Bibliography . . . . . . . . . . . . . . . . . . . . . . . . . . . . 656

    16.36LIMITS: A package for finding limits . . . . . . . . . . . . . . . 657

    16.36.1 Normal entry points . . . . . . . . . . . . . . . . . . . . 657

    16.36.2 Direction-dependent limits . . . . . . . . . . . . . . . . . 657

    16.37LINALG: Linear algebra package . . . . . . . . . . . . . . . . . 658

    16.37.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . 658

    16.37.2 Getting started . . . . . . . . . . . . . . . . . . . . . . . 659

    16.37.3 What’s available . . . . . . . . . . . . . . . . . . . . . . 660

    16.37.4 Fast Linear Algebra . . . . . . . . . . . . . . . . . . . . . 684

    16.37.5 Acknowledgments . . . . . . . . . . . . . . . . . . . . . 685

    Bibliography . . . . . . . . . . . . . . . . . . . . . . . . . . . . 685

    16.38LISTVECOPS: Vector operations on lists . . . . . . . . . . . . . 686

    16.39LPDO: Linear Partial Differential Operators . . . . . . . . . . . . 689

    16.39.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . 689

    16.39.2 Operators . . . . . . . . . . . . . . . . . . . . . . . . . . 690

    16.39.3 Shapes of F-elements . . . . . . . . . . . . . . . . . . . . 691

    16.39.4 Commands . . . . . . . . . . . . . . . . . . . . . . . . . 692

    16.40MODSR: Modular solve and roots . . . . . . . . . . . . . . . . . 699

    16.41MRVLIMIT: A new exp-log limits package . . . . . . . . . . . . 700

    16.41.1 The Exp-Log Limits package . . . . . . . . . . . . . . . . 700

    16.41.2 The Algorithm . . . . . . . . . . . . . . . . . . . . . . . 701

    16.41.3 The tracing facility . . . . . . . . . . . . . . . . . . . . . 703

  • 16 CONTENTS

    Bibliography . . . . . . . . . . . . . . . . . . . . . . . . . . . . 706

    16.42NCPOLY: Non–commutative polynomial ideals . . . . . . . . . . 706

    16.42.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . 706

    16.42.2 Setup, Cleanup . . . . . . . . . . . . . . . . . . . . . . . 706

    16.42.3 Left and right ideals . . . . . . . . . . . . . . . . . . . . 708

    16.42.4 Gröbner bases . . . . . . . . . . . . . . . . . . . . . . . . 708

    16.42.5 Left or right polynomial division . . . . . . . . . . . . . . 709

    16.42.6 Left or right polynomial reduction . . . . . . . . . . . . . 710

    16.42.7 Factorization . . . . . . . . . . . . . . . . . . . . . . . . 710

    16.42.8 Output of expressions . . . . . . . . . . . . . . . . . . . 711

    16.43NORMFORM: Computation of matrix normal forms . . . . . . . 713

    16.43.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . 713

    16.43.2 Smith normal form . . . . . . . . . . . . . . . . . . . . . 714

    16.43.3 smithex_int . . . . . . . . . . . . . . . . . . . . . . . . . 715

    16.43.4 frobenius . . . . . . . . . . . . . . . . . . . . . . . . . . 716

    16.43.5 ratjordan . . . . . . . . . . . . . . . . . . . . . . . . . . 717

    16.43.6 jordansymbolic . . . . . . . . . . . . . . . . . . . . . . . 718

    16.43.7 jordan . . . . . . . . . . . . . . . . . . . . . . . . . . . . 720

    16.43.8 Algebraic extensions: Using the ARNUM package . . . . . 721

    16.43.9 Modular arithmetic . . . . . . . . . . . . . . . . . . . . . 722

    Bibliography . . . . . . . . . . . . . . . . . . . . . . . . . . . . 723

    16.44NUMERIC: Solving numerical problems . . . . . . . . . . . . . 724

    16.44.1 Syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . 724

    16.44.2 Minima . . . . . . . . . . . . . . . . . . . . . . . . . . . 725

    16.44.3 Roots of Functions/ Solutions of Equations . . . . . . . . 726

    16.44.4 Integrals . . . . . . . . . . . . . . . . . . . . . . . . . . . 727

    16.44.5 Ordinary Differential Equations . . . . . . . . . . . . . . 728

    16.44.6 Bounds of a Function . . . . . . . . . . . . . . . . . . . . 730

    16.44.7 Chebyshev Curve Fitting . . . . . . . . . . . . . . . . . . 731

    16.44.8 General Curve Fitting . . . . . . . . . . . . . . . . . . . 732

  • CONTENTS 17

    16.44.9 Function Bases . . . . . . . . . . . . . . . . . . . . . . . 733

    16.45ODESOLVE: Ordinary differential equations solver . . . . . . . . 735

    16.45.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . 735

    16.45.2 Installation . . . . . . . . . . . . . . . . . . . . . . . . . 736

    16.45.3 User interface . . . . . . . . . . . . . . . . . . . . . . . . 737

    16.45.4 Output syntax . . . . . . . . . . . . . . . . . . . . . . . . 743

    16.45.5 Solution techniques . . . . . . . . . . . . . . . . . . . . . 743

    16.45.6 Extension interface . . . . . . . . . . . . . . . . . . . . . 748

    16.45.7 Change log . . . . . . . . . . . . . . . . . . . . . . . . . 751

    16.45.8 Planned developments . . . . . . . . . . . . . . . . . . . 751

    Bibliography . . . . . . . . . . . . . . . . . . . . . . . . . . . . 752

    16.46ORTHOVEC: Manipulation of scalars and vectors . . . . . . . . . 754

    16.46.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . 754

    16.46.2 Initialisation . . . . . . . . . . . . . . . . . . . . . . . . 755

    16.46.3 Input-Output . . . . . . . . . . . . . . . . . . . . . . . . 755

    16.46.4 Algebraic Operations . . . . . . . . . . . . . . . . . . . . 756

    16.46.5 Differential Operations . . . . . . . . . . . . . . . . . . . 758

    16.46.6 Integral Operations . . . . . . . . . . . . . . . . . . . . . 760

    16.46.7 Test Cases . . . . . . . . . . . . . . . . . . . . . . . . . . 760

    Bibliography . . . . . . . . . . . . . . . . . . . . . . . . . . . . 763

    16.47PHYSOP: Operator calculus in quantum theory . . . . . . . . . . 764

    16.47.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . 764

    16.47.2 The NONCOM2 Package . . . . . . . . . . . . . . . . . 764

    16.47.3 The PHYSOP package . . . . . . . . . . . . . . . . . . . 765

    16.47.4 Known problems in the current release of PHYSOP . . . . 773

    16.47.5 Final remarks . . . . . . . . . . . . . . . . . . . . . . . . 773

    16.47.6 Appendix: List of error and warning messages . . . . . . 774

    16.48PM: A REDUCE pattern matcher . . . . . . . . . . . . . . . . . . 776

    16.48.1 M(exp,temp) . . . . . . . . . . . . . . . . . . . . . . 777

    16.48.2 temp _= logical_exp . . . . . . . . . . . . . . . . . . . . 778

  • 18 CONTENTS

    16.48.3 S(exp,{temp1 -> sub1, temp2 -> sub2, . . . }, rept, depth) . 779

    16.48.4 temp :- exp and temp ::- exp . . . . . . . . . . . . . . . . 780

    16.48.5 Arep({rep1,rep2,. . . }) . . . . . . . . . . . . . . . . . . . 781

    16.48.6 Drep({rep1,rep2,..}) . . . . . . . . . . . . . . . . . . . . 781

    16.48.7 Switches . . . . . . . . . . . . . . . . . . . . . . . . . . 781

    16.49QHULL: Compute the complex hull . . . . . . . . . . . . . . . . 783

    16.50QSUM: Indefinite and Definite Summation of q-hypergeometricTerms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 784

    16.50.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . 784

    16.50.2 Elementary q-Functions . . . . . . . . . . . . . . . . . . 784

    16.50.3 q-Gosper Algorithm . . . . . . . . . . . . . . . . . . . . 785

    16.50.4 q-Zeilberger Algorithm . . . . . . . . . . . . . . . . . . . 786

    16.50.5 REDUCE operator QGOSPER . . . . . . . . . . . . . . . 787

    16.50.6 REDUCE operator QSUMRECURSION . . . . . . . . . . 789

    16.50.7 Simplification Operators . . . . . . . . . . . . . . . . . . 794

    16.50.8 Global Variables and Switches . . . . . . . . . . . . . . . 795

    16.50.9 Messages . . . . . . . . . . . . . . . . . . . . . . . . . . 796

    Bibliography . . . . . . . . . . . . . . . . . . . . . . . . . . . . 797

    16.51RANDPOLY: A random polynomial generator . . . . . . . . . . . 799

    16.51.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . 799

    16.51.2 Basic use of randpoly . . . . . . . . . . . . . . . . . . 800

    16.51.3 Advanced use of randpoly . . . . . . . . . . . . . . . . 801

    16.51.4 Subsidiary functions: rand, proc, random . . . . . . . . . 802

    16.51.5 Examples . . . . . . . . . . . . . . . . . . . . . . . . . . 804

    16.51.6 Appendix: Algorithmic background . . . . . . . . . . . . 805

    16.52RATAPRX: Rational Approximations Package for REDUCE . . . 809

    16.52.1 Periodic Decimal Representation . . . . . . . . . . . . . . 809

    16.52.2 Continued Fractions . . . . . . . . . . . . . . . . . . . . 811

    16.52.3 Padé Approximation . . . . . . . . . . . . . . . . . . . . 820

    Bibliography . . . . . . . . . . . . . . . . . . . . . . . . . . . . 824

  • CONTENTS 19

    16.53RATINT: Integrate Rational Functions using the Minimal Alge-braic Extension to the Constant Field . . . . . . . . . . . . . . . . 825

    16.53.1 Rational Integration . . . . . . . . . . . . . . . . . . . . 825

    16.53.2 The Algorithm . . . . . . . . . . . . . . . . . . . . . . . 827

    16.53.3 The log_sum operator . . . . . . . . . . . . . . . . . . . 829

    16.53.4 Options . . . . . . . . . . . . . . . . . . . . . . . . . . . 830

    16.53.5 Hermite’s method . . . . . . . . . . . . . . . . . . . . . . 833

    16.53.6 Tracing the ratint program . . . . . . . . . . . . . . . . 834

    16.53.7 Bugs, suggestions and comments . . . . . . . . . . . . . 835

    Bibliography . . . . . . . . . . . . . . . . . . . . . . . . . . . . 835

    16.54REACTEQN: Support for chemical reaction equation systems . . 835

    16.55REDLOG: Extend REDUCE to a computer logic system . . . . . 840

    16.56RESET: Code to reset REDUCE to its initial state . . . . . . . . . 840

    16.57RESIDUE: A residue package . . . . . . . . . . . . . . . . . . . 841

    16.58RLFI: REDUCE LATEX formula interface . . . . . . . . . . . . . . 845

    16.58.1 APPENDIX: Summary and syntax . . . . . . . . . . . . . 847

    Bibliography . . . . . . . . . . . . . . . . . . . . . . . . . . . . 849

    16.59ROOTS: A REDUCE root finding package . . . . . . . . . . . . . 851

    16.59.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . 851

    16.59.2 Root Finding Strategies . . . . . . . . . . . . . . . . . . . 851

    16.59.3 Top Level Functions . . . . . . . . . . . . . . . . . . . . 852

    16.59.4 Switches Used in Input . . . . . . . . . . . . . . . . . . . 855

    16.59.5 Internal and Output Use of Switches . . . . . . . . . . . . 856

    16.59.6 Root Package Switches . . . . . . . . . . . . . . . . . . . 856

    16.59.7 Operational Parameters and Parameter Setting. . . . . . . 857

    16.59.8 Avoiding truncation of polynomials on input . . . . . . . 858

    16.60RSOLVE: Rational/integer polynomial solvers . . . . . . . . . . . 859

    16.60.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . 859

    16.60.2 The user interface . . . . . . . . . . . . . . . . . . . . . . 859

    16.60.3 Examples . . . . . . . . . . . . . . . . . . . . . . . . . . 860

    16.60.4 Tracing . . . . . . . . . . . . . . . . . . . . . . . . . . . 861

  • 20 CONTENTS

    16.61RTRACE: Tracing in REDUCE . . . . . . . . . . . . . . . . . . 862

    16.61.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . 862

    16.61.2 RTrace versus RDebug . . . . . . . . . . . . . . . . . . . 862

    16.61.3 Procedure tracing: RTR, UNRTR . . . . . . . . . . . . . 863

    16.61.4 Assignment tracing: RTRST, UNRTRST . . . . . . . . . 865

    16.61.5 Tracing active rules: TRRL, UNTRRL . . . . . . . . . . 867

    16.61.6 Tracing inactive rules: TRRLID, UNTRRLID . . . . . . . 868

    16.61.7 Output control: RTROUT . . . . . . . . . . . . . . . . . 869

    16.62SCOPE: REDUCE source code optimization package . . . . . . . 870

    16.63SETS: A basic set theory package . . . . . . . . . . . . . . . . . 871

    16.63.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . 871

    16.63.2 Infix operator precedence . . . . . . . . . . . . . . . . . . 872

    16.63.3 Explicit set representation and mkset . . . . . . . . . . . 872

    16.63.4 Union and intersection . . . . . . . . . . . . . . . . . . . 873

    16.63.5 Symbolic set expressions . . . . . . . . . . . . . . . . . . 873

    16.63.6 Set difference . . . . . . . . . . . . . . . . . . . . . . . . 874

    16.63.7 Predicates on sets . . . . . . . . . . . . . . . . . . . . . . 875

    16.63.8 Possible future developments . . . . . . . . . . . . . . . . 879

    16.64SPARSE: Sparse Matrix Calculations . . . . . . . . . . . . . . . 880

    16.64.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . 880

    16.64.2 Sparse Matrix Calculations . . . . . . . . . . . . . . . . . 880

    16.64.3 Sparse Matrix Expressions . . . . . . . . . . . . . . . . . 881

    16.64.4 Operators with Sparse Matrix Arguments . . . . . . . . . 881

    16.64.5 The Linear Algebra Package for Sparse Matrices . . . . . 883

    16.64.6 Available Functions . . . . . . . . . . . . . . . . . . . . . 884

    16.64.7 Fast Linear Algebra . . . . . . . . . . . . . . . . . . . . . 906

    16.64.8 Acknowledgments . . . . . . . . . . . . . . . . . . . . . 906

    Bibliography . . . . . . . . . . . . . . . . . . . . . . . . . . . . 906

    16.65SPDE: Finding symmetry groups of PDE’s . . . . . . . . . . . . . 907

    16.65.1 Description of the System Functions and Variables . . . . 907

  • CONTENTS 21

    16.65.2 How to Use the Package . . . . . . . . . . . . . . . . . . 910

    16.65.3 Test File . . . . . . . . . . . . . . . . . . . . . . . . . . . 916

    16.66SPECFN: Package for special functions . . . . . . . . . . . . . . 919

    16.66.1 Simplification and Approximation . . . . . . . . . . . . . 920

    16.66.2 Constants . . . . . . . . . . . . . . . . . . . . . . . . . . 922

    16.66.3 Bernoulli Numbers and Euler Numbers . . . . . . . . . . 922

    16.66.4 Fibonacci Numbers and Fibonacci Polynomials . . . . . . 923

    16.66.5 Stirling Numbers . . . . . . . . . . . . . . . . . . . . . . 923

    16.66.6 The Γ Function, and Related Functions . . . . . . . . . . 923

    16.66.7 Bessel Functions . . . . . . . . . . . . . . . . . . . . . . 925

    16.66.8 Hypergeometric and Other Functions . . . . . . . . . . . 926

    16.66.9 Integral Functions . . . . . . . . . . . . . . . . . . . . . 926

    16.66.10Airy Functions . . . . . . . . . . . . . . . . . . . . . . . 927

    16.66.11Polynomial Functions . . . . . . . . . . . . . . . . . . . 927

    16.66.12Spherical and Solid Harmonics . . . . . . . . . . . . . . . 928

    16.66.13Jacobi’s Elliptic Functions . . . . . . . . . . . . . . . . . 929

    16.66.14Elliptic Integrals . . . . . . . . . . . . . . . . . . . . . . 931

    16.66.15Elliptic Theta Functions . . . . . . . . . . . . . . . . . . 934

    16.66.16Lambert’s W function . . . . . . . . . . . . . . . . . . . 936

    16.66.173j symbols and Clebsch-Gordan Coefficients . . . . . . . 936

    16.66.186j symbols . . . . . . . . . . . . . . . . . . . . . . . . . 936

    16.66.19Acknowledgements . . . . . . . . . . . . . . . . . . . . . 936

    16.66.20Table of Operators and Constants . . . . . . . . . . . . . 937

    Bibliography . . . . . . . . . . . . . . . . . . . . . . . . . . . . 940

    16.67SPECFN2: Package for special special functions . . . . . . . . . 940

    16.67.1 REDUCE operator HYPERGEOMETRIC . . . . . . . . . 941

    16.67.2 Extending the HYPERGEOMETRIC operator . . . . . . 942

    16.67.3 REDUCE operator meijerg . . . . . . . . . . . . . . . 942

    Bibliography . . . . . . . . . . . . . . . . . . . . . . . . . . . . 943

    16.68SSTOOLS: Computations with supersymmetric algebraic and dif-ferential expressions . . . . . . . . . . . . . . . . . . . . . . . . 944

  • 22 CONTENTS

    16.68.1 Overview . . . . . . . . . . . . . . . . . . . . . . . . . . 944

    Bibliography . . . . . . . . . . . . . . . . . . . . . . . . . . . . 945

    16.69SUM: A package for series summation . . . . . . . . . . . . . . . 946

    16.70SYMMETRY: Operations on symmetric matrices . . . . . . . . . 948

    16.70.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . 948

    16.70.2 Operators for linear representations . . . . . . . . . . . . 948

    16.70.3 Display Operators . . . . . . . . . . . . . . . . . . . . . 950

    16.70.4 Storing a new group . . . . . . . . . . . . . . . . . . . . 950

    Bibliography . . . . . . . . . . . . . . . . . . . . . . . . . . . . 952

    16.71TAYLOR: Manipulation of Taylor series . . . . . . . . . . . . . . 953

    16.71.1 Basic Use . . . . . . . . . . . . . . . . . . . . . . . . . . 953

    16.71.2 Caveats . . . . . . . . . . . . . . . . . . . . . . . . . . . 957

    16.71.3 Warning messages . . . . . . . . . . . . . . . . . . . . . 958

    16.71.4 Error messages . . . . . . . . . . . . . . . . . . . . . . . 958

    16.71.5 Comparison to other packages . . . . . . . . . . . . . . . 960

    16.72TPS: A extendible power series package . . . . . . . . . . . . . . 962

    16.72.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . 962

    16.72.2 PS Operator . . . . . . . . . . . . . . . . . . . . . . . . . 962

    16.72.3 PSEXPLIM Operator . . . . . . . . . . . . . . . . . . . . 964

    16.72.4 PSPRINTORDER Switch . . . . . . . . . . . . . . . . . 964

    16.72.5 PSORDLIM Operator . . . . . . . . . . . . . . . . . . . 964

    16.72.6 PSTERM Operator . . . . . . . . . . . . . . . . . . . . . 965

    16.72.7 PSORDER Operator . . . . . . . . . . . . . . . . . . . . 965

    16.72.8 PSSETORDER Operator . . . . . . . . . . . . . . . . . . 965

    16.72.9 PSDEPVAR Operator . . . . . . . . . . . . . . . . . . . 966

    16.72.10PSEXPANSIONPT operator . . . . . . . . . . . . . . . . 966

    16.72.11PSFUNCTION Operator . . . . . . . . . . . . . . . . . . 966

    16.72.12PSCHANGEVAR Operator . . . . . . . . . . . . . . . . 967

    16.72.13PSREVERSE Operator . . . . . . . . . . . . . . . . . . . 967

    16.72.14PSCOMPOSE Operator . . . . . . . . . . . . . . . . . . 968

  • CONTENTS 23

    16.72.15PSSUM Operator . . . . . . . . . . . . . . . . . . . . . . 969

    16.72.16PSTAYLOR Operator . . . . . . . . . . . . . . . . . . . 970

    16.72.17PSCOPY Operator . . . . . . . . . . . . . . . . . . . . . 970

    16.72.18PSTRUNCATE Operator . . . . . . . . . . . . . . . . . . 971

    16.72.19Arithmetic Operations . . . . . . . . . . . . . . . . . . . 971

    16.72.20Differentiation . . . . . . . . . . . . . . . . . . . . . . . 972

    16.72.21Restrictions and Known Bugs . . . . . . . . . . . . . . . 972

    16.73TRI: TeX REDUCE interface . . . . . . . . . . . . . . . . . . . . 974

    16.74TRIGD: Trigonometrical Functions with Degree Arguments . . . 975

    16.74.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . 975

    16.74.2 Simplification . . . . . . . . . . . . . . . . . . . . . . . . 977

    16.74.3 Numerical Evaluation . . . . . . . . . . . . . . . . . . . 978

    16.74.4 Bugs, Restrictions and Planned Extensions . . . . . . . . 981

    16.75TRIGINT: Weierstrass substitution in REDUCE . . . . . . . . . . 983

    16.75.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . 983

    16.75.2 Statement of the Algorithm . . . . . . . . . . . . . . . . . 984

    16.75.3 REDUCE implementation . . . . . . . . . . . . . . . . . 984

    16.75.4 Definite Integration . . . . . . . . . . . . . . . . . . . . . 986

    16.75.5 Tracing the trigint function . . . . . . . . . . . . . . . . 987

    16.75.6 Bugs, comments, suggestions . . . . . . . . . . . . . . . 987

    Bibliography . . . . . . . . . . . . . . . . . . . . . . . . . . . . 988

    16.76TRIGSIMP: Simplification and factorization of trigonometric andhyperbolic functions . . . . . . . . . . . . . . . . . . . . . . . . 988

    16.76.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . 988

    16.76.2 Simplifying trigonometric expressions . . . . . . . . . . . 988

    16.76.3 Factorizing trigonometric expressions . . . . . . . . . . . 992

    16.76.4 GCDs of trigonometric expressions . . . . . . . . . . . . 993

    16.76.5 Further Examples . . . . . . . . . . . . . . . . . . . . . . 993

    Bibliography . . . . . . . . . . . . . . . . . . . . . . . . . . . . 997

    16.77TURTLE: Turtle Graphics Interface for REDUCE . . . . . . . . . 998

    16.77.1 Turtle Graphics . . . . . . . . . . . . . . . . . . . . . . . 998

  • 24 CONTENTS

    16.77.2 Implementation . . . . . . . . . . . . . . . . . . . . . . . 998

    16.77.3 Turtle Functions . . . . . . . . . . . . . . . . . . . . . . 999

    16.77.4 Examples . . . . . . . . . . . . . . . . . . . . . . . . . . 1004

    16.77.5 References . . . . . . . . . . . . . . . . . . . . . . . . . 1010

    16.78WU: Wu algorithm for polynomial systems . . . . . . . . . . . . 1012

    16.79XCOLOR: Color factor in some field theories . . . . . . . . . . . 1014

    16.80XIDEAL: Gröbner Bases for exterior algebra . . . . . . . . . . . 1016

    16.80.1 Description . . . . . . . . . . . . . . . . . . . . . . . . . 1016

    16.80.2 Declarations . . . . . . . . . . . . . . . . . . . . . . . . 1017

    16.80.3 Operators . . . . . . . . . . . . . . . . . . . . . . . . . . 1018

    16.80.4 Switches . . . . . . . . . . . . . . . . . . . . . . . . . . 1020

    16.80.5 Examples . . . . . . . . . . . . . . . . . . . . . . . . . . 1020

    Bibliography . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1023

    16.81ZEILBERG: Indefinite and definite summation . . . . . . . . . . 1024

    16.81.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . 1024

    16.81.2 Gosper Algorithm . . . . . . . . . . . . . . . . . . . . . 1024

    16.81.3 Zeilberger Algorithm . . . . . . . . . . . . . . . . . . . . 1025

    16.81.4 REDUCE operator GOSPER . . . . . . . . . . . . . . . . 1026

    16.81.5 REDUCE operator EXTENDED_GOSPER . . . . . . . . . 1029

    16.81.6 REDUCE operator SUMRECURSION . . . . . . . . . . . 1029

    16.81.7 REDUCE operator EXTENDED_SUMRECURSION . . . . 1032

    16.81.8 REDUCE operator HYPERRECURSION . . . . . . . . . . 1033

    16.81.9 REDUCE operator HYPERSUM . . . . . . . . . . . . . . 1035

    16.81.10REDUCE operator SUMTOHYPER . . . . . . . . . . . . . 1037

    16.81.11Simplification Operators . . . . . . . . . . . . . . . . . . 1037

    16.81.12Tracing . . . . . . . . . . . . . . . . . . . . . . . . . . . 1039

    16.81.13Global Variables and Switches . . . . . . . . . . . . . . . 1041

    16.81.14Messages . . . . . . . . . . . . . . . . . . . . . . . . . . 1042

    Bibliography . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1043

    16.82ZTRANS: Z-transform package . . . . . . . . . . . . . . . . . . 1045

  • CONTENTS 25

    16.82.1 Z-Transform . . . . . . . . . . . . . . . . . . . . . . . . 1045

    16.82.2 Inverse Z-Transform . . . . . . . . . . . . . . . . . . . . 1045

    16.82.3 Input for the Z-Transform . . . . . . . . . . . . . . . . . 1045

    16.82.4 Input for the Inverse Z-Transform . . . . . . . . . . . . . 1046

    16.82.5 Application of the Z-Transform . . . . . . . . . . . . . . 1047

    16.82.6 EXAMPLES . . . . . . . . . . . . . . . . . . . . . . . . 1047

    Bibliography . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1053

    17 Symbolic Mode 1055

    17.1 Symbolic Infix Operators . . . . . . . . . . . . . . . . . . . . . . 1057

    17.2 Symbolic Expressions . . . . . . . . . . . . . . . . . . . . . . . . 1057

    17.3 Quoted Expressions . . . . . . . . . . . . . . . . . . . . . . . . . 1057

    17.4 Lambda Expressions . . . . . . . . . . . . . . . . . . . . . . . . 1057

    17.5 Symbolic Assignment Statements . . . . . . . . . . . . . . . . . 1058

    17.6 FOR EACH Statement . . . . . . . . . . . . . . . . . . . . . . . 1059

    17.7 Symbolic Procedures . . . . . . . . . . . . . . . . . . . . . . . . 1059

    17.8 Standard Lisp Equivalent of Reduce Input . . . . . . . . . . . . . 1060

    17.9 Communicating with Algebraic Mode . . . . . . . . . . . . . . . 1060

    17.9.1 Passing Algebraic Mode Values to Symbolic Mode . . . . 1061

    17.9.2 Passing Symbolic Mode Values to Algebraic Mode . . . . 1064

    17.9.3 Complete Example . . . . . . . . . . . . . . . . . . . . . 1064

    17.9.4 Defining Procedures for Intermode Communication . . . . 1065

    17.10Rlisp ’88 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1066

    17.11References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1066

    18 Calculations in High Energy Physics 1067

    18.1 High Energy Physics Operators . . . . . . . . . . . . . . . . . . . 1067

    18.1.1 . (Cons) Operator . . . . . . . . . . . . . . . . . . . . . . 1067

    18.1.2 G Operator for Gamma Matrices . . . . . . . . . . . . . . 1068

    18.1.3 EPS Operator . . . . . . . . . . . . . . . . . . . . . . . . 1069

    18.2 Vector Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . 1069

  • 26 CONTENTS

    18.3 Additional Expression Types . . . . . . . . . . . . . . . . . . . . 1070

    18.3.1 Vector Expressions . . . . . . . . . . . . . . . . . . . . . 1070

    18.3.2 Dirac Expressions . . . . . . . . . . . . . . . . . . . . . 1070

    18.4 Trace Calculations . . . . . . . . . . . . . . . . . . . . . . . . . 1071

    18.5 Mass Declarations . . . . . . . . . . . . . . . . . . . . . . . . . . 1071

    18.6 Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1072

    18.7 Extensions to More Than Four Dimensions . . . . . . . . . . . . 1073

    19 REDUCE and Rlisp Utilities 1075

    19.1 The Standard Lisp Compiler . . . . . . . . . . . . . . . . . . . . 1075

    19.2 Fast Loading Code Generation Program . . . . . . . . . . . . . . 1076

    19.3 The Standard Lisp Cross Reference Program . . . . . . . . . . . . 1077

    19.3.1 Restrictions . . . . . . . . . . . . . . . . . . . . . . . . . 1078

    19.3.2 Usage . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1078

    19.3.3 Options . . . . . . . . . . . . . . . . . . . . . . . . . . . 1078

    19.4 Prettyprinting REDUCE Expressions . . . . . . . . . . . . . . . . 1078

    19.5 Prettyprinting Standard Lisp S-Expressions . . . . . . . . . . . . 1079

    20 Maintaining REDUCE 1081

    A Reserved Identifiers 1085

    B Changes since Version 3.8 1091

  • Abstract

    This document provides the user with a description of the algebraic programmingsystem REDUCE. The capabilities of this system include:

    1. expansion and ordering of polynomials and rational functions,

    2. substitutions and pattern matching in a wide variety of forms,

    3. automatic and user controlled simplification of expressions,

    4. calculations with symbolic matrices,

    5. arbitrary precision integer and real arithmetic,

    6. facilities for defining new functions and extending program syntax,

    7. analytic differentiation and integration,

    8. factorization of polynomials,

    9. facilities for the solution of a variety of algebraic equations,

    10. facilities for the output of expressions in a variety of formats,

    11. facilities for generating numerical programs from symbolic input,

    12. Dirac matrix calculations of interest to high energy physicists.

    27

  • 28 CONTENTS

  • Acknowledgment

    The production of this version of the manual has been the result of the contribu-tions of a large number of individuals who have taken the time and effort to suggestimprovements to previous versions, and to draft new sections. Particular thanksare due to Gerry Rayna, who provided a draft rewrite of most of the first half ofthe manual. Other people who have made significant contributions have includedJohn Fitch, Martin Griss, Stan Kameny, Jed Marti, Herbert Melenk, Don Morri-son, Arthur Norman, Eberhard Schrüfer, Larry Seward and Walter Tietze. Finally,Richard Hitt produced a TEX version of the REDUCE 3.3 manual, which has beena useful guide for the production of the LATEX version of this manual.

    29

  • 30 CONTENTS

  • Chapter 1

    Introductory Information

    REDUCE is a system for carrying out algebraic operations accurately, no matterhow complicated the expressions become. It can manipulate polynomials in a va-riety of forms, both expanding and factoring them, and extract various parts ofthem as required. REDUCE can also do differentiation and integration, but weshall only show trivial examples of this in this introduction. Other topics not con-sidered include the use of arrays, the definition of procedures and operators, thespecific routines for high energy physics calculations, the use of files to eliminaterepetitious typing and for saving results, and the editing of the input text.

    Also not considered in any detail in this introduction are the many options thatare available for varying computational procedures, output forms, number systemsused, and so on.

    REDUCE is designed to be an interactive system, so that the user can input an al-gebraic expression and see its value before moving on to the next calculation. Forthose systems that do not support interactive use, or for those calculations, espe-cially long ones, for which a standard script can be defined, REDUCE can also beused in batch mode. In this case, a sequence of commands can be given to RE-DUCE and results obtained without any user interaction during the computation.

    In this introduction, we shall limit ourselves to the interactive use of REDUCE,since this illustrates most completely the capabilities of the system. When RE-DUCE is called, it begins by printing a banner message like:

    Reduce (Free CSL version), 25-Oct-14 ...

    where the version number and the system release date will change from time totime. It proceeds to execute the commands in user’s startup (reducerc) file, ifsuch a file is present, then prompts the user for input by:

    1:

    31

  • 32 CHAPTER 1. INTRODUCTORY INFORMATION

    You can now type a REDUCE statement, terminated by a semicolon to indicate theend of the expression, for example:

    (x+y+z)^2;

    This expression would normally be followed by another character (a Return onan ASCII keyboard) to “wake up” the system, which would then input the expres-sion, evaluate it, and return the result:

    2 2 2X + 2*X*Y + 2*X*Z + Y + 2*Y*Z + Z

    Let us review this simple example to learn a little more about the way that RE-DUCE works. First, we note that REDUCE deals with variables, and constantslike other computer languages, but that in evaluating the former, a variable canstand for itself. Expression evaluation normally follows the rules of high schoolalgebra, so the only surprise in the above example might be that the expression wasexpanded. REDUCE normally expands expressions where possible, collecting liketerms and ordering the variables in a specific manner. However, expansion, order-ing of variables, format of output and so on is under control of the user, and variousdeclarations are available to manipulate these.

    Another characteristic of the above example is the use of lower case on input andupper case on output. In fact, input may be in either mode, but output is usually inlower case. To make the difference between input and output more distinct in thismanual, all expressions intended for input will be shown in lower case and outputin upper case. However, for stylistic reasons, we represent all single identifiers inthe text in upper case.

    Finally, the numerical prompt can be used to reference the result in a later compu-tation.

    As a further illustration of the system features, the user should try:

    for i:= 1:40 product i;

    The result in this case is the value of 40!,

    815915283247897734345611269596115894272000000000

    You can also get the same result by saying

    factorial 40;

    Since we want exact results in algebraic calculations, it is essential that integerarithmetic be performed to arbitrary precision, as in the above example. Further-

  • 33

    more, the FOR statement in the above is illustrative of a whole range of combiningforms that REDUCE supports for the convenience of the user.

    Among the many options in REDUCE is the use of other number systems, such asmultiple precision floating point with any specified number of digits — of use ifroundoff in, say, the 100th digit is all that can be tolerated.

    In many cases, it is necessary to use the results of one calculation in succeedingcalculations. One way to do this is via an assignment for a variable, such as

    u := (x+y+z)^2;

    If we now use U in later calculations, the value of the right-hand side of the abovewill be used.

    The results of a given calculation are also saved in the variable WS (for WorkSpace),so this can be used in the next calculation for further processing.

    For example, the expression

    df(ws,x);

    following the previous evaluation will calculate the derivative of (x+y+z)^2withrespect to X. Alternatively,

    int(ws,y);

    would calculate the integral of the same expression with respect to y.

    REDUCE is also capable of handling symbolic matrices. For example,

    matrix m(2,2);

    declares m to be a two by two matrix, and

    m := mat((a,b),(c,d));

    gives its elements values. Expressions that include M and make algebraic sensemay now be evaluated, such as 1/m to give the inverse, 2*m - u*m^2 to give usanother matrix and det(m) to give us the determinant of M.

    REDUCE has a wide range of substitution capabilities. The system knows aboutelementary functions, but does not automatically invoke many of their well-knownproperties. For example, products of trigonometrical functions are not convertedautomatically into multiple angle expressions, but if the user wants this, he can say,for example:

    (sin(a+b)+cos(a+b))*(sin(a-b)-cos(a-b))

  • 34 CHAPTER 1. INTRODUCTORY INFORMATION

    where cos(~x)*cos(~y) = (cos(x+y)+cos(x-y))/2,cos(~x)*sin(~y) = (sin(x+y)-sin(x-y))/2,sin(~x)*sin(~y) = (cos(x-y)-cos(x+y))/2;

    where the tilde in front of the variables X and Y indicates that the rules apply forall values of those variables. The result of this calculation is

    -(COS(2*A) + SIN(2*B))

    See also the user-contributed packages ASSIST (chapter 16.5), CAMAL (chap-ter 16.10) and TRIGSIMP (chapter 16.76).

    Another very commonly used capability of the system, and an illustration of one ofthe many output modes of REDUCE, is the ability to output results in a FORTRANcompatible form. Such results can then be used in a FORTRAN based numericalcalculation. This is particularly useful as a way of generating algebraic formulasto be used as the basis of extensive numerical calculations.

    For example, the statements

    on fort;df(log(x)*(sin(x)+cos(x))/sqrt(x),x,2);

    will result in the output

    ANS=(-4.*LOG(X)*COS(X)*X**2-4.*LOG(X)*COS(X)*X+3.*. LOG(X)*COS(X)-4.*LOG(X)*SIN(X)*X**2+4.*LOG(X)*. SIN(X)*X+3.*LOG(X)*SIN(X)+8.*COS(X)*X-8.*COS(X)-8.. *SIN(X)*X-8.*SIN(X))/(4.*SQRT(X)*X**2)

    These algebraic manipulations illustrate the algebraic mode of REDUCE. RE-DUCE is based on Standard Lisp. A symbolic mode is also available for executingLisp statements. These statements follow the syntax of Lisp, e.g.

    symbolic car ’(a);

    Communication between the two modes is possible.

    With this simple introduction, you are now in a position to study the material in thefull REDUCE manual in order to learn just how extensive the range of facilitiesreally is. If further tutorial material is desired, the seven REDUCE InteractiveLessons by David R. Stoutemyer are recommended. These are normally distributedwith the system.

  • Chapter 2

    Structure of Programs

    A REDUCE program consists of a set of functional commands which are evaluatedsequentially by the computer. These commands are built up from declarations,statements and expressions. Such entities are composed of sequences of numbers,variables, operators, strings, reserved words and delimiters (such as commas andparentheses), which in turn are sequences of basic characters.

    2.1 The REDUCE Standard Character Set

    The basic characters which are used to build REDUCE symbols are the following:

    1. The 26 letters a through z

    2. The 10 decimal digits 0 through 9

    3. The special characters _ ! " $ % ’ ( ) * + , - . / : ; <> = { } 〈blank〉

    With the exception of strings and characters preceded by an exclamation mark, thecase of characters is ignored: depending of the underlying LISP they will all beconverted internally into lower case or upper case: ALPHA, Alpha and alpharepresent the same symbol. Most implementations allow you to switch this con-version off. The operating instructions for a particular implementation should beconsulted on this point. For portability, we shall limit ourselves to the standardcharacter set in this exposition.

    35

  • 36 CHAPTER 2. STRUCTURE OF PROGRAMS

    2.2 Numbers

    There are several different types of numbers available in REDUCE. Integers consistof a signed or unsigned sequence of decimal digits written without a decimal point,for example:

    -2, 5396, +32

    In principle, there is no practical limit on the number of digits permitted as exactarithmetic is used in most implementations. (You should however check the spe-cific instructions for your particular system implementation to make sure that thisis true.) For example, if you ask for the value of 22000 you get it displayed as anumber of 603 decimal digits, taking up several lines of output on an interactivedisplay. It should be borne in mind of course that computations with such longnumbers can be quite slow.

    Numbers that aren’t integers are usually represented as the quotient of two integers,in lowest terms: that is, as rational numbers.

    In essentially all versions of REDUCE it is also possible (but not always desirable!)to ask REDUCE to work with floating point approximations to numbers again, toany precision. Such numbers are called real. They can be input in two ways:

    1. as a signed or unsigned sequence of any number of decimal digits with anembedded or trailing decimal point.

    2. as in 1. followed by a decimal exponent which is written as the letter Efollowed by a signed or unsigned integer.

    e.g. 32. +32.0 0.32E2 and 320.E-1 are all representations of 32.

    The declaration SCIENTIFIC_NOTATION controls the output format of float-ing point numbers. At the default settings, any number with five or less dig-its before the decimal point is printed in a fixed-point notation, e.g., 12345.6.Numbers with more than five digits are printed in scientific notation, e.g.,1.234567E+5. Similarly, by default, any number with eleven or more zerosafter the decimal point is printed in scientific notation. To change these defaults,SCIENTIFIC_NOTATION can be used in one of two ways.

    SCIENTIFIC_NOTATION m;

    where m is a positive integer, sets the printing format so that a number with morethan m digits before the decimal point, or m or more zeros after the decimal point,is printed in scientific notation.

    SCIENTIFIC_NOTATION{m,n},

    with m and n both positive integers, sets the format so that a number with more

  • 2.3. IDENTIFIERS 37

    than m digits before the decimal point, or n or more zeros after the decimal pointis printed in scientific notation.

    CAUTION: The unsigned part of any number may not begin with a decimal point,as this causes confusion with the CONS (.) operator, i.e., NOT ALLOWED ARE:.5 -.23 +.12; use 0.5 -0.23 +0.12 instead.

    2.3 Identifiers

    Identifiers in REDUCE consist of one or more alphanumeric characters (i.e. alpha-betic letters or decimal digits) the first of which must be alphabetic. The maximumnumber of characters allowed is implementation dependent, although twenty-fouris permitted in most implementations. In addition, the underscore character (_) isconsidered a letter if it is within an identifier. For example,

    a az p1 q23p a_very_long_variable

    are all identifiers, whereas

    _a

    is not.

    A sequence of alphanumeric characters in which the first is a digit is interpreted asa product. For example, 2ab3c is interpreted as 2*ab3c. There is one exceptionto this: If the first letter after a digit is E, the system will try to interpret that part ofthe sequence as a real number, which may fail in some cases. For example, 2E12is the real number 2.0 ∗ 1012, 2e3c is 2000.0*C, and 2ebc gives an error.

    Special characters, such as -, *, and blank, may be used in identifiers too, even asthe first character, but each must be preceded by an exclamation mark in input. Forexample:

    light!-years d!*!*n good! morning!$sign !5goldrings

    CAUTION: Many system identifiers have such special characters in their names(especially * and =). If the user accidentally picks the name of one of them for hisown purposes it may have catastrophic consequences for his REDUCE run. Usersare therefore advised to avoid such names.

    Identifiers are used as variables, labels and to name arrays, operators and proce-dures.

  • 38 CHAPTER 2. STRUCTURE OF PROGRAMS

    Restrictions

    The reserved words listed in section (A may not be used as identifiers. No spacesmay appear within an identifier, and an identifier may not extend over a line of text.

    2.4 Variables

    Every variable is named by an identifier, and is given a specific type. The type isof no concern to the ordinary user. Most variables are allowed to have the defaulttype, called scalar. These can receive, as values, the representation of any ordinaryalgebraic expression. In the absence of such a value, they stand for themselves.

    Reserved Variables

    Several variables in REDUCE have particular properties which should not bechanged by the user. These variables include:

    CATALAN Catalan’s constant, defined as

    ∞∑n=0

    (−1)n

    (2n+ 1)2.

    E Intended to represent the base of the natural logarithms. log(e),if it occurs in an expression, is automatically replaced by 1. IfROUNDED is on, E is replaced by the value of E to the current degreeof floating point precision.

    EULER_GAMMA Euler’s constant, also available as −ψ(1).

    GOLDEN_RATIO The number 1+√

    52 .

    I Intended to represent the square

    root of −1. i^2 is replaced by −1, and appropriately for higherpowers of I. This applies only to the symbol I used on the top level,not as a formal parameter in a procedure, a local variable, nor in thecontext for i:= ....

    INFINITY Intended to represent∞in limit and power series calculations for example, as well as in def-inite integration. Note however that the current system does not doproper arithmetic on∞. For example, infinity + infinityis 2*infinity.

  • 2.5. STRINGS 39

    KHINCHIN Khinchin’s constant, defined as

    ∞∏n=1

    (1 +

    1

    n(n+ 2)

    )log2 n.

    NEGATIVE Used in the Roots package.

    NIL In REDUCE (algebraic mode only) taken as a synonym for zero.Therefore NIL cannot be used as a variable.

    PI Intended to represent the circular constant. With ROUNDED on, itis replaced by the value of π to the current degree of floating pointprecision.

    POSITIVE Used in the Roots package.

    T Must not be used as a formal parameter or local variable in proce-dures, since conflict arises with the symbolic mode meaning of T astrue.

    Other reserved variables, such as LOW_POW, described in other sections, are listedin Appendix A.

    Using these reserved variables inappropriately will lead to errors.

    There are also internal variables used by REDUCE that have similar restrictions.These usually have an asterisk in their names, so it is unlikely a casual user woulduse one. An example of such a variable is K!* used in the asymptotic commandpackage.

    Certain words are reserved in REDUCE. They may only be used in the mannerintended. A list of these is given in the section “Reserved Identifiers”. There are,of course, an impossibly large number of such names to keep in mind. The readermay therefore want to make himself a copy of the list, deleting the names he doesn’tthink he is likely to use by mistake.

    2.5 Strings

    Strings are used in WRITE statements, in other output statements (such as errormessages), and to name files. A string consists of any number of characters en-closed in double quotes. For example:

    "A String".

  • 40 CHAPTER 2. STRUCTURE OF PROGRAMS

    Lower case characters within a string are not converted to upper case.

    The string "" represents the empty string. A double quote may be included in astring by preceding it by another double quote. Thus "a""b" is the string a"b,and """" is the string consisting of the single character ".

    2.6 Comments

    Text can be included in program listings for the convenience of human readers, insuch a way that REDUCE pays no attention to it. There are two ways to do this:

    1. Everything from the word COMMENT to the next statement terminator, nor-mally ; or $, is ignored. Such comments can be placed anywhere a blankcould properly appear. (Note that END and >> are not treated as COMMENTdelimiters!)

    2. Everything from the symbol % to the end of the line on which it appears isignored. Such comments can be placed as the last part of any line. Statementterminators have no special meaning in such comments. Remember to puta semicolon before the % if the earlier part of the line is intended to be soterminated. Remember also to begin each line of a multi-line % commentwith a % sign.

    2.7 Operators

    Operators in REDUCE are specified by name and type. There are two types, in-fix and prefix. Operators can be purely abstract, just symbols with no properties;they can have values assigned (using := or simple LET declarations) for specificarguments; they can have properties declared for some collection of arguments(using more general LET declarations); or they can be fully defined (usually by aprocedure declaration).

    Infix operators have a definite precedence with respect to one another, and normallyoccur between their arguments. For example:

    a + b - c (spaces optional)x

  • 2.7. OPERATORS 41

    Prefix operators occur to the left of their arguments, which are written as a listenclosed in parentheses and separated by commas, as with normal mathematicalfunctions, e.g.,

    cos(u)df(x^2,x)q(v+w)

    Unmatched parentheses, incorrect groupings of infix operators and the like, natu-rally lead to syntax errors. The parentheses can be omitted (replaced by a spacefollowing the operator name) if the operator is unary and the argument is a singlesymbol or begins with a prefix operator name:

    cos y means cos(y)cos (-y) – parentheses necessarylog cos y means log(cos(y))log cos (a+b) means log(cos(a+b))

    but

    cos a*b means (cos a)*bcos -y is erroneous (treated as a variable

    “cos” minus the variable y)

    A unary prefix operator has a precedence higher than any infix operator, includingunary infix operators. In other words, REDUCE will always interpret cos y +3 as (cos y) + 3 rather than as cos(y + 3).

    Infix operators may also be used in a prefix format on input, e.g., +(a,b,c). Onoutput, however, such expressions will always be printed in infix form (i.e., a +b + c for this example).

    A number of prefix operators are built into the system with predefined properties.Users may also add new operators and define their rules for simplification. Thebuilt in operators are described in another section.

    Built-In Infix Operators

    The following infix operators are built into the system. They are all defined inter-nally as procedures.

    〈infix operator〉 −→ where | := | or | and | member | memq |= | neq | eq | >= | > |

  • 42 CHAPTER 2. STRUCTURE OF PROGRAMS

    These operators may be further divided into the following subclasses:

    〈assignment operator〉 −→ :=〈logical operator〉 −→ or | and | member | memq〈relational operator〉 −→ = | neq | eq | >= | > | = geq> greaterp

  • 2.7. OPERATORS 43

    Parentheses may be used to specify the order of combination. If parentheses areomitted then this order is by the ordering of the precedence list defined by theright-hand side of the 〈infix operator〉 table at the beginning of this section, fromlowest to highest. In other words, WHERE has the lowest precedence, and . (thedot operator) the highest.

  • 44 CHAPTER 2. STRUCTURE OF PROGRAMS

  • Chapter 3

    Expressions

    REDUCE expressions may be of several types and consist of sequences of num-bers, variables, operators, left and right parentheses and commas. The most com-mon types are as follows:

    3.1 Scalar Expressions

    Using the arithmetic operations + - * / ^ (power) and parentheses, scalarexpressions are composed from numbers, ordinary “scalar” variables (identifiers),array names with subscripts, operator or procedure names with arguments andstatement expressions.

    Examples:

    xx^3 - 2*y/(2*z^2 - df(x,z))(p^2 + m^2)^(1/2)*log (y/m)a(5) + b(i,q)

    The symbol ** may be used as an alternative to the caret symbol (^) for formingpowers, particularly in those systems that do not support a caret symbol.

    Statement expressions, usually in parentheses, can also form part of a scalar ex-pression, as in the example

    w + (c:=x+y) + z .

    When the algebraic value of an expression is needed, REDUCE determines it, start-ing with the algebraic values of the parts, roughly as follows:

    Variables and operator symbols with an argument list have the algebraic values

    45

  • 46 CHAPTER 3. EXPRESSIONS

    they were last assigned, or if never assigned stand for themselves. However, arrayelements have the algebraic values they were last assigned, or, if never assigned,are taken to be 0.

    Procedures are evaluated with the values of their actual parameters.

    In evaluating expressions, the standard rules of algebra are applied. Unfortunately,this algebraic evaluation of an expression is not as unambiguous as is numericalevaluation. This process is generally referred to as “simplification” in the sense thatthe evaluation usually but not always produces a simplified form for the expression.

    There are many options available to the user for carrying out such simplification.If the user doesn’t specify any method, the default method is used. The defaultevaluation of an expression involves expansion of the expression and collectionof like terms, ordering of the terms, evaluation of derivatives and other functionsand substitution for any expressions which have values assigned or declared (seeassignments and LET statements). In many cases, this is all that the user needs.

    The declarations by which the user can exercise some control over the way in whichthe evaluation is performed are explained in other sections. For example, if a real(floating point) number is encountered during evaluation, the system will normallyconvert it into a ratio of two integers. If the user wants to use real arithmetic,he can effect this by the command on rounded;. Other modes for coefficientarithmetic are described elsewhere.

    If an illegal action occurs during evaluation (such as division by zero) or functionsare called with the wrong number of arguments, and so on, an appropriate errormessage is generated.

    3.2 Integer Expressions

    These are expressions which, because of the values of the constants and variablesin them, evaluate to whole numbers.

    Examples:

    2, 37 * 999, (x + 3)^2 - x^2 - 6*x

    are obviously integer expressions.

    j + k - 2 * j^2

    is an integer expression when J and K have values that are integers, or if not integersare such that “the variables and fractions cancel out”, as in

    k - 7/3 - j + 2/3 + 2*j^2.

  • 3.3. BOOLEAN EXPRESSIONS 47

    3.3 Boolean Expressions

    A boolean expression returns a truth value. In the algebraic mode of REDUCE,boolean expressions have the syntactical form:

    〈expression〉〈relational operator〉〈expression〉

    or

    〈boolean operator〉(〈arguments〉)

    or

    〈boolean expression〉〈logical operator〉〈boolean expression〉.

    Parentheses can also be used to control the precedence of expressions.

    In addition to the logical and relational operators defined earlier as infix operators,the following boolean operators are also defined:

    EVENP(U) determines if the number U is even or not;

    FIXP(U) determines if the expression U is integer or not;

    FREEOF(U,V) determines if the expression U does not contain the kernelV anywhere in its structure;

    NUMBERP(U) determines if U is a number or not;

    ORDP(U,V) determines if U is ordered ahead of V by some canonicalordering (based on the expression structure and an internalordering of identifiers);

    PRIMEP(U) true if U is a prime object, i.e., any object other than 0 andplus or minus 1 which is only exactly divisible by itself ora unit.

    Examples:

    j0 or x=-2numberp xfixp x and evenp xnumberp x and x neq 0

  • 48 CHAPTER 3. EXPRESSIONS

    Boolean expressions can only appear directly within IF, FOR, WHILE, and UNTILstatements, as described in other sections. Such expressions cannot be used in placeof ordinary algebraic expressions, or assigned to a variable.

    NB: For those familiar with symbolic mode, the meaning of some of these oper-ators is different in that mode. For example, NUMBERP is true only for integers andreals in symbolic mode.

    When two or more boolean expressions are combined with AND, they are evaluatedone by one until a false expression is found. The rest are not evaluated. Thus

    numberp x and numberp y and x>y

    does not attempt to make the x>y comparison unless X and Y are both verified tobe numbers.

    Similarly, evaluation of a sequence of boolean expressions connected by OR stopsas soon as a true expression is found.

    NB: In a boolean expression, and in a place where a boolean expression is expected,the algebraic value 0 is interpreted as false, while all other algebraic values areconverted to true. So in algebraic mode a procedure can be written for direct usagein boolean expressions, returning say 1 or 0 as its value as in

    procedure polynomialp(u,x);if den(u)=1 and deg(u,x)>=1 then 1 else 0;

    One can then use this in a boolean construct, such as

    if polynomialp(q,z) and not polynomialp(q,y) then ...

    In addition, any procedure that does not have a defined return value (for example,a block without a RETURN statement in it) has the boolean value false.

    3.4 Equations

    Equations are a particular type of expression with the syntax

    〈expression〉=〈expression〉.

    In addition to their role as boolean expressions, they can also be used as argumentsto several operators (e.g., SOLVE), and can be returned as values.

    Under normal circumstances, the right-hand-side of the equation is evaluated butnot the left-hand-side. This also applies to any substitutions made by the SUB

  • 3.5. PROPER STATEMENTS AS EXPRESSIONS 49

    operator. If both sides are to be evaluated, the switch EVALLHSEQP should beturned on.

    To facilitate the handling of equations, two selectors, LHS and RHS, which re-turn the left- and right-hand sides of an equation respectively, are provided. Forexample,

    lhs(a+b=c) -> a+band

    rhs(a+b=c) -> c.

    3.5 Proper Statements as Expressions

    Several kinds of proper statements deliver an algebraic or numerical result of somekind, which can in turn be used as an expression or part of an expression. Forexample, an assignment statement itself has a value, namel