RAD2DMS

REDUC
E

INDEX

RAD2DMS _ _ _ _ _ _ _ _ _ _ _ _ operator

syntax:

rad2dms(<expression>)

In rounded mode, if <expression> is a real number, the operator rad2dms will interpret it as radians, and convert it to a list containing the equivalent degrees, minutes and seconds. In all other cases, an expression in terms of the original operator is returned.

examples:


rad2dms 1; 

  RAD2DMS(1) 


on rounded; 

ws; 

  {57,17,44.8062470964} 


rad2dms a; 

  RAD2DMS(A)

RECIP

REDUC
E

INDEX

RECIP _ _ _ _ _ _ _ _ _ _ _ _ operator

recip is the alphabetical name for the division operator / or slash used as a unary operator. The use of / is preferred.

examples:


recip a; 

  1
  - 
  A


recip 2; 

  1
  --
  2

REMAINDER

REDUC
E

INDEX

REMAINDER _ _ _ _ _ _ _ _ _ _ _ _ operator

The remainder operator returns the remainder after its first argument is divided by its second argument.

syntax:

remainder(<expression>,<expression>)

<expression> can be any valid REDUCE polynomial, and is not limited to numeric values.

examples:


remainder(13,6); 

  1 


remainder(x**2 + 3*x + 2,x+1); 

  0  


remainder(x**3 + 12*x + 4,x**2 + 1); 


  11*X + 4 


remainder(sin(2*x),x*y); 

  SIN(2*X)

In the default case, remainders are calculated over the integers. If you need the remainder with respect to another domain, it must be declared explicitly.

If the first argument to remainder contains a denominator not equal to 1, an error occurs.

ROUND

REDUC
E

INDEX

ROUND _ _ _ _ _ _ _ _ _ _ _ _ operator

syntax:

round(<expression>)

If its argument has a numerical value, round rounds it to the nearest integer. For non-numeric arguments, the value is an expression in the original operator.

examples:


round 3.4; 

  3 


round 3.5; 

  4 


round a; 

  ROUND(A)

SETMOD

REDUC
E

INDEX

SETMOD _ _ _ _ _ _ _ _ _ _ _ _ command

The setmod command sets the modulus value for subsequent modular arithmetic.

syntax:

setmod<integer>

<integer> must be positive, and greater than 1. It need not be a prime number.

examples:


setmod 6; 

  1 


on modular; 

16; 

  4 


x^2 + 5x + 7; 

   2
  X  + 5*X + 1 


x/3; 

  X
  - 
  3


setmod 2; 

  6 


(x+1)^4; 

   4
  X  + 1 


x/3; 

  X

setmodreturns the previous modulus, or 1 if none has been set before. setmod only has effect when modular is on.

Modular operations are done only on numbers such as coefficients of polynomials, not on the exponents. The modulus need not be prime. Attempts to divide by a power of the modulus produces an error message, since th e operation is equivalent to dividing by 0. However, dividing by a factor of a non-prime modulus does not produce an error message.

SIGN

REDUC
E

INDEX

SIGN _ _ _ _ _ _ _ _ _ _ _ _ operator

syntax:

sign<expression>

signtries to evaluate the sign of its argument. If this is possible sign returns one of 1, 0 or -1. Otherwise, the result is the original form or a simplified variant.

examples:


        sign(-5) 

  -1


        sign(-a^2*b) 

  -SIGN(B)

Even powers of formal expressions are assumed to be positive only as long as the switch complex is off.

SQRT

REDUC
E

INDEX

SQRT _ _ _ _ _ _ _ _ _ _ _ _ operator

The sqrt operator returns the square root of its argument.

syntax:

sqrt(<expression>)

<expression> can be any REDUCE scalar expression.

examples:


sqrt(16*a^3); 

  4*SQRT(A)*A 


sqrt(17); 

  SQRT(17) 


on rounded; 

sqrt(17); 

  4.12310562562 


off rounded; 

sqrt(a*b*c^5*d^3*27); 

                                             2
  3*SQRT(D)*SQRT(C)*SQRT(B)*SQRT(A)*SQRT(3)*C *D

sqrtchecks its argument for squared factors and removes t hem.

Numeric values for square roots that are not exact integers are given only when rounded is on.

Please note that sqrt(a**2) is given as a, which may be incorrect if a eventually has a negative value. If you are programming a calculation in which this is a concern, you can turn on the precise switch, which causes the absolute val ue of the square root to be returned.

TIMES

REDUC
E

INDEX

TIMES _ _ _ _ _ _ _ _ _ _ _ _ operator

The times operator is an infix or prefix n-ary multiplication operator. It is identical to *.

syntax:

<expression> times <expression> {times <express ion>}*

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

<expression> can be any valid REDUCE scalar or matrix expression. Matrix expressions must be of the correct dimensions. Compatible scalar and matrix expressions can be mixed.

examples:


var1 times var2; 

  VAR1*VAR2 


times(6,5); 

  30 


matrix aa,bb; 

aa := mat((1),(2),(x))$ 

bb := mat((0,3,1))$ 

aa times bb times 5; 

  [0   15    5 ]
  [            ]
  [0   30   10 ]
  [            ]
  [0  15*X  5*X]

Arithmetic Operations

REDUC
E

INDEX

Arithmetic Operations

  • ARITHMETIC\_OPERATIONS introduction

  • ABS operator

  • ADJPREC switch

  • ARG operator

  • CEILING operator

  • CHOOSE operator

  • DEG2DMS operator

  • DEG2RAD operator

  • DIFFERENCE operator

  • DILOG operator

  • DMS2DEG operator

  • DMS2RAD operator

  • FACTORIAL operator

  • FIX operator

  • FIXP operator

  • FLOOR operator

  • EXPT operator

  • GCD operator

  • LN operator

  • LOG operator

  • LOGB operator

  • MAX operator

  • MIN operator

  • MINUS operator

  • NEXTPRIME operator

  • NOCONVERT switch

  • NORM operator

  • PERM operator

  • PLUS operator

  • QUOTIENT operator

  • RAD2DEG operator

  • RAD2DMS operator

  • RECIP operator

  • REMAINDER operator

  • ROUND operator

  • SETMOD command

  • SIGN operator

  • SQRT operator

  • TIMES operator

  • boolean_value

    REDUC
E

    INDEX

    BOOLEAN VALUE

    There are no extra symbols for the truth values true and false. Instead, nil and the number zero are interpreted as truth value false in algebraic programs (see false), while any different value is considered as true (see true).

    EQUAL

    REDUC
E

    INDEX

    EQUAL _ _ _ _ _ _ _ _ _ _ _ _ operator

    The operator equal is an infix binary comparison operator. It is identical with =. It returns true if its two arguments are equal.

    syntax:

    <expression> equal <expression>

    Equality is given between floating point numbers and integers that have the same value.

    examples:

    
    on rounded; 
    
    a := 4; 
    
      A := 4 
    
    
    b := 4.0; 
    
      B := 4.0 
    
    
    if a equal b then write "true" else write "false";
    			 
    
    
      true 
    
    
    if a equal 5 then write "true" else write "false";
    			 
    
    
      false 
    
    
    if a equal sqrt(16) then write "true" else write "false";
    			 
    
    
      true
    
    

    Comparison operators can only be used as conditions in conditional commands such as if...then and repeat...until. <equal> can also be used as a prefix operator. However, this use is not encouraged.

    EVENP

    REDUC
E

    INDEX

    EVENP _ _ _ _ _ _ _ _ _ _ _ _ operator

    The evenp logical operator returns true if its argument is an even integer, and nil if its argument is an odd integer. An err or message is returned if its argument is not an integer.

    syntax:

    evenp(<integer>) or evenp <integer>

    <integer> must evaluate to an integer.

    examples:

    
    aa := 1782; 
    
      AA := 1782 
    
    
    if evenp aa then yes else no; 
    
      YES 
    
    
    if evenp(-3) then yes else no; 
    
      NO 
    
    

    Although you would not ordinarily enter an expression such as the last example above, note that the negative term must be enclosed in parentheses to be correctly parsed. The evenp operator can only be used in conditional statements such as if...then...else or while...do.

    false

    REDUC
E

    INDEX

    FALSE

    The symbol nil and the number zero are considered as boolean value false if used in a place where a boolean value is required. Most builtin operators return nil as false value. Algebraic programs use be tter zero. Note that nil is not printed when returned as result to a top level evaluation.

    FREEOF

    REDUC
E

    INDEX

    FREEOF _ _ _ _ _ _ _ _ _ _ _ _ operator

    The freeof logical operator returns true if its first argument does not contain its second argument anywhere in its structure.

    syntax:

    freeof(<expression>,<kernel>) or <expression> freeof <kernel>

    <expression> can be any valid scalar REDUCE expression, <kernel> mus t be a kernel expression (see kernel).

    examples:

    
    a := x + sin(y)**2 + log sin z;
    			 
    
    
                               2
      A := LOG(SIN(Z)) + SIN(Y)   + X 
    
    
    if freeof(a,sin(y)) then write "free" else write "not free";
    			 
    
    
      not free 
    
    
    if freeof(a,sin(x)) then write "free" else write "not free";
    			 
    
    
      free 
    
    
    if a freeof sin z then write "free" else write "not free";
    			 
    
    
      not free
    
    

    Logical operators can only be used in conditional expressions such as

    if...then or while...do.

    LEQ

    REDUC
E

    INDEX

    LEQ _ _ _ _ _ _ _ _ _ _ _ _ operator

    The leq operator is a binary infix or prefix logical operator. It returns true if its first argument is less than or eq ual to its second argument. As an infix operator it is identical with <=.

    syntax:

    leq(<expression>,<expression>) or <expression> leq <expression>

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

    examples:

    
    a := 15; 
    
      A := 15 
    
    
    if leq(a,25) then write "yes" else write "no";
    			 
    
    
      yes 
    
    
    if leq(a,15) then write "yes" else write "no";
    			 
    
    
      yes 
    
    
    if leq(a,5) then write "yes" else write "no";
    			 
    
    
      no
    
    

    Logical operators can only be used in conditional statements such as

    if...then...else or while...do.

    LESSP

    REDUC
E

    INDEX

    LESSP _ _ _ _ _ _ _ _ _ _ _ _ operator

    The lessp operator is a binary infix or prefix logical operator. It returns true if its first argument is strictly less t han its second argument. As an infix operator it is identical with <.

    syntax:

    lessp(<expression>,<expression>) or <expression> lessp <expression>

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

    examples:

    
    a := 15; 
    
      A := 15 
    
    
    if lessp(a,25) then write "yes" else write "no";
    			 
    
    
      yes 
    
    
    if lessp(a,15) then write "yes" else write "no";
    			 
    
    
      no 
    
    
    if lessp(a,5) then write "yes" else write "no";
    			 
    
    
      no
    
    

    Logical operators can only be used in conditional statements such as

    if...then...else or while...do.

    MEMBER

    REDUC
E

    INDEX

    MEMBER _ _ _ _ _ _ _ _ _ _ _ _ operator

    syntax:

    <expression> member <list>

    memberis an infix binary comparison operator that evaluates to true if <expression> is equal to a member of the list <list>.

    examples:

    
    if a member {a,b} then 1 else 0; 
    
      1 
    
    
    if 1 member(1,2,3) then a else b; 
    
      a 
    
    
    if 1 member(1.0,2) then a else b; 
    
      b
    
    

    Logical operators can only be used in conditional statements such as

    if...then...else or while...do. <member> can also be used as a prefix operator. However, this use is not encouraged. Finally, equal (=) is used for the test within the list, so expressions must be of the same type to match.

    NEQ

    REDUC
E

    INDEX

    NEQ _ _ _ _ _ _ _ _ _ _ _ _ operator

    The operator neq is an infix binary comparison operator. It returns true if its two arguments are not equal.

    syntax:

    <expression> neq <expression>

    An inequality is satisfied between floating point numbers and integers that have the same value.

    examples:

    
    on rounded; 
    
    a := 4; 
    
      A := 4 
    
    
    b := 4.0; 
    
      B := 4.0 
    
    
    if a neq b then write "true" else write "false";
    			 
    
    
      false 
    
    
    if a neq 5 then write "true" else write "false";
    			 
    
    
      true
    
    

    Comparison operators can only be used as conditions in conditional commands such as if...then and repeat...until. <neq> can also be used as a prefix operator. However, this use is not encouraged.

    NOT

    REDUC
E

    INDEX

    NOT _ _ _ _ _ _ _ _ _ _ _ _ operator

    The not operator returns true if its argument evaluates to nil, and nil if its argument is true.

    syntax:

    not(<logical expression>)

    examples:

    
    if not numberp(a) then write "indeterminate" else write a;
    			 
    
    
      indeterminate; 
    
    
    a := 10; 
    
      A := 10 
    
    
    if not numberp(a) then write "indeterminate" else write a;
    			 
    
    
      10 
    
    
    if not(numberp(a) and a < 0) then write "positive number";
    			 
    
    
      positive number
    
    

    Logical operators can only be used in conditional statements such as

    if...then...else or while...do.

    NUMBERP

    REDUC
E

    INDEX

    NUMBERP _ _ _ _ _ _ _ _ _ _ _ _ operator

    The numberp operator returns true if its argument is a number, and nil otherwise.

    syntax:

    numberp(<expression>) or numberp <expression>

    <expression> can be any REDUCE scalar expression.

    examples:

    
    cc := 15.3; 
    
      CC := 15.3 
    
    
    if numberp(cc) then write "number" else write "nonnumber"; 
    
    
      number 
    
    
    if numberp(cb) then write "number" else write "nonnumber"; 
    
    
      nonnumber
    
    

    Logical operators can only be used in conditional expressions, suc h as

    if...then...else and while...do.

    ORDP

    REDUC
E

    INDEX

    ORDP _ _ _ _ _ _ _ _ _ _ _ _ operator

    The ordp logical operator returns true if its first argument is ordered ahead of its second argument in canonical internal ordering, or is identical to it.

    syntax:

    ordp(<expression1>,<expression2>)

    <expression1> and <expression2> can be any valid REDUCE scalar expression.

    examples:

    
    if ordp(x**2 + 1,x**3 + 3) then write "yes" else write "no";
    			 
    
    
      no 
    
    
    if ordp(101,100) then write "yes" else write "no";
    			 
    
    
      yes 
    
    
    if ordp(x,x) then write "yes" else write "no";
    			 
    
    
      yes
    
    

    Logical operators can only be used in conditional expressions, suc h as

    if...then...else and while...do.

    PRIMEP

    REDUC
E

    INDEX

    PRIMEP _ _ _ _ _ _ _ _ _ _ _ _ operator

    syntax:

    primep(<expression>) or primep <simple\_expression >

    If <expression> evaluates to a integer, primep returns true

    if <expression> is a prime number (i.e., a number other than 0 and plus or minus 1 which is only exactly divisible by itself or a unit) and nil otherwise. If <expression> does not have an integer value, a type error occurs.

    examples:

    
    if primep 3 then write "yes" else write "no"; 
    
    
      YES 
    
    
    if primep a then 1; 
    
      ***** A invalid as integer
    
    

    TRUE

    REDUC
E

    INDEX

    TRUE

    Any value of the boolean part of a logical expression which is neither nil nor 0 is considered as true . Most builtin test and compare functions return t for true and nil for false.

    examples:

    
    if member(3,{1,2,3}) then 1 else -1;
    
    
      1
    
    
    if floor(1.7) then 1 else -1; 
    
      1 
    
    
    if floor(0.7) then 1 else -1; 
    
      -1
    
    

    Boolean Operators

    REDUC
E

    INDEX

    Boolean Operators

  • boolean value concept

  • EQUAL operator

  • EVENP operator

  • false concept

  • FREEOF operator

  • LEQ operator

  • LESSP operator

  • MEMBER operator

  • NEQ operator

  • NOT operator

  • NUMBERP operator

  • ORDP operator

  • PRIMEP operator

  • TRUE concept

  • BYE

    REDUC
E

    INDEX

    BYE _ _ _ _ _ _ _ _ _ _ _ _ command

    The bye command ends the REDUCE session, returning control to the program (e.g., the operating system) that called REDUCE. When you are at the top level, the bye command exits REDUCE. quit is a synonym for bye.

    CONT

    REDUC
E

    INDEX

    CONT _ _ _ _ _ _ _ _ _ _ _ _ command

    The command cont returns control to an interactive file after a pause command that has been answered with n.

    examples:

    Suppose you are in the middle of an interactive file.

     
    
     
    
      factorize(x**2 + 17*x + 60); 
    
    
     
    
      {{X + 12,1},{X + 5,1}} 
    
    
       pause; 
    
      Cont? (Y or N) 
    
    
    n 
    
    saveas results; 
    
    factor1 := first results; 
    
      FACTOR1 := {X + 12,1} 
    
    
    factor2 := second results; 
    
      FACTOR2 := {X + 5,1} 
    
    
    cont; 

    the file resumes

    
    
    

    A pause allows you to enter your own REDUCE com mands, change switch values, inquire about results, or other such activities. When you wish to resume operation of the interactive file, use cont.

    DISPLAY

    REDUC
E

    INDEX

    DISPLAY _ _ _ _ _ _ _ _ _ _ _ _ command

    When given a numeric argument <n>, display prints the <n> most recent input statements, identified by prompt numbers. If an empty pair of parentheses is given, or if <n> is greater than the current number of statements, all the input statements since the beginning of the session are printed.

    syntax:

    display(<n>) or display()

    <n> should be a positive integer. However, if it is a real number, the truncated integer value is used, and if a non-numeric argument is used, all the input statements are printed.

    The statements are displayed in upper case, with lines split at semicolons or dollar signs, as they are in editing. If long files have been input during the session, the display command is slow to format these for printing.

    LOAD_PACKAGE

    REDUC
E

    INDEX

    LOAD\_PACKAGE _ _ _ _ _ _ _ _ _ _ _ _ command

    The load_package command is used to load REDUCE packages, such as gentran that are not automatically loaded by the system.

    syntax:

    load_package "<package\_name>"

    A package is only loaded once; subsequent calls of load_package for the same package name are ignored.

    PAUSE

    REDUC
E

    INDEX

    PAUSE _ _ _ _ _ _ _ _ _ _ _ _ command

    The pause command, given in an interactive file, stops operation and asks if you want to continue or not.

    examples:

    An interactive file is running, and at some point you see the question

     
    
    				   Cont? (Y or N) 
    

    If you type

     
    
    ykey{Return}
    

    the file continues to run until the next pause or the end.

     
    

    If you type

     
    
    nkey{Return} 
    

    you will get a numbered REDUCE prompt, and be allowed to enter and execute any REDUCE statements. If you later wish to continue with the file, type

     
    
    cont; 
    

    and the file resumes.

    To use pause in your own interactive files, type

    pause;in the file wherever you want it.

    pausedoes not allow you to continue without typing either y or n. Its use is to slow down scrolling of interactive files, or to let you change parameters or switch settings for the calculations.

    If you have stopped an interactive file at a pause, and do not wish to resume the file, type end;. This does not end the REDUCE session, but stops input from the file. A second end; ends the REDUCE session. However, if you have pauses from more than one file stacked up, an end; brings you back to the top level, not the file directly above.

    A pause typed from the terminal has no effect.

    QUIT

    REDUC
E

    INDEX

    QUIT _ _ _ _ _ _ _ _ _ _ _ _ command

    The quit command ends the REDUCE session, returning control to the program (e.g., the operating system) that called REDUCE. When you are at the top level, the quit command exits REDUCE. bye is a synonym for quit.

    RECLAIM

    REDUC
E

    INDEX

    RECLAIM _ _ _ _ _ _ _ _ _ _ _ _ operator

    REDUCE's memory is in a storage structure called a heap. As REDUCE statements execute, chunks of memory are used up. When these chunks are no longer needed, they remain idle. When the memory is almost full, the system executes a garbage collection, reclaiming space that is no longer needed, and putting all the free space at one end. Depending on the size of the image REDUCE is using, garbage collection needs to be done more or less often. A larger image means fewer but longer garbage collections. Regardless of memory size, if you ask REDUCE to do something ridiculous, like factorial(2000), it may garbage collect many times.

    REDERR

    REDUC
E

    INDEX

    REDERR _ _ _ _ _ _ _ _ _ _ _ _ command

    The rederr command allows you to print an error message from inside a procedure or a block statement. The calculation is gracefully terminated.

    syntax:

    rederr<message>

    <message> is an error message, usually inside double quotation marks (a string).

    examples:

    
    procedure fac(n);
       if not (fixp(n) and n>=0)
         then  rederr "Choose nonneg. integer only"
        else for i := 0:n-1 product i+1;
     
    
      fac 
    
    
    fac a; 
    
      	   ***** Choose nonneg. integer only 
    
    
    fac 5; 
    
      120
    
    

    The above procedure finds the factorial of its argument. If n is not a positive integer or 0, an error message is returned.

    If your procedure is executed in a file, the usual error message is printed, followed by Cont? (Y or N), just as any other error does from a file. Although the procedure is gracefully terminated, any switch settings or variable assignments you made before the error occurred are not undone. If you need to clean up such items before exiting, use a group statement, with the rederr command as its last statement.

    RETRY

    REDUC
E

    INDEX

    RETRY _ _ _ _ _ _ _ _ _ _ _ _ command

    The retry command allows you to retry the latest statement that resulte d in an error message.

    examples:

    
    matrix a; 
    
    det a; 
    
      ***** Matrix A not set 
    
    
    a := mat((1,2),(3,4)); 
    
      A(1,1) := 1
      A(1,2) := 2
      A(2,1) := 3
      A(2,2) := 4
    
    
    retry; 
    
      -2
    
    

    retryremembers only the most recent statement that result ed in an error message. It allows you to stop and fix something obvious, then continue on your way without retyping the original command.

    SAVEAS

    REDUC
E

    INDEX

    SAVEAS _ _ _ _ _ _ _ _ _ _ _ _ command

    The saveas command saves the current workspace under the name of its argument.

    syntax:

    saveas<identifier>

    <identifier> can be any valid REDUCE identifier.

    examples:

    (The numbered prompts are shown below, unlike in most examples)

    
    
    1: solve(x^2-3);
    
      {x=sqrt(3),x= - sqrt(3)}
    
    
    2: saveas rts(0)$
    
    3: rts(0);
    
      {x=sqrt(3),x= - sqrt(3)}
    
    

    saveasworks only for the current workspace, the last algebraic expression produced by REDUCE. This allows you to save a result that you did not assign to an identifier when you originally typed the input. For access to previous output use ws.

    SHOWTIME

    REDUC
E

    INDEX

    SHOWTIME _ _ _ _ _ _ _ _ _ _ _ _ command

    The showtime command prints the elapsed system time since the last call of this command or since the beginning of the session, if it has not been called before.

    examples:

    
    showtime; 
    
      Time: 1020 ms 
    
    
    factorize(x^4 - 8x^4 + 8x^2 - 136x - 153);
    			 
    
    
              2
      {X - 9,X  + 17,X + 1} 
    
    
    showtime; 
    
      Time: 920 ms
    
    

    The time printed is either the elapsed cpu time or the elapsed wal l clock time, depending on your system. showtime allows you to see the system time resources REDUCE uses in its calculations. Your time readings will of course vary from this example according to the system you use.

    WRITE

    REDUC
E

    INDEX

    WRITE _ _ _ _ _ _ _ _ _ _ _ _ command

    The write command explicitly writes its arguments to the output device (terminal or file).

    syntax:

    write<item>{,<item>}*

    <item> can be an expression, an assignment or a string enclosed in double quotation marks (").

    examples:

    
    write a, sin x, "this is a string"; 
    
    
      ASIN(X)this is a string 
    
    
    write a," ",sin x," this is a string"; 
    
    
      A SIN(X) this is a string 
    
    
    if not numberp(a) then write "the symbol ",a;
    							
    
    
      the symbol A 
    
    
    array m(10); 
    
    for i := 1:5 do write m(i) := 2*i; 
    
    
      M(1) := 2
      M(2) := 4
      M(3) := 6
      M(4) := 8
      M(5) := 10
    
    
    m(4); 
    
      8
    
    

    The items specified by a single write statement print on a single line unless they are too long. A printed line is always ended with a carriage return, so the next item printed starts a new line.

    When an assignment statement is printed, the assignment is also made. This allows you to get feedback on filling slots in an array with a for statement, as shown in the last example above.

    General Commands

    REDUC
E

    INDEX

    General Commands

  • BYE command

  • CONT command

  • DISPLAY command

  • LOAD\_PACKAGE command

  • PAUSE command

  • QUIT command

  • RECLAIM operator

  • REDERR command

  • RETRY command

  • SAVEAS command

  • SHOWTIME command

  • WRITE command

  • APPEND

    REDUC
E

    INDEX

    APPEND _ _ _ _ _ _ _ _ _ _ _ _ operator

    The append operator constructs a new list from the elements of its two arguments (which must be lists).

    syntax:

    append(<list>,<list>)

    <list> must be a list, though it may be the empty list ({}). Any arguments beyond the first two are ignored.

    examples:

    
    alist := {1,2,{a,b}}; 
    
      ALIST := {1,2,{A,B}} 
    
    
    blist := {3,4,5,sin(y)}; 
    
      BLIST := {3,4,5,SIN(Y)} 
    
    
    append(alist,blist); 
    
      {1,2,{A,B},3,4,5,SIN(Y)} 
    
    
    append(alist,{}); 
    
      {1,2,{A,B}} 
    
    
    append(list z,blist); 
    
      {Z,3,4,5,SIN(Y)}
    
    

    The new list consists of the elements of the second list appended to the elements of the first list. You can append new elements to the beginning or end of an existing list by putting the new element in a list (use curly braces or the operator list). This is particularly helpful in an iterative loop.

    ARBINT

    REDUC
E

    INDEX

    ARBINT _ _ _ _ _ _ _ _ _ _ _ _ operator

    The operator arbint is used to express arbitrary integer parts of an expression, e.g. in the result of solve when allbranch is on.

    examples:

    
    
    solve(log(sin(x+3)),x); 
    
      {X=2*ARBINT(1)*PI - ASIN(1) - 3,
       X=2*ARBINT(1)*PI + ASIN(1) + PI - 3}
    
    

    ARBCOMPLEX

    REDUC
E

    INDEX

    ARBCOMPLEX _ _ _ _ _ _ _ _ _ _ _ _ operator

    The operator arbcomplex is used to express arbitrary scalar parts of an expression, e.g. in the result of solve when the solution is parametric in one of the variable.

    examples:

    
    
    solve({x+3=y-2z,y-3x=0},{x,y,z}); 
    
    
         2*ARBCOMPLEX(1) + 3
      {X=-------------------,
                  2
          3*ARBCOMPLEX(1) + 3
        Y=-------------------,
                   2
        Z=ARBCOMPLEX(1)}
    
    

    ARGLENGTH

    REDUC
E

    INDEX

    ARGLENGTH _ _ _ _ _ _ _ _ _ _ _ _ operator

    The operator arglength returns the number of arguments of the top-level operator in its argument.

    syntax:

    arglength(<expression>)

    <expression> can be any valid REDUCE algebraic expression.

    examples:

    
    arglength(a + b + c + d); 
    
      4 
    
    
    arglength(a/b/c); 
    
      2 
    
    
    arglength(log(sin(df(r**3*x,x)))); 
    
    
      1
    
    

    In the first example, + is an n-ary operator, so the numb er of terms is returned. In the second example, since / is a binary operator, the argument is actually (a/b)/c, so there are two terms at the top level. In the last example, no matter how deeply the operators are nested, there is still only one argument at the top level.

    COEFF

    REDUC
E

    INDEX

    COEFF _ _ _ _ _ _ _ _ _ _ _ _ operator

    The coeff operator returns the coefficients of the powers of the specified variable in the given expression, in a list.

    syntax:

    coeff(<expression>,<variable>)

    <expression> is expected to be a polynomial expression, not a rational expression. Rational expressions are accepted when the switch ratarg is on. <variable> must be a kern el. The results are returned in a list.

    examples:

    
    coeff((x+y)**3,x); 
    
        3     2
      {Y  ,3*Y  ,3*Y,1} 
    
    
    coeff((x+2)**4 + sin(x),x); 
    
      {SIN(X) + 16,32,24,8,1} 
    
    
    high_pow; 
    
      4 
    
    
    low_pow; 
    
      0 
    
    
    ab := x**9 + sin(x)*x**7 + sqrt(y); 
     
    
    
                              7     9
      AB := SQRT(Y) + SIN(X)*X   + X
    
    
    coeff(ab,x); 
    
      {SQRT(Y),0,0,0,0,0,0,SIN(X),0,1}
    
    

    The variables high_pow and low_pow are set to the highest and lowest powers of the variable, respectively, appearing in the expression.

    The coefficients are put into a list, with the coefficient of the lowest (constant) term first. You can use the usual list access methods (first, second, third, rest, length , and part) to extract them. If a power does not appear in the expression, the corresponding element of the list is zero. Terms involving functions of the specified variable but not including powers of it (for example in the expression x**4 + 3*x**2 + tan(x)) are placed in the constant term.

    Since the coeff command deals with the expanded form of the expression, you may get unexpected results when exp is off, or when factor or ifactor are on.

    If you want only a specific coefficient rather than all of them, use the coeffn operator.

    COEFFN

    REDUC
E

    INDEX

    COEFFN _ _ _ _ _ _ _ _ _ _ _ _ operator

    The coeffn operator takes three arguments: an expression, a kernel, and a non-negative integer. It returns the coefficient of the kernel to that integer power, appearing in the expression.

    syntax:

    coeffn(<expression>,<kernel>,<integer>)

    <expression> must be a polynomial, unless ratarg is on which allows rational expressions. <kernel> must be a kernel, and <integer> must be a non-negative integer.

    examples:

    
    
    ff := x**7 + sin(y)*x**5 + y**4 + x + 7; 
    
    
                    5     7         4
      FF := SIN(Y)*X   + X   + X + Y   + 7 
    
    
    coeffn(ff,x,5); 
    
      SIN(Y) 
    
    
    coeffn(ff,z,3); 
    
      0 
    
    
    coeffn(ff,y,0); 
    
              5     7
      SIN(Y)*X   + X   + X + 7 
    
    
    
    rr := 1/y**2+y**3+sin(y); 
    
                    2     5
            SIN(Y)*Y   + Y   + 1
      RR := -------------------- 
                      2
                     Y
    
    
    on ratarg; 
    
    
    coeffn(rr,y,-2); 
    
      ***** -2 invalid as COEFFN index 
    
    
    
    coeffn(rr,y,5); 
    
      1
      ---
       2
      Y
    
    

    If the given power of the kernel does not appear in the expression , coeffn returns 0. Negative powers are never detected, even if they appear in the expression and ratarg are on. coeffn with an integer argument of 0 returns any terms in the expression that do not contain the given kernel.

    CONJ

    REDUC
E

    INDEX

    CONJ _ _ _ _ _ _ _ _ _ _ _ _ operator

    syntax:

    conj(<expression>) or conj <simple\_expression>

    This operator returns the complex conjugate of an expression, if that argument has an numerical value. A non-numerical argument is returned as an expression in the operators repart and impart.

    examples:

    
    conj(1+i); 
    
      1-I 
    
    
    conj(a+i*b); 
    
      REPART(A) - REPART(B)*I - IMPART(A)*I - IMPART(B)
    
    

    CONTINUED_FRACTION

    REDUC
E

    INDEX

    CONTINUED_FRACTION _ _ _ _ _ _ _ _ _ _ _ _ operator

    syntax:

    continued_fraction(<num>) or continued_fraction( <num>,<size>)

    This operator approximates the real number <num> ( rational number, rounded number) into a continued fraction. The result is a list of two elements: the first one is the rational value of the approximation, the second one is the list of terms of the continued fraction which represents the same value according to the definition t0 +1/(t1 + 1/(t2 + ...)). Precision: the second optional parameter <size> is an upper bound for the absolute value of the result denominator. If omitted, the approximation is performed up to the current system precision.

    examples:

    
    continued_fraction pi;
     
    
       1146408
      {-------,{3,7,15,1,292,1,1,1,2,1}} 
       364913
    
    
    continued_fraction(pi,100);
     
    
       22
      {--,{3,7}} 
       7
    
    

    DECOMPOSE

    REDUC
E

    INDEX

    DECOMPOSE _ _ _ _ _ _ _ _ _ _ _ _ operator

    The decompose operator takes a multivariate polynomial as argument, and returns an expression and a list of equations from which the original polynomial can be found by composition.

    syntax:

    decompose(<expression>) or decompose <simple\_expression>

    examples:

    
    decompose(x^8-88*x^7+2924*x^6-43912*x^5+263431*x^4-
              218900*x^3+65690*x^2-7700*x+234)
    
     
    
       2                  2            2
      U  + 35*U + 234, U=V  + 10*V, V=X  - 22*X 
    
    
         decompose(u^2+v^2+2u*v+1) 
    
       2
      W   + 1, W=U + V
    
    

    Unlike factorization, this decomposition is not unique. Further details can be found in V.S. Alagar, M.Tanh, <Fast Polynomial Decomposition>, Proc. EUROCAL 1985, pp 150-153 (Springer) and J. von zur Gathen, <Functional> <Decomposition of Polynomials: the Tame Case>, J. Symbolic Computation (1990) 9, 281-299.

    DEG

    REDUC
E

    INDEX

    DEG _ _ _ _ _ _ _ _ _ _ _ _ operator

    The operator deg returns the highest degree of its variable argument found in its expression argument.

    syntax:

    deg(<expression>,<kernel>)

    <expression> is expected to be a polynomial expression, not a rational expression. Rational expressions are accepted when the switch ratarg is on. <variable> must be a kernel. The results are returned in a list.

    examples:

    
    
    deg((x+y)**5,x); 
    
      5 
    
    
    
    deg((a+b)*(c+2*d)**2,d); 
    
      2 
    
    
    
    deg(x**2 + cos(y),sin(x)); 
    
    
    deg((x**2 + sin(x))**5,sin(x)); 
    
      5
    
    

    DEN

    REDUC
E

    INDEX

    DEN _ _ _ _ _ _ _ _ _ _ _ _ operator

    The den operator returns the denominator of its argument.

    syntax:

    den(<expression>)

    <expression> is ordinarily a rational expression, but may be any valid scalar REDUCE expression.

    examples:

    
    
    a := x**3 + 3*x**2 + 12*x; 
    
               2
      A := X*(X   + 3*X + 12) 
    
    
    
    b := 4*x*y + x*sin(x); 
    
      B := X*(SIN(X) + 4*Y) 
    
    
    
    den(a/b); 
    
      SIN(X) + 4*Y 
    
    
    
    den(aa/4 + bb/5); 
    
      20 
    
    
    
    den(100/6); 
    
      3 
    
    
    
    den(sin(x)); 
    
      1
    
    

    denreturns the denominator of the expression after it has been simplified by REDUCE. As seen in the examples, this includes putting sums of rational expressions over a common denominator, and reducing common factors where possible. If the expression does not have any other denominator, 1 is returned.

    Switch settings, such as mcd or rational, have an effect on the denominator of an expression.

    DF

    REDUC
E

    INDEX

    DF _ _ _ _ _ _ _ _ _ _ _ _ operator

    The df operator finds partial derivatives with respect to one or more variables.

    syntax:

    df(<expression>,<var> [,<number>] {,<var> [ ,<number>] } )

    <expression> can be any valid REDUCE algebraic expression. <var> must be a kernel, and is the differentiation variable. <number> must be a non-negative integer.

    examples:

    
    
    df(x**2,x); 
    
      2*X 
    
    
    
    df(x**2*y + sin(y),y); 
    
                2
      COS(Y) + X  
    
    
    
    df((x+y)**10,z); 
    
      0 
    
    
    
    
    df(1/x**2,x,2); 
    
      6
      ---
       4
      X
    
    
    
    df(x**4*y + sin(y),y,x,3); 
    
      24*X 
    
    
    
    for all x let df(tan(x),x) = sec(x)**2; 
    
    
    df(tan(3*x),x); 
    
                2
      3*SEC(3*X)
    
    

    An error message results if a non-kernel is entered as a different iation operator. If the optional number is omitted, it is assumed to be 1. See the declaration depend to establish dependencies for implicit differentiation.

    You can define your own differentiation rules, expanding REDUCE's capabilities, using the let command as shown in the last example above. Note that once you add your own rule for differentiating a function, it supersedes REDUCE's normal handling of that function for the duration of the REDUCE session. If you clear the rule ( clearrules), you don't get back to the previous rule.

    EXPAND_CASES

    REDUC
E

    INDEX

    EXPAND\_CASES _ _ _ _ _ _ _ _ _ _ _ _ operator

    When a root_of form in a result of solve has been converted to a one_of form, expand_cases can be used to convert this into form corresponding to the normal explicit results of solve. See root_of.