IDENTIFIER

REDUC
E

INDEX

IDENTIFIER _ _ _ _ _ _ _ _ _ _ _ _ type

Identifiers in REDUCE consist of one or more alphanumeric characters, of which the first must be alphabetical. The maximum number of characters allowed is system dependent, but is usually over 100. However, printing is simplified if they are kept under 25 characters.

You can also use special characters in your identifiers, but each must be preceded by an exclamation point ! as an escape character. Useful special characters are # $ % ^ & * - + = ? < > ~ | / ! and the space. Note that the use of the exclamation point as a special character requires a second exclamation point as an escape character. The underscore _ is special in this regard. It must be preceded by an escape character in the first position in an identifier, but is treated like a normal letter within an identifier.

Other characters, such as ( ) # ; ` ' " can also be used if preceded by a !, but as they have special meanings to the Lisp reader it is best to avoid them to avoid confusion.

Many system identifiers have * before or after their names, or - between words. If you accidentally pick one of these names for your own identifier, it could have disastrous effects. For this reason it is wise not to include * or - anywhere in your identifiers.

You will notice that REDUCE does not use the escape characters when it prints identifiers containing special characters; however, you still must use them when you refer to these identifiers. Be careful when editing statements containing escaped special characters to treat the character and its escape as an inseparable pair.

Identifiers are used for variable names, labels for go to statements, and names of arrays, matrices, operators, and procedures. Once an identifier is used as a matrix, array, scalar or operator identifier, it may not be used again as a matrix, array or operator. An operator or array identifier may later be used as a scalar without problems, but a matrix identifier cannot be used as a scalar. All procedures are entered into the system as operators, so the name of a procedure may not be used as a matrix, array, or operator identifier either.

KERNEL

REDUC
E

INDEX

KERNEL _ _ _ _ _ _ _ _ _ _ _ _ type

A kernel is a form that cannot be modified further by the REDUCE canonical simplifier. Scalar variables are always kernels. The other important class of kernels are operators with their arguments. Some examples should help clarify this concept:


        Expression                     Kernel?

          x                              Yes
          varname                        Yes
          cos(a)                         Yes
          log(sin(x**2))                 Yes
          a*b                            No
          (x+y)**4                       No
          matrix-identifier              No

Many REDUCE operators expect kernels among their arguments. Error messages result from attempts to use non-kernel expressions for these arguments.

STRING

REDUC
E

INDEX

STRING _ _ _ _ _ _ _ _ _ _ _ _ type

A string is any collection of characters enclosed in double quotation marks ("). It may be used as an argument for a variety of commands and operators, such as in, rederr and write.

examples:


write "this is a string"; 

  this is a string 


write a, " ", b, " ",c,"!"; 

  A B C!

Concepts

REDUC
E

INDEX

Concepts

  • IDENTIFIER type

  • KERNEL type

  • STRING type

  • assumptions

    REDUC
E

    INDEX

    ASSUMPTIONS _ _ _ _ _ _ _ _ _ _ _ _ variable

    After solving a linear or polynomial equation system with parameters, the variable assumptions contains a list of side relations for the parameters. The solution is valid only as long as none of these expression is zero.

    examples:

    
    solve({a*x-b*y+x,y-c},{x,y});
    
           b*c
      {{x=-----,y=c}} 
          a + 1
    
    
    assumptions; 
    
      {a + 1}
    
    

    CARD_NO

    REDUC
E

    INDEX

    CARD\_NO _ _ _ _ _ _ _ _ _ _ _ _ variable

    card_nosets the total number of cards allowed in a Fortran output statement when fort is on. Default is 20.

    examples:

    
    on fort; 
    
    card_no := 4; 
    
      CARD_NO=4. 
    
    
    z := (x + y)**15; 
    
            ANS1=5005.*X**6*Y**9+3003.*X**5*Y**10+1365.*X**4*Y**
           . 11+455.*X**3*Y**12+105.*X**2*Y**13+15.*X*Y**14+Y**15
            Z=X**15+15.*X**14*Y+105.*X**13*Y**2+455.*X**12*Y**3+ 
           . 1365.*X**11*Y**4+3003.*X**10*Y**5+5005.*X**9*Y**6+
           . 6435.*X**8*Y**7+6435.*X**7*Y**8+ANS1
    
    

    Twenty total cards means 19 continuation cards. You may set it for more if your Fortran system allows more. Expressions are broken apart in a Fortran-compatible way if they extend for more than card_no continuation cards.

    E

    REDUC
E

    INDEX

    E _ _ _ _ _ _ _ _ _ _ _ _ constant

    The constant e is reserved for use as the base of the natural logarithm. Its value is approximately 2.71828284590, which REDUCE gives to the current decimal precision when the switch rounded is on.

    emay be used as an iterative variable in a for statement, or as a local variable or a procedure. If e is defined as a local variable inside the procedure, the normal definition as the base of the natural logarithm would be suspended inside the procedure.

    EVAL_MODE

    REDUC
E

    INDEX

    EVAL\_MODE _ _ _ _ _ _ _ _ _ _ _ _ variable

    The system variable eval_mode contains the current mode, either algebraic or symbolic.

    examples:

    
    EVAL_MODE; 
    
      ALGEBRAIC
    
    

    Some commands do not behave the same way in algebraic and symbolic modes.

    FORT_WIDTH

    REDUC
E

    INDEX

    FORT\_WIDTH _ _ _ _ _ _ _ _ _ _ _ _ variable

    The fort_width variable sets the number of characters in a line of Fortran-compatible output produced when the fort switch is on. Default is 70.

    examples:

    
    fort_width := 30; 
    
      FORT_WIDTH := 30  
    
    
    on fort; 
    
    df(sin(x**3*y),x); 
    
            ANS=3.*COS(X
           . **3*Y)*X**2*
           . Y
    
    

    fort_widthincludes the usually blank characters at the be ginning of the card. As you may notice above, it is conservative and makes the lines even shorter than it was told.

    HIGH_POW

    REDUC
E

    INDEX

    HIGH\_POW _ _ _ _ _ _ _ _ _ _ _ _ variable

    The variable high_pow is set by coeff to the highest power of the variable of interest in the given expression. You can access this variable for use in further computation or display.

    examples:

    
    coeff((x+1)^5*(x*(y+3)^2)^2,x); 
    
      {0,
       0,
        4       3       2
       Y  + 12*Y  + 54*Y  + 108*Y + 81,
           4       3       2
       5*(Y  + 12*Y  + 54*Y  + 108*Y + 81),
            4       3       2
       10*(Y  + 12*Y  + 54*Y  + 108*Y + 81),
            4       3       2
       10*(Y  + 12*Y  + 54*Y  + 108*Y + 81),
           4       3       2
       5*(Y  + 12*Y  + 54*Y  + 108*Y + 81),
        4       3       2
       Y  + 12*Y  + 54*Y  + 108*Y + 81}
    
    
    high_pow; 
    
      7
    
    

    I

    REDUC
E

    INDEX

    I _ _ _ _ _ _ _ _ _ _ _ _ constant

    REDUCE knows i is the square root of -1, and that i^2 = -1.

    examples:

    
    (a + b*i)*(c + d*i); 
    
      A*C + A*D*I + B*C*I - B*D 
    
    
    i**2; 
    
      -1
    
    

    icannot be used as an identifier. It is all right to use i as an index variable in a for loop, or as a local (scalar) variable inside a begin...end block, but it loses its definition as the square root of -1 inside the block in that case.

    Only the simplest properties of i are known by REDUCE unless the switch complex is turned on, which implements full c omplex arithmetic in factoring, simplification, and functional values. complex is ordinarily off.

    INFINITY

    REDUC
E

    INDEX

    INFINITY _ _ _ _ _ _ _ _ _ _ _ _ constant

    The name infinity is used to represent the infinite positive number. However, at the present time, arithmetic in terms of this operator reflects finite arithmetic, rather than true operations on infinity.

    LOW_POW

    REDUC
E

    INDEX

    LOW\_POW _ _ _ _ _ _ _ _ _ _ _ _ variable

    The variable low_pow is set by coeff to the lowest power of the variable of interest in the given expression. You can access this variable for use in further computation or display.

    examples:

    
    coeff((x+2*y)**6,y); 
    
        6
      {X ,
           5
       12*X ,
           4
       60*X ,
            3
       160*X ,
            2
       240*X ,
       192*X,
       64}
    
    
    low_pow; 
    
      0 
    
    
    coeff(x**2*(x*sin(y) + 1),x); 
    			 
    
    
      {0,0,1,SIN(Y)} 
    
    
    low_pow; 
    
      2
    
    

    NIL

    REDUC
E

    INDEX

    NIL _ _ _ _ _ _ _ _ _ _ _ _ constant

    nilrepresents the truth value false in symbolic mode, and is a synonym for 0 in algebraic mode. It cannot be used for any other purpose, even inside procedures or for loops.

    PI

    REDUC
E

    INDEX

    PI _ _ _ _ _ _ _ _ _ _ _ _ constant

    The identifier pi is reserved for use as the circular constant. Its value is given by 3.14159265358..., which REDUCE gives to the current decimal precision when REDUCE is in a floating-point mode.

    pimay be used as a looping variable in a for statement, or as a local variable in a procedure. Its value in such cases will be taken from the local environment.

    requirements

    REDUC
E

    INDEX

    REQUIREMENTS _ _ _ _ _ _ _ _ _ _ _ _ variable

    After an attempt to solve an inconsistent equation system with parameters, the variable requirements contains a list of expressions. These expressions define a set of conditions implicitly equated with zero. Any solution to this system defines a setting for the parameters sufficient to make the original system consistent.

    examples:

    
    solve({x-a,x-y,y-1},{x,y}); 
    
      {}
    
    
    requirements;
    
      {a - 1}
    
    

    ROOT_MULTIPLICITIES

    REDUC
E

    INDEX

    ROOT\_MULTIPLICITIES _ _ _ _ _ _ _ _ _ _ _ _ variable

    The root_multiplicities variable is set to the list of the multiplicities of the roots of an equation by the solve operator.

    solvereturns its solutions in a list. The mul tiplicities of each solution are put in the corresponding locations of the list root_multiplicities.

    T

    REDUC
E

    INDEX

    T _ _ _ _ _ _ _ _ _ _ _ _ constant

    The constant t stands for the truth value true. It cannot be used as a scalar variable in a block, as a looping variable in a for statement or as an operator name.

    Variables

    REDUC
E

    INDEX

    Variables

  • assumptions variable

  • CARD\_NO variable

  • E constant

  • EVAL\_MODE variable

  • FORT\_WIDTH variable

  • HIGH\_POW variable

  • I constant

  • INFINITY constant

  • LOW\_POW variable

  • NIL constant

  • PI constant

  • requirements variable

  • ROOT\_MULTIPLICITIES variable

  • T constant

  • semicolon

    REDUC
E

    INDEX

    ; _ _ _ SEMICOLON _ _ _ _ _ _ _ _ _ _ _ _ command

    The semicolon is a statement delimiter, indicating results are to be printed when used in interactive mode.

    examples:

    
    (x+1)**2; 
    
       2
      X  + 2*X + 1 
    
    
    df(x**2 + 1,x); 
    
      2*X
    
    

    Entering a Return without a semicolon or dollar sign resu lts in a prompt on the following line. A semicolon or dollar sign can be added at this point to execute the statement. In interactive mode, a statement that is ended with a semicolon and Return has its results printed on the screen.

    Inside a group statement <<...>> or a begin...end block, a semicolon or dollar sign separates individual REDUCE statements. Since results are not printed from a block without a specific return statement, there is no difference between using the semicolon or dollar sign. In a group statement, the last value produced is the value returned by the group statement. Thus, if a semicolon or dollar sign is placed between the last statement and the ending brackets, the group statement returns the value 0 or nil, rather than the value of the last statement.

    dollar

    REDUC
E

    INDEX

    $ _ _ _ DOLLAR _ _ _ _ _ _ _ _ _ _ _ _ command

    The dollar sign is a statement delimiter, indicating results are not to be printed when used in interactive mode.

    examples:

    
    
    (x+1)**2$ 

    The workspace is set to x^2 + 2x + 1 but nothing shows on the screen

    
    
    
    ws; 
    
       2
      X   + 2*X + 1
    
    

    Entering a Return without a semicolon or dollar sign results in a prompt on the following line. A semicolon or dollar sign can be added at this point to execute the statement. In interactive mode, a statement that ends with a dollar sign $ and a Return is executed, but the results not printed.

    Inside a group statement <<...> > or a begin...end block, a semicolon or dollar sign separates individual REDUCE statements. Since results are not printed from a block without a specific return

    statement, there is no difference between using the semicolon or dollar sign.

    In a group statement, the last value produced is the value returned by the group statement. Thus, if a semicolon or dollar sign is placed between the last statement and the ending brackets, the group statement returns the value 0 or nil, rather than the value of the last statement.

    percent

    REDUC
E

    INDEX

    % _ _ _ PERCENT _ _ _ _ _ _ _ _ _ _ _ _ command

    The percent sign is used to precede comments; everything from a percent to the end of the line is ignored.

    examples:

    
    
    df(x**3 + y,x);% This is a comment key{Return} 
    
    
         2
      3*X  
    
    
    int(3*x**2,x) %This is a comment; key{Return} 
    

    A prompt is given, waiting for the semicolon that was not detected in the comment

    Statement delimiters ; and $ are not detected between a percent sign and the end of the line.

    dot

    REDUC
E

    INDEX

    . _ _ _ DOT _ _ _ _ _ _ _ _ _ _ _ _ operator

    The . (dot) infix binary operator adds a new item to the beginning of an existing list. In high energy physics expressions, it can also be used to represent the scalar product of two Lorentz four-vectors.

    syntax:

    <item> . <list>

    <item> can be any REDUCE scalar expression, including a list; <list> must be a list to avoid producing an error message. The dot operator is right associative.

    examples:

    
    
    liss := a . {}; 
    
      LISS := {A} 
    
    
    liss := b . liss; 
    
      LISS := {B,A} 
    
    
    newliss := liss . liss; 
    
      NEWLISS := {{B,A},B,A} 
    
    
    firstlis := a . b . {c}; 
    
      FIRSTLIS := {A,B,C} 
    
    
    secondlis := x . y . {z}; 
    
      SECONDLIS := {X,Y,Z} 
    
    
    for i := 1:3 sum part(firstlis,i)*part(secondlis,i);
     
    
    
      A*X + B*Y + C*Z
    
    

    assign

    REDUC
E

    INDEX

    := _ _ _ ASSIGN _ _ _ _ _ _ _ _ _ _ _ _ operator

    The := is the assignment operator, assigning the value on the right-han d side to the identifier or other valid expression on the left-hand side.

    syntax:

    <restricted\_expression> := <expression>

    <restricted\_expression> is ordinarily a single identifier, though simple expressions may be used (see Comments below). <expression> is any valid REDUCE expression. If <expression> is a matrix identifier, then <restricted\_expression> can be a matrix identifier (redimensioned if necessary) which has each element set to the corresponding elements of the identifier on the right-hand side.

    examples:

    
    a := x**2 + 1; 
    
            2
      A := X   + 1 
    
    
    a; 
    
       2
      X  + 1 
    
    
    first := second := third; 
    
      FIRST := SECOND := THIRD 
    
    
    first; 
    
      THIRD 
    
    
    second; 
    
      THIRD 
    
    
    b := for i := 1:5 product i; 
    
      B := 120 
    
    
    b; 
    
      120 
    
    
    w + (c := x + 3) + z; 
    
      W + X + Z + 3 
    
    
    c; 
    
      X + 3 
    
    
    y + b := c; 
    
      Y + B := C 
    
    
    y; 
    
      - (B - C)
    
    

    The assignment operator is right associative, as shown in the seco nd and third examples. A string of such assignments has all but the last item set to the value of the last item. Embedding an assignment statement in another expression has the side effect of making the assignment, as well as causing the given replacement in the expression.

    Assignments of values to expressions rather than simple identifiers (such as in the last example above) can also be done, subject to the following remarks:

    _ _ _ (i) If the left-hand side is an identifier, an operator, or a power, the substitution rule is added to the rule table.

    _ _ _ (ii) If the operators - + / appear on the left-hand side, all but the first term of the expression is moved to the right-hand side.

    _ _ _ (iii) If the operator * appears on the left-hand side, any constant terms are moved to the right-hand side, but the symbolic factors remain.

    Assignment is valid for array elements, but not for entire arrays. The assignment operator can also be used to attach functionality to operators.

    A recursive construction such as a := a + b is allowed, but when a is referenced again, the process of resubstitution continues until the expression stack overflows (you get an error message). Recursive assignments can be done safely inside controlled loop expressions, such as for... or repeat...until.

    equalsign

    REDUC
E

    INDEX

    = _ _ _ EQUALSIGN _ _ _ _ _ _ _ _ _ _ _ _ operator

    The = operator is a prefix or infix equality comparison operator.

    syntax:

    =(<expression>,<expression>) or <expression> = <expression>

    <expression> can be any REDUCE scalar expression.

    examples:

    
    a := 4; 
    
      A := 4 
    
    
    if =(a,10) then write "yes" else write "no";
     
    
    
      no 
    
    
    b := c; 
    
      B := C 
    
    
    if b = c then write "yes" else write "no";
     
    
    
      yes 
    
    
    on rounded; 
    
    if 4.0 = 4 then write "yes" else write "no";
     
    
    
      yes
    
    

    This logical equality operator can only be used inside a condition al statement, such as if...then...else or repeat...until. In other places the equal sign establishes an algebraic object of type equation.

    replace

    REDUC
E

    INDEX

    => _ _ _ REPLACE _ _ _ _ _ _ _ _ _ _ _ _ operator

    The => operator is a binary operator used in rule lists to denote replacements.

    examples:

    
    operator f; 
    
    let f(x) => x^2; 
    
    f(x); 
    
       2
      x
    
    

    plussign

    REDUC
E

    INDEX

    + _ _ _ PLUSSIGN _ _ _ _ _ _ _ _ _ _ _ _ operator

    The + operator is a prefix or infix n-ary addition operator.

    syntax:

    <expression> { +<expression>}+

    or +(<expression> {,<expression>}+)

    <expression> may be any valid REDUCE expression.

    examples:

    
    x**4 + 4*x**2 + 17*x + 1; 
    
       4      2
      X  + 4*X  + 17*X + 1 
    
    
    14 + 15 + x; 
    
      X + 29 
    
    
    +(1,2,3,4,5); 
    
      15
    
    

    +is also valid as an addition operator for matrix variables that are of the same dimensions and for equations.

    minussign

    REDUC
E

    INDEX

    - _ _ _ MINUSSIGN _ _ _ _ _ _ _ _ _ _ _ _ operator

    The - operator is a prefix or infix binary subtraction operator, as wel l as the unary minus operator.

    syntax:

    <expression> - <expression> or -(<expression>,<expression>)

    <expression> may be any valid REDUCE expression.

    examples:

    
    15 - 4; 
    
      11 
    
    
    x*(-5); 
    
      - 5*X 
    
    
    a - b - 15; 
    
      A - B - 15 
    
    
    -(a,4); 
    
      A - 4
    
    

    The subtraction operator is left associative, so that a - b - c is equivalent to (a - b) - c, as shown in the third example. The subtraction operator is also valid with matrix expressions of the correct dimensions and with equations.

    asterisk

    REDUC
E

    INDEX

    * _ _ _ ASTERISK _ _ _ _ _ _ _ _ _ _ _ _ operator

    The * operator is a prefix or infix n-ary multiplication operator.

    syntax:

    <expression> { * <expression>}+

    or *(<expression> {,<expression>}+)

    <expression> may be any valid REDUCE expression.

    examples:

    
    15*3; 
    
      45 
    
    
    24*x*yvalue*2; 
    
      48*X*YVALUE 
    
    
    *(6,x); 
    
      6*X 
    
    
    on rounded; 
    
    3*1.5*x*x*x; 
    
           3
      4.5*X  
    
    
    off rounded; 
    
    2x**2; 
    
         2
      2*X
    
    

    REDUCE assumes you are using an implicit multiplication operator w hen an identifier is preceded by a number, as shown in the last line above. Since no valid identifiers can begin with numbers, there is no ambiguity in making this assumption.

    The multiplication operator is also valid with matrix expressions of the proper dimensions: matrices A and B can be multiplied if A is n x m and B is m x p. Matrices and equations can also be multiplied by scalars: the result is as if each element was multiplied by the scalar.

    slash

    REDUC
E

    INDEX

    / _ _ _ SLASH _ _ _ _ _ _ _ _ _ _ _ _ operator

    The / operator is a prefix or infix binary division operator or prefix unary reciprocal operator.

    syntax:

    <expression>/<expression> or /<expression>

    or /(<expression>,<expression>)

    <expression> may be any valid REDUCE expression.

    examples:

    
    20/5; 
    
      4  
    
    
    100/6; 
    
      50
      -- 
      3
    
    
    16/2/x; 
    
      8
      - 
      X
    
    
    /b; 
    
      1
      - 
      B
    
    
    /(y,5); 
    
      Y
      - 
      5
    
    
    on rounded; 
    
    35/4; 
    
      8.75 
    
    
    /20; 
    
      0.05
    
    

    The division operator is left associative, so that a/b/c is equivalent to (a/b)/c. The division operator is also valid with square matrix expressions of the same dimensions: Wi th A and B both n x n matrices and B invertible, A/B is given by A*B^-1. Division of a matrix by a scalar is defined, with the results being the division of each element of the matrix by the scalar. Division of a scalar by a matrix is defined if the matrix is invertible, and has the effect of multiplying the scalar by the inverse of the matrix. When / is used as a reciprocal operator for a matrix, the inverse of the matrix is returned if it exists.

    power

    REDUC
E

    INDEX

    ** _ _ _ POWER _ _ _ _ _ _ _ _ _ _ _ _ operator

    The ** operator is a prefix or infix binary exponentiation operator.

    syntax:

    <expression> **<expression> or **(<expression>,<expression>)

    <expression> may be any valid REDUCE expression.

    examples:

    
    x**15; 
    
       15
      X   
    
    
    x**y**z; 
    
       Y*Z
      X    
    
    
    x**(y**z); 
    
        Z
       Y
      X   
    
    
     **(y,4); 
    
       4
      Y  
    
    
    on rounded; 
    
    2**pi; 
    
      8.82497782708
    
    

    The exponentiation operator is left associative, so that a**b* *c is equivalent to (a**b)**c, as shown in the second example. Note that this is not a**(b**c), which would be right associative.

    When nat is on (the default), REDUCE output produc es raised exponents, as shown. The symbol ^, which is the upper-case 6 on most keyboards, may be used in the place of **.

    A square matrix may also be raised to positive and neg ative powers with the exponentiation operator (negative powers require the matrix to be invertible). Scalar expressions and equations may be raised to fractional and floating-point powers.

    caret

    REDUC
E

    INDEX

    ^ _ _ _ CARET _ _ _ _ _ _ _ _ _ _ _ _ operator

    The ^ operator is a prefix or infix binary exponentiation operator. It is equivalent to power or **.

    syntax:

    <expression> ^<expression> or ^(<expression>,<expression>)

    <expression> may be any valid REDUCE expression.

    examples:

    
    x^15; 
    
       15
      X   
    
    
    x^y^z; 
    
       Y*Z
      X    
    
    
    x^(y^z); 
    
        Z
       Y
      X   
    
    
    ^(y,4); 
    
       4
      Y  
    
    
    on rounded; 
    
    2^pi; 
    
      8.82497782708
    
    

    The exponentiation operator is left associative, so that a^b^c is equivalent to (a^b)^c, as shown in the second example. Note that this is <not> a^(b^c), which would be right associative.

    When nat is on (the default), REDUCE output produc es raised exponents, as shown.

    A square matrix may also be raised to positive and negative powers with the exponentiation operator (negative powers require the matrix to be invertible). Scalar expressions and equations may be raised to fractional and floating-point powers.

    geqsign

    REDUC
E

    INDEX

    >= _ _ _ GEQSIGN _ _ _ _ _ _ _ _ _ _ _ _ operator

    >= is an infix binary comparison operator, which returns true if its first argument is greater than or equal to its second argument.

    syntax:

    <expression> >= <expression>

    <expression> must evaluate to an integer or floating-point number.

    examples:

    
    if (3 >= 2) then yes; 
    
      yes 
    
    
    a := 15; 
    
      A := 15 
    
    
    if a >= 20 then big else small;
     
    
      small 
    
    

    The binary comparison operators can only be used for comparisons b etween numbers or variables that evaluate to numbers. The truth values returned by such a comparison can only be used inside programming constructs, such as if...then...else or repeat...until or while...do.

    greater

    REDUC
E

    INDEX

    > _ _ _ GREATER _ _ _ _ _ _ _ _ _ _ _ _ operator

    The > is an infix binary comparison operator that returns true if its first argument is strictly greater than its second.

    syntax:

    <expression> > <expression>

    <expression> must evaluate to a number, e.g., integer, rational or floating point number.

    examples:

    
    on rounded; 
    
    if 3.0 > 3 then write "different" else write "same"; 
    
    
      same 
    
    
    off rounded; 
    
    a := 20; 
    
      A := 20 
    
    
    if a > 20 then write "bigger" else write "not bigger"; 
    
    
      not bigger 
    
    

    The binary comparison operators can only be used for comparisons b etween numbers or variables that evaluate to numbers. The truth values returned by such a comparison can only be used inside programming constructs, such as if...then...else or repeat...until or while...do.

    leqsign

    REDUC
E

    INDEX

    <= _ _ _ LEQSIGN _ _ _ _ _ _ _ _ _ _ _ _ operator

    <= is an infix binary comparison operator that returns true if its first argument is less than or equal to its second argument.

    syntax:

    <expression> <= <expression>

    <expression> must evaluate to a number, e.g., integer, rational or floating point number.

    examples:

    
    a := 10; 
    
      A := 10 
    
    
    if a <= 10 then true; 
    
      true
    
    

    The binary comparison operators can only be used for comparisons b etween numbers or variables that evaluate to numbers. The truth values returned by such a comparison can only be used inside programming constructs, such as if...then...else or repeat...until or while...do.

    less

    REDUC
E

    INDEX

    < _ _ _ LESS _ _ _ _ _ _ _ _ _ _ _ _ operator

    < is an infix binary logical comparison operator that returns true if its first argument is strictly less than its second argument.

    syntax:

    <expression> < <expression>

    <expression> must evaluate to a number, e.g., integer, rational or floating point number.

    examples:

    
    f := -3; 
    
      F := -3 
    
    
    if f < -3 then write "yes" else write "no"; 
    
    
      no
    
    

    The binary comparison operators can only be used for comparisons b etween numbers or variables that evaluate to numbers. The truth values returned by such a comparison can only be used inside programming constructs, such as if...then...else or repeat...until or while...do.

    tilde

    REDUC
E

    INDEX

    ~ _ _ _ TILDE _ _ _ _ _ _ _ _ _ _ _ _ operator

    The ~ is used as a unary prefix operator in the left-hand sides of rules to mark free variables. A double tilde marks an optional free variable.

    group

    REDUC
E

    INDEX

    << _ _ _ GROUP _ _ _ _ _ _ _ _ _ _ _ _ command

    The <<...>> command is a group statement, used to group statements together where REDUCE expects a single statement.

    syntax:

    <<<statement>{; <statement> or <statement>}* >>

    <statement> may be any valid REDUCE statement or expression.

    examples:

    
    a := 2; 
    
      A := 2 
    
    
    if a < 5 then <<b := a + 10; write b>>; 
    
    
      12 
    
    
    <<d := c/15; f := d + 3; f**2>>;
     
    
       2
      C  + 90*C + 202
      ----------------
            225
    
    

    The value returned from a group statement is the value of the last individual statement executed inside it. Note that when a semicolon is placed between the last statement and the closing brackets, 0 or nil is returned. Group statements are often used in the consequence portions of if...then, repeat...until, and while...do clauses. They may also be used in interactive operation to execute several statements at one time. Statements inside the group statement are separated by semicolons or dollar signs.

    AND

    REDUC
E

    INDEX

    AND _ _ _ _ _ _ _ _ _ _ _ _ operator

    The and binary logical operator returns true if both of its arguments are true.

    syntax:

    <logical\_expression> and <logical\_expression>

    <logical\_expression> must evaluate to true or nil.

    examples:

    
    a := 12; 
    
      A := 12 
    
    
    if numberp a and a < 15 then write a**2 else write "no";
     
    
    
      144 
    
    
    clear a; 
    
    if numberp a and a < 15 then write a**2 else write "no";
     
    
    
      no
    
    

    Logical operators can only be used inside conditional statements, such as while...do or if...then...else. and examines each of its arguments in order, and quits, returning nil, on finding an argument that is not true. An error results if it is used in other contexts.

    andis left associative: x and y and z is equivalent to (x and y) and z.

    BEGIN

    REDUC
E

    INDEX

    BEGIN _ _ _ _ _ _ _ _ _ _ _ _ command

    begin is used to start a block statement, which is closed with end.

    syntax:

    begin<statement>{; <statement>}* end

    <statement> is any valid REDUCE statement.

    examples:

    
    begin for i := 1:3 do write i end; 
    
    
      1
      2
      3     
    
    
    begin scalar n;n:=1;b:=for i:=1:4 product(x-i);return n end;
     
    
    
      1 
    
    
    b; 
    
       4        3        2
      X   - 10*X   + 35*X   - 50*X  + 24
    
    

    A begin...end block can do actions (such as write), but does not return a value unless instructed to by a return statement, which must be the last statement executed in the block. It is unnecessary to insert a semicolon before the end.

    Local variables, if any, are declared in the first statement immediately after begin, and may be defined as scalar, integer, or real. array variables declared within a begin...end block are global in every case, and let statements have global effects. A let statement involving a formal parameter af fects the calling parameter that corresponds to it. let statements involving local variables make global assignments, overwriting outside variables by the same name or creating them if they do not exist. You can use this feature to affect global variables from procedures, but be careful that you do not do it inadvertently.

    block

    REDUC
E

    INDEX

    BLOCK _ _ _ _ _ _ _ _ _ _ _ _ command

    A block is a sequence of statements enclosed by commands begin and end.

    syntax:

    begin<statement>{; <statement>}* end

    For more details see begin.

    COMMENT

    REDUC
E

    INDEX

    COMMENT _ _ _ _ _ _ _ _ _ _ _ _ command

    Beginning with the word comment, all text until the next statement terminator (; or $) is ignored.

    examples:

    
    
    x := a**2 comment--a is the velocity of the particle;;
     
    
    
            2
      X := A
    
    

    Note that the first semicolon ends the comment and the second one terminates the original REDUCE statement.

    Multiple-line comments are often needed in interactive files. The comment command allows a normal-looking text to accompany the REDUCE statements in the file.

    CONS

    REDUC
E

    INDEX

    CONS _ _ _ _ _ _ _ _ _ _ _ _ operator

    The cons operator adds a new element to the beginning of a list. Its operation is identical to the symbol dot (dot). It can be used infix or prefix.

    syntax:

    cons(<item>,<list>) or <item> cons <list >

    <item> can be any REDUCE scalar expression, including a list; <list> must be a list.

    examples:

    
    
    liss := cons(a,{b}); 
    
      {A,B} 
    
    
    
    liss := c cons liss; 
    
      {C,A,B} 
    
    
    
    newliss := for each y in liss collect cons(y,list x);
     
    
    
      NEWLISS := {{C,X},{A,X},{B,X}} 
    
    
    
    for each y in newliss sum (first y)*(second y);
     
    
    
      X*(A + B + C)
    
    

    If you want to use cons to put together two elements into a new list, you must make the second one into a list with curly brackets or the list command. You can also start with an empty list created by {}.

    The cons operator is right associative: a cons b cons c is val id if c is a list; b need not be a list. The list produced is {a,b,c}.

    END

    REDUC
E

    INDEX

    END _ _ _ _ _ _ _ _ _ _ _ _ command

    The command end has two main uses:

    _ _ _ (i) as the ending of a begin...end block; and

    _ _ _ (ii) to end input from a file.

    In a begin...end block, there need not be a delimiter (; or $) before the end, though there must be one after it, or a right bracket matching an earlier left bracket.

    Files to be read into REDUCE should end with end;, which must be preceded by a semicolon (usually the last character of the previous line). The additional semicolon avoids problems with mistakes in the files. If you have suspended file operation by answering n to a pause command, you are still, technically speaking, ``in" the file. Use end to exit the file.

    An end at the top level of a program is ignored.

    EQUATION

    REDUC
E

    INDEX

    EQUATION _ _ _ _ _ _ _ _ _ _ _ _ type

    An equation is an expression where two algebraic expressions are connected by the (infix) operator equal or by =. For access to the components of an equation the operators lhs, rhs or part can be used. The evaluation of the left-hand side of an equation is controlled by the switch evallhseqp, while the right-hand side is evaluated unconditionally. When an equation is part of a logical expression, e.g. in a if or while statement, the equation is evaluated by subtracting both sides can comparing the result with zero.

    Equations occur in many contexts, e.g. as arguments of the sub operator and in the arguments and the results of the operator solve. An equation can be member of a list and you may assign an equation to a variable. Elementary arithmetic is supported for equations: if evallhseqp is on, you may add and subtract equations, and you can combine an equation with a scalar expression by addition, subtraction, multiplication, division and raise an equation to a power.

    examples:

    
    on evallhseqp;
    
    u:=x+y=1$
    
    v:=2x-y=0$
    
    2*u-v; 
    
      - 3*y=-2
    
    
    ws/3; 
    
        2
      y=--
        3
    
    

    Important: the equation must occur in the leftmost term of such an expression. For other operations, e.g. taking function values of both sides, use the map operator.

    FIRST

    REDUC
E

    INDEX

    FIRST _ _ _ _ _ _ _ _ _ _ _ _ operator

    The first operator returns the first element of a list.

    syntax:

    first(<list>) or first <list>

    <list> must be a non-empty list to avoid an error message.

    examples:

    
    alist := {a,b,c,d}; 
    
      ALIST := {A,B,C,D} 
    
    
    first alist; 
    
      A 
    
    
    blist := {x,y,{ww,aa,qq},z}; 
    
      BLIST := {X,Y,{WW,AA,QQ},Z} 
    
    
    first third blist; 
    
      WW
    
    

    FOR

    REDUC
E

    INDEX

    FOR _ _ _ _ _ _ _ _ _ _ _ _ command

    The for command is used for iterative loops. There are many possible forms it can take.

    
                       /                   
       /               |STEP <number> UNTIL|        
       |<var>:=<number>|                   |<number>|
    FOR|               |         :         |        |<action> <exprn>
       |                                  /        |
       |EACH <var> IN <list>                        |
                                                   /
    
     where <action> ::= DO|PRODUCT|SUM|COLLECT|JOIN.
    

    <var> can be any valid REDUCE identifier except t o r nil, <inc>, <start> and <stop> can be any expression that evaluates to a positive or negative integer. <list> must be a valid list structure. The action taken must be one of the actions shown above, each of which is followed by a single REDUCE expression, statement or a group (<<...>>) or block ( begin... end) statement.

    examples:

    
    for i := 1:10 sum i;                                    
     
    
    
      55 
    
    
    for a := -2 step 3 until 6 product a;
    							
    
    
      -8 
    
    
    a := 3; 
    
      A := 3 
    
    
    for iter := 4:a do write iter; 
    
    m := 0; 
    
      M := 0 
    
    
    for s := 10 step -1 until 3 do <<d := 10*s;m := m + d>>; 
    
    m; 
    
      520 
    
    
    for each x in {q,r,s} sum x**2; 
    
       2    2    2
      Q  + R  + S  
    
    
    for i := 1:4 collect 1/i;                              
     
    
    
         1 1 1
      {1,-,-,-} 
         2 3 4
    
    
    for i := 1:3 join list solve(x**2 + i*x + 1,x);         
     
    
    
            SQRT(3)*I + 1
      {{X= --------------,
                  2
            SQRT(3)*I - 1
        X= --------------}
                  2
       {X=-1},
             SQRT(5) + 3   SQRT(5) - 3
       {X= - -----------,X=-----------}}
                  2             2
    
    

    The behavior of each of the five action words follows:

    
                               Action Word Behavior
    Keyword   Argument Type                    Action
       do    statement, command, group   Evaluates its argument once
             or block                    for each iteration of the loop,
                                         not saving results
    collect expression, statement,       Evaluates its argument once for
            command, group, block, list  each iteration of the loop,
                                         storing the results in a list
                                         which is returned by the for
                                         statement when done
     join   list or an operator which    Evaluates its argument once for
            produces a list              each iteration of the loop,
                                         appending the elements in each
                                         individual result list onto the
                                         overall result list
    product expression, statement,       Evaluates its argument once for
            command, group or block      each iteration of the loop,
                                         multiplying the results together
                                         and returning the overall product
      sum   expression, statement,       Evaluates its argument once for
            command, group or block      each iteration of the loop,
                                         adding the results together and
                                         returning the overall sum
    

    For number-driven for statements, if the ending limit is smaller than the beginning limit (larger in the case of negative steps) the action statement is not executed at all. The iterative variable is local to the for statement, and does not affect the value of an identifier with the same name. For list-driven for statements, if the list is empty, the action statement is not executed, but no error occurs.

    You can use nested for statements, with the inner for statement after the action keyword. You must make sure that your inner statement returns an expression that the outer statement can handle.

    FOREACH

    REDUC
E

    INDEX

    FOREACH _ _ _ _ _ _ _ _ _ _ _ _ command

    foreachis a synonym for the for each variant of the for construct. It is designed to iterate down a list, and an error will occur if a list is not used. The use of for each is preferred to foreach.

    syntax:

    foreach<variable> in <list> <action> <expression >

    where <action> ::= do | product | sum | collect | join

    examples:

    
    foreach x in {q,r,s} sum x**2; 
    
       2    2    2
      Q  + R  + S
    
    

    GEQ

    REDUC
E

    INDEX

    GEQ _ _ _ _ _ _ _ _ _ _ _ _ operator

    The geq operator is a binary infix or prefix logical operator. It returns true if its first argument is greater than or equal to its second argument. As an infix operator it is identical with >=.

    syntax:

    geq(<expression>,<expression>) or <expression> geq <expression>

    <expression> can be any valid REDUCE expression that evaluates to a number.

    examples:

    
    a := 20; 
    
      A := 20 
    
    
    if geq(a,25) then write "big" else write "small";
    			 
    
    
      small 
    
    
    if a geq 20 then write "big" else write "small";
    			 
    
    
      big  
    
    
    if (a geq 18) then write "big" else write "small";
    			 
    
    
      big
    
    

    Logical operators can only be used in conditional statements such as

    if...then...else or repeat...until.