Introduction to Expressions
===========================

There are a number of reserved words which cannot be used as variable names.   Their use would cause a possibly cryptic syntax error.

     integrate            next           from                 diff
     in                   at             limit                sum
     for                  and            elseif               then
     else                 do             or                   if
     unless               product        while                thru
     step

Most things in Maxima are expressions.   A sequence of expressions
can be made into an expression by separating them by commas and
putting parentheses around them.   This is similar to the C
comma expression.

     (%i1) x: 3$
     (%i2) (x: x+1, x: x^2);
     (%o2)                          16
     (%i3) (if (x > 17) then 2 else 4);
     (%o3)                           4
     (%i4) (if (x > 17) then x: 2 else y: 4, y+x);
     (%o4)                          20

Even loops in Maxima are expressions, although the value they return is the not too useful done.

     (%i1) y: (x: 1, for i from 1 thru 10 do (x: x*i))$
     (%i2) y;
     (%o2)                         done

whereas what you really want is probably to include a third term in the comma expression which actually gives back the value.

     (%i3) y: (x: 1, for i from 1 thru 10 do (x: x*i), x)$
     (%i4) y;
     (%o4)                        3628800

Assignment
==========

There are two assignment operators in Maxima, : and ::. E.g., a: 3 sets the variable a to 3. :: assigns the value of the expression on its right to the value of the quantity on its left, which must evaluate to an atomic variable or subscripted variable.

Complex
=======

A complex expression is specified in Maxima by adding the real part of the expression to %i times the imaginary part.  Thus the roots of the equation x^2 - 4*x + 13 = 0 are 2 + 3*%i and 2 - 3*%i.  Note that simplification of products of complex expressions can be effected by expanding the product.  Simplification of quotients, roots, and other functions of complex expressions can usually be accomplished by using the realpart, imagpart, rectform, polarform, abs, carg functions.

Nouns and Verbs
===============

Maxima distinguishes between operators which are "nouns" and operators which are "verbs". A verb is an operator which can be executed. A noun is an operator which appears as a symbol in an expression, without being executed. By default, function names are verbs. A verb can be changed into a noun by quoting the function name or applying the nounify function. A noun can be changed into a verb by applying the verbify function. The evaluation flag nouns causes ev to evaluate nouns in an expression.

The verb form is distinguished by a leading dollar sign $ on the corresponding Lisp symbol. In contrast, the noun form is distinguished by a leading percent sign % on the corresponding Lisp symbol. Some nouns have special display properties, such as 'integrate and 'derivative (returned by diff), but most do not. By default, the noun and verb forms of a function are identical when displayed. The global flag noundisp causes Maxima to display nouns with a leading quote mark '.

See also noun, nouns, nounify, and verbify.

Examples:

     (%i1) foo (x) := x^2;
                                          2
     (%o1)                     foo(x) := x
     (%i2) foo (42);
     (%o2)                         1764
     (%i3) 'foo (42);
     (%o3)                        foo(42)
     (%i4) 'foo (42), nouns;
     (%o4)                         1764
     (%i5) declare (bar, noun);
     (%o5)                         done
     (%i6) bar (x) := x/17;
                                          x
     (%o6)                    ''bar(x) := --
                                          17
     (%i7) bar (52);
     (%o7)                        bar(52)
     (%i8) bar (52), nouns;
                                    52
     (%o8)                          --
                                    17
     (%i9) integrate (1/x, x, 1, 42);
     (%o9)                        log(42)
     (%i10) 'integrate (1/x, x, 1, 42);
                                  42
                                 /
                                 [   1
     (%o10)                      I   - dx
                                 ]   x
                                 /
                                  1
     (%i11) ev (%, nouns);
     (%o11)                       log(42)

Identifiers
===========

Maxima identifiers may comprise alphabetic characters, plus the numerals 0 through 9, plus any special character preceded by the backslash \ character.

A numeral may be the first character of an identifier if it is preceded by a backslash. Numerals which are the second or later characters need not be preceded by a backslash.

Characters may be declared alphabetic by the declare function. If so declared, they need not be preceded by a backslash in an identifier. The alphabetic characters are initially A through Z, a through z, %, and _.

Maxima is case-sensitive. The identifiers foo, FOO, and Foo are distinct. See Lisp and Maxima for more on this point.

A Maxima identifier is a Lisp symbol which begins with a dollar sign $. Any other Lisp symbol is preceded by a question mark ? when it appears in Maxima. See Lisp and Maxima for more on this point.

Examples:

     (%i1) %an_ordinary_identifier42;
     (%o1)               %an_ordinary_identifier42
     (%i2) embedded\ spaces\ in\ an\ identifier;
     (%o2)           embedded spaces in an identifier
     (%i3) symbolp (%);
     (%o3)                         true
     (%i4) [foo+bar, foo\+bar];
     (%o4)                 [foo + bar, foo+bar]
     (%i5) [1729, \1729];
     (%o5)                     [1729, 1729]
     (%i6) [symbolp (foo\+bar), symbolp (\1729)];
     (%o6)                     [true, true]
     (%i7) [is (foo\+bar = foo+bar), is (\1729 = 1729)];
     (%o7)                    [false, false]
     (%i8) baz\~quux;
     (%o8)                       baz~quux
     (%i9) declare ("~", alphabetic);
     (%o9)                         done
     (%i10) baz~quux;
     (%o10)                      baz~quux
     (%i11) [is (foo = FOO), is (FOO = Foo), is (Foo = foo)];
     (%o11)                [false, false, false]
     (%i12) :lisp (defvar *my-lisp-variable* '$foo)
     *MY-LISP-VARIABLE*
     (%i12) ?\*my\-lisp\-variable\*;
     (%o12)                         foo

Strings
=======

Strings (quoted character sequences) are enclosed in double quote marks " for input, and displayed with or without the quote marks, depending on the global variable stringdisp.

Strings may contain any characters, including embedded tab, newline, and carriage return characters. The sequence \" is recognized as a literal double quote, and \\ as a literal backslash. When backslash appears at the end of a line, the backslash and the line termination (either newline or carriage return and newline) are ignored, so that the string continues with the next line. No other special combinations of backslash with another character are recognized; when backslash appears before any character other than ", \, or a line termination, the backslash is ignored. There is no way to represent a special character (such as tab, newline, or carriage return) except by embedding the literal character in the string.

There is no character type in Maxima; a single character is represented as a one-character string.

Maxima strings are implemented as Lisp symbols, not Lisp strings; that may change in a future version of Maxima. Maxima can display Lisp strings and Lisp characters, although some other operations (for example, equality tests) may fail.

The stringproc add-on package contains many functions for working with strings.

Examples:

     (%i1) s_1 : "This is a Maxima string.";
     (%o1)               This is a Maxima string.
     (%i2) s_2 : "Embedded \"double quotes\" and backslash \\ characters.";
     (%o2) Embedded "double quotes" and backslash \ characters.
     (%i3) s_3 : "Embedded line termination
     in this string.";
     (%o3) Embedded line termination
     in this string.
     (%i4) s_4 : "Ignore the \
     line termination \
     characters in \
     this string.";
     (%o4) Ignore the line termination characters in this string.
     (%i5) stringdisp : false;
     (%o5)                         false
     (%i6) s_1;
     (%o6)               This is a Maxima string.
     (%i7) stringdisp : true;
     (%o7)                         true
     (%i8) s_1;
     (%o8)              "This is a Maxima string."

Inequality
==========

Maxima has the inequality operators <, <=, >=, >, #, and notequal. See if for a description of conditional expressions.

Syntax
======

It is possible to define new operators with specified precedence, to undefine existing operators, or to redefine the precedence of existing operators. An operator may be unary prefix or unary postfix, binary infix, n-ary infix, matchfix, or nofix. "Matchfix" means a pair of symbols which enclose their argument or arguments, and "nofix" means an operator which takes no arguments. As examples of the different types of operators, there are the following.

unary prefix
     negation - a

unary postfix
     factorial a!

binary infix
     exponentiation a^b

n-ary infix
     addition a + b

matchfix
     list construction [a, b]

(There are no built-in nofix operators; for an example of such an operator, see nofix.)

The mechanism to define a new operator is straightforward. It is only necessary to declare a function as an operator; the operator function might or might not be defined.

An example of user-defined operators is the following. Note that the explicit function call "dd" (a) is equivalent to dd a, likewise "<-" (a, b) is equivalent to a <- b. Note also that the functions "dd" and "<-" are undefined in this example.

     (%i1) prefix ("dd");
     (%o1)                          dd
     (%i2) dd a;
     (%o2)                         dd a
     (%i3) "dd" (a);
     (%o3)                         dd a
     (%i4) infix ("<-");
     (%o4)                          <-
     (%i5) a <- dd b;
     (%o5)                      a <- dd b
     (%i6) "<-" (a, "dd" (b));
     (%o6)                      a <- dd b

The Maxima functions which define new operators are summarized in this table, stating the default left and right binding powers (lbp and rbp, respectively). (Binding power determines operator precedence. However, since left and right binding powers can differ, binding power is somewhat more complicated than precedence.) Some of the operation definition functions take additional arguments; see the function descriptions for details.

prefix
     rbp=180

postfix
     lbp=180

infix
     lbp=180, rbp=180

nary
     lbp=180, rbp=180

matchfix
     (binding power not applicable)

nofix
     (binding power not applicable)

For comparison, here are some built-in operators and their left and right binding powers.

     Operator   lbp     rbp

       :        180     20
       ::       180     20
       :=       180     20
       ::=      180     20
       !        160
       !!       160
       ^        140     139
       .        130     129
       *        120
       /        120     120
       +        100     100
       -        100     134
       =        80      80
       #        80      80
       >        80      80
       >=       80      80
       <        80      80
       <=       80      80
       not              70
       and      65
       or       60
       ,        10
       $        -1
       ;        -1

remove and kill remove operator properties from an atom. remove ("A", op) removes only the operator properties of A. kill ("A") removes all properties of A, including the operator properties. Note that the name of the operator must be enclosed in quotation marks.

     (%i1) infix ("##");
     (%o1)                          ##
     (%i2) "##" (a, b) := a^b;
                                          b
     (%o2)                     a ## b := a
     (%i3) 5 ## 3;
     (%o3)                          125
     (%i4) remove ("##", op);
     (%o4)                         done
     (%i5) 5 ## 3;
     Incorrect syntax: # is not a prefix operator
     5 ##
       ^
     (%i5) "##" (5, 3);
     (%o5)                          125
     (%i6) infix ("##");
     (%o6)                          ##
     (%i7) 5 ## 3;
     (%o7)                          125
     (%i8) kill ("##");
     (%o8)                         done
     (%i9) 5 ## 3;
     Incorrect syntax: # is not a prefix operator
     5 ##
       ^
     (%i9) "##" (5, 3);
     (%o9)                       ##(5, 3)

Functions and Variables for Expressions
=======================================

 -- Function: at (EXPR, [EQN_1, ..., EQN_N])
 -- Function: at (EXPR, EQN)
     Evaluates the expression EXPR with the variables assuming the values as specified for them in the list of equations [EQN_1, ..., EQN_N] or the single equation EQN.

     If a subexpression depends on any of the variables for which a value is specified but there is no atvalue specified and it can't be otherwise evaluated, then a noun form of the at is returned which displays in a two-dimensional form.

     at carries out multiple substitutions in series, not parallel.

     See also atvalue. For other functions which carry out substitutions, see also subst and ev.

     Examples:

          (%i1) atvalue (f(x,y), [x = 0, y = 1], a^2);
                                          2
          (%o1)                          a
          (%i2) atvalue ('diff (f(x,y), x), x = 0, 1 + y);
          (%o2)                        @2 + 1
          (%i3) printprops (all, atvalue);
                                          !
                            d             !
                           --- (f(@1, @2))!       = @2 + 1
                           d@1            !
                                          !@1 = 0

                                               2
                                    f(0, 1) = a

          (%o3)                         done
          (%i4) diff (4*f(x, y)^2 - u(x, y)^2, x);
                            d                          d
          (%o4)  8 f(x, y) (-- (f(x, y))) - 2 u(x, y) (-- (u(x, y)))
                            dx                         dx
          (%i5) at (%, [x = 0, y = 1]);
                                                   !
                        2              d           !
          (%o5)     16 a  - 2 u(0, 1) (-- (u(x, y))!            )
                                       dx          !
                                                   !x = 0, y = 1

 -- Function: box (EXPR)
 -- Function: box (EXPR, A)
     Returns EXPR enclosed in a box. The return value is an expression with box as the operator and EXPR as the argument. A box is drawn on the display when display2d is true.

     box (EXPR, A) encloses EXPR in a box labelled by the symbol A. The label is truncated if it is longer than the width of the box.

     box evaluates its argument. However, a boxed expression does not evaluate to its content, so boxed expressions are effectively excluded from computations.

     boxchar is the character used to draw the box in box and in the dpart and lpart functions.

     Examples:

          (%i1) box (a^2 + b^2);
                                      """""""""
                                      " 2    2"
          (%o1)                       "b  + a "
                                      """""""""
          (%i2) a : 1234;
          (%o2)                         1234
          (%i3) b : c - d;
          (%o3)                         c - d
          (%i4) box (a^2 + b^2);
                                """"""""""""""""""""
                                "       2          "
          (%o4)                 "(c - d)  + 1522756"
                                """"""""""""""""""""
          (%i5) box (a^2 + b^2, term_1);
                                term_1""""""""""""""
                                "       2          "
          (%o5)                 "(c - d)  + 1522756"
                                """"""""""""""""""""
          (%i6) 1729 - box (1729);
                                           """"""
          (%o6)                     1729 - "1729"
                                           """"""
          (%i7) boxchar: "-";
          (%o7)                           -
          (%i8) box (sin(x) + cos(y));
                                  -----------------
          (%o8)                   -cos(y) + sin(x)-
                                  -----------------

 -- Option variable: boxchar
     Default value: "

     boxchar is the character used to draw the box in the box and in the dpart and lpart functions.

     All boxes in an expression are drawn with the current value of boxchar; the drawing character is not stored with the box expression.

 -- Function: carg (Z)
     Returns the complex argument of Z. The complex argument is an angle theta in (-%pi, %pi] such that r exp (theta %i) = Z where r is the magnitude of Z.

     carg is a computational function, not a simplifying function.

     carg ignores the declaration declare (X, complex), and treats X as a real variable. This is a bug.

     See also abs (complex magnitude), polarform, rectform, realpart, and imagpart.

     Examples:

          (%i1) carg (1);
          (%o1)                           0
          (%i2) carg (1 + %i);
                                         %pi
          (%o2)                          ---
                                          4
          (%i3) carg (exp (%i));
          (%o3)                           1
          (%i4) carg (exp (%pi * %i));
          (%o4)                          %pi
          (%i5) carg (exp (3/2 * %pi * %i));
                                          %pi
          (%o5)                         - ---
                                           2
          (%i6) carg (17 * exp (2 * %i));
          (%o6)                           2

 -- Special operator: constant
     declare (A, constant) declares A to be a constant. See declare.

 -- Function: constantp (EXPR)
     Returns true if EXPR is a constant expression, otherwise returns false.

     An expression is considered a constant expression if its arguments are numbers (including rational numbers, as displayed with /R/), symbolic constants such as %pi, %e, and %i, variables bound to a constant or declared constant by declare, or functions whose arguments are constant.

     constantp evaluates its arguments.

     Examples:

          (%i1) constantp (7 * sin(2));
          (%o1)                                true
          (%i2) constantp (rat (17/29));
          (%o2)                                true
          (%i3) constantp (%pi * sin(%e));
          (%o3)                                true
          (%i4) constantp (exp (x));
          (%o4)                                false
          (%i5) declare (x, constant);
          (%o5)                                done
          (%i6) constantp (exp (x));
          (%o6)                                true
          (%i7) constantp (foo (x) + bar (%e) + baz (2));
          (%o7)                                false
          (%i8)

 -- Function: declare (A_1, P_1, A_2, P_2, ...)
     Assigns the atom or list of atoms A_I the property or list of properties P_I. When A_I and/or P_I are lists, each of the atoms gets all of the properties.

     declare quotes its arguments. declare always returns done.

     As noted in the description for each declaration flag, for some flags featurep(OBJECT, FEATURE) returns true if OBJECT has been declared to have FEATURE. However, featurep does not recognize some flags; this is a bug.

     See also features.

     declare recognizes the following properties:

     evfun
          Makes A_I known to ev so that the function named by A_I is applied when A_I appears as a flag argument of ev. See evfun.

     evflag
          Makes A_I known to the ev function so that A_I is bound to true during the execution of ev when A_I appears as a flag argument of ev. See evflag.

     bindtest
          Tells Maxima to trigger an error when A_I is evaluated unbound.

     noun
          Tells Maxima to parse A_I as a noun. The effect of this is to replace instances of A_I with 'A_I or nounify(A_I), depending on the context.

     constant
          Tells Maxima to consider A_I a symbolic constant.

     scalar
          Tells Maxima to consider A_I a scalar variable.

     nonscalar
          Tells Maxima to consider A_I a nonscalar variable. The usual application is to declare a variable as a symbolic vector or matrix.

     mainvar
          Tells Maxima to consider A_I a "main variable" (mainvar). ordergreatp determines the ordering of atoms as follows:

          (main variables) > (other variables) > (scalar variables) > (constants) > (numbers)

     alphabetic
          Tells Maxima to recognize all characters in A_I (which must be a string) as alphabetic characters.

     feature
          Tells Maxima to recognize A_I as the name of a feature. Other atoms may then be declared to have the A_I property.

     rassociative, lassociative
          Tells Maxima to recognize A_I as a right-associative or left-associative function.

     nary
          Tells Maxima to recognize A_I as an n-ary function.

          The nary declaration is not the same as calling the nary function. The sole effect of declare(foo, nary) is to instruct the Maxima simplifier to flatten nested expressions, for example, to simplify foo(x, foo(y, z)) to foo(x, y, z).

     symmetric, antisymmetric, commutative
          Tells Maxima to recognize A_I as a symmetric or antisymmetric function. commutative is the same as symmetric.

     oddfun, evenfun
          Tells Maxima to recognize A_I as an odd or even function.

     outative
          Tells Maxima to simplify A_I expressions by pulling constant factors out of the first argument.

          When A_I has one argument, a factor is considered constant if it is a literal or declared constant.

          When A_I has two or more arguments, a factor is considered constant if the second argument is a symbol and the factor is free of the second argument.

     multiplicative
          Tells Maxima to simplify A_I expressions by the substitution A_I(x * y * z * ...) --> A_I(x) * A_I(y) * A_I(z) * .... The substitution is carried out on the first argument only.

     additive
          Tells Maxima to simplify A_I expressions by the substitution A_I(x + y + z + ...) --> A_I(x) + A_I(y) + A_I(z) + .... The substitution is carried out on the first argument only.

     linear
          Equivalent to declaring A_I both outative and additive.

     integer, noninteger
          Tells Maxima to recognize A_I as an integer or noninteger variable.

     even, odd
          Tells Maxima to recognize A_I as an even or odd integer variable.

     rational, irrational
          Tells Maxima to recognize A_I as a rational or irrational real variable.

     real, imaginary, complex
          Tells Maxima to recognize A_I as a real, pure imaginary, or complex variable.

     increasing, decreasing
          Tells Maxima to recognize A_I as an increasing or decreasing function.

     posfun
          Tells Maxima to recognize A_I as a positive function.

     integervalued
          Tells Maxima to recognize A_I as an integer-valued function.

     Examples:

     evfun and evflag declarations.

          (%i1) declare (expand, evfun);
          (%o1)                         done
          (%i2) (a + b)^3;
                                             3
          (%o2)                       (b + a)
          (%i3) (a + b)^3, expand;
                               3        2      2      3
          (%o3)               b  + 3 a b  + 3 a  b + a
          (%i4) declare (demoivre, evflag);
          (%o4)                         done
          (%i5) exp (a + b*%i);
                                       %i b + a
          (%o5)                      %e
          (%i6) exp (a + b*%i), demoivre;
                                a
          (%o6)               %e  (%i sin(b) + cos(b))

     bindtest declaration.

          (%i1) aa + bb;
          (%o1)                        bb + aa
          (%i2) declare (aa, bindtest);
          (%o2)                         done
          (%i3) aa + bb;
          aa unbound variable
           -- an error.  Quitting.  To debug this try debugmode(true);
          (%i4) aa : 1234;
          (%o4)                         1234
          (%i5) aa + bb;
          (%o5)                       bb + 1234

     noun declaration.

          (%i1) factor (12345678);
                                       2
          (%o1)                     2 3  47 14593
          (%i2) declare (factor, noun);
          (%o2)                         done
          (%i3) factor (12345678);
          (%o3)                   factor(12345678)
          (%i4) ''%, nouns;
                                       2
          (%o4)                     2 3  47 14593

     constant, scalar, nonscalar, and mainvar declarations.

     alphabetic declaration.

          (%i1) xx\~yy\`\@ : 1729;
          (%o1)                         1729
          (%i2) declare ("~`@", alphabetic);
          (%o2)                         done
          (%i3) xx~yy`@ + @yy`xx + `xx@@yy~;
          (%o3)               `xx@@yy~ + @yy`xx + 1729
          (%i4) listofvars (%);
          (%o4)                  [@yy`xx, `xx@@yy~]

     feature declaration.

          (%i1) declare (FOO, feature);
          (%o1)                         done
          (%i2) declare (x, FOO);
          (%o2)                         done
          (%i3) featurep (x, FOO);
          (%o3)                         true

     rassociative and lassociative declarations.

     nary declaration.

          (%i1) H (H (a, b), H (c, H (d, e)));
          (%o1)               H(H(a, b), H(c, H(d, e)))
          (%i2) declare (H, nary);
          (%o2)                         done
          (%i3) H (H (a, b), H (c, H (d, e)));
          (%o3)                   H(a, b, c, d, e)

     symmetric and antisymmetric declarations.

          (%i1) S (b, a);
          (%o1)                        S(b, a)
          (%i2) declare (S, symmetric);
          (%o2)                         done
          (%i3) S (b, a);
          (%o3)                        S(a, b)
          (%i4) S (a, c, e, d, b);
          (%o4)                   S(a, b, c, d, e)
          (%i5) T (b, a);
          (%o5)                        T(b, a)
          (%i6) declare (T, antisymmetric);
          (%o6)                         done
          (%i7) T (b, a);
          (%o7)                       - T(a, b)
          (%i8) T (a, c, e, d, b);
          (%o8)                   T(a, b, c, d, e)

     oddfun and evenfun declarations.

          (%i1) o (- u) + o (u);
          (%o1)                     o(u) + o(- u)
          (%i2) declare (o, oddfun);
          (%o2)                         done
          (%i3) o (- u) + o (u);
          (%o3)                           0
          (%i4) e (- u) - e (u);
          (%o4)                     e(- u) - e(u)
          (%i5) declare (e, evenfun);
          (%o5)                         done
          (%i6) e (- u) - e (u);
          (%o6)                           0

     outative declaration.

          (%i1) F1 (100 * x);
          (%o1)                       F1(100 x)
          (%i2) declare (F1, outative);
          (%o2)                         done
          (%i3) F1 (100 * x);
          (%o3)                       100 F1(x)
          (%i4) declare (zz, constant);
          (%o4)                         done
          (%i5) F1 (zz * y);
          (%o5)                       zz F1(y)

     multiplicative declaration.

          (%i1) F2 (a * b * c);
          (%o1)                       F2(a b c)
          (%i2) declare (F2, multiplicative);
          (%o2)                         done
          (%i3) F2 (a * b * c);
          (%o3)                   F2(a) F2(b) F2(c)

     additive declaration.

          (%i1) F3 (a + b + c);
          (%o1)                     F3(c + b + a)
          (%i2) declare (F3, additive);
          (%o2)                         done
          (%i3) F3 (a + b + c);
          (%o3)                 F3(c) + F3(b) + F3(a)

     linear declaration.

          (%i1) 'sum (F(k) + G(k), k, 1, inf);
                                 inf
                                 ====
                                 \
          (%o1)                   >    (G(k) + F(k))
                                 /
                                 ====
                                 k = 1
          (%i2) declare (nounify (sum), linear);
          (%o2)                         done
          (%i3) 'sum (F(k) + G(k), k, 1, inf);
                               inf          inf
                               ====         ====
                               \            \
          (%o3)                 >    G(k) +  >    F(k)
                               /            /
                               ====         ====
                               k = 1        k = 1

 -- Function: disolate (EXPR, X_1, ..., X_N)
     is similar to isolate (EXPR, X) except that it enables the user to isolate more than one variable simultaneously.  This might be useful, for example, if one were attempting to change variables in a multiple integration, and that variable change involved two or more of the integration variables.  This function is autoloaded from simplification/disol.mac.  A demo is available by demo("disol")$.

 -- Function: dispform (EXPR)
     Returns the external representation of EXPR with respect to its main operator.  This should be useful in conjunction with part which also deals with the external representation.  Suppose EXPR is -A . Then the internal representation of EXPR is "*"(-1,A), while the external representation is "-"(A). dispform (EXPR, all) converts the entire expression (not just the top-level) to external format.  For example, if expr: sin (sqrt (x)), then freeof (sqrt, expr) and freeof (sqrt, dispform (expr)) give true, while freeof (sqrt, dispform (expr, all)) gives false.

 -- Function: distrib (EXPR)
     Distributes sums over products.  It differs from expand in that it works at only the top level of an expression, i.e., it doesn't recurse and it is faster than expand.  It differs from multthru in that it expands all sums at that level.

     Examples:

          (%i1) distrib ((a+b) * (c+d));
          (%o1)                 b d + a d + b c + a c
          (%i2) multthru ((a+b) * (c+d));
          (%o2)                 (b + a) d + (b + a) c
          (%i3) distrib (1/((a+b) * (c+d)));
                                          1
          (%o3)                    ---------------
                                   (b + a) (d + c)
          (%i4) expand (1/((a+b) * (c+d)), 1, 0);
                                          1
          (%o4)                 ---------------------
                                b d + a d + b c + a c

 -- Function: dpart (EXPR, N_1, ..., N_K)
     Selects the same subexpression as part, but instead of just returning that subexpression as its value, it returns the whole expression with the selected subexpression displayed inside a box.  The box is actually part of the expression.

          (%i1) dpart (x+y/z^2, 1, 2, 1);
                                       y
          (%o1)                       ---- + x
                                         2
                                      """
                                      "z"
                                      """

 -- Function: exp (X)
     Represents the exponential function. Instances of exp (X) in input are simplified to %e^X; exp does not appear in simplified expressions.

     demoivre if true causes %e^(a + b %i) to simplify to %e^(a (cos(b) + %i sin(b))) if b is free of %i. See demoivre.

     %emode, when true, causes %e^(%pi %i x) to be simplified. See %emode.

     %enumer, when true causes %e to be replaced by 2.718...  whenever numer is true. See %enumer.

 -- Option variable: %emode
     Default value: true

     When %emode is true, %e^(%pi %i x) is simplified as follows.

     %e^(%pi %i x) simplifies to cos (%pi x) + %i sin (%pi x) if x is an integer or a multiple of 1/2, 1/3, 1/4, or 1/6, and then further simplified.

     For other numerical x, %e^(%pi %i x) simplifies to %e^(%pi %i y) where y is x - 2 k for some integer k such that abs(y) < 1.

     When %emode is false, no special simplification of %e^(%pi %i x) is carried out.

 -- Option variable: %enumer
     Default value: false

     When %enumer is true, %e is replaced by its numeric value 2.718...  whenever numer is true.

     When %enumer is false, this substitution is carried out only if the exponent in %e^x evaluates to a number.

     See also ev and numer.

 -- Option variable: exptisolate
     Default value: false

     exptisolate, when true, causes isolate (expr, var) to examine exponents of atoms (such as %e) which contain var.

 -- Option variable: exptsubst
     Default value: false

     exptsubst, when true, permits substitutions such as y for %e^x in %e^(a x).

 -- Function: freeof (X_1, ..., X_N, EXPR)
     freeof (X_1, EXPR) Returns true if no subexpression of EXPR is equal to X_1 or if X_1 occurs only as a dummy variable in EXPR, and returns false otherwise.

     freeof (X_1, ..., X_N, EXPR) is equivalent to freeof (X_1, EXPR) and ... and freeof (X_N, EXPR).

     The arguments X_1, ..., X_N may be names of functions and variables, subscripted names, operators (enclosed in double quotes), or general expressions. freeof evaluates its arguments.

     freeof operates only on EXPR as it stands (after simplification and evaluation) and does not attempt to determine if some equivalent expression would give a different result. In particular, simplification may yield an equivalent but different expression which comprises some different elements than the original form of EXPR.

     A variable is a dummy variable in an expression if it has no binding outside of the expression. Dummy variables recognized by freeof are the index of a sum or product, the limit variable in limit, the integration variable in the definite integral form of integrate, the original variable in laplace, formal variables in at expressions, and arguments in lambda expressions. Local variables in block are not recognized by freeof as dummy variables; this is a bug.

     The indefinite form of integrate is not free of its variable of integration.

       * Arguments are names of functions, variables, subscripted names, operators, and expressions. freeof (a, b, expr) is equivalent to freeof (a, expr) and freeof (b, expr).

               (%i1) expr: z^3 * cos (a[1]) * b^(c+d);
                                                d + c  3
               (%o1)                   cos(a ) b      z
                                            1
               (%i2) freeof (z, expr);
               (%o2)                         false
               (%i3) freeof (cos, expr);
               (%o3)                         false
               (%i4) freeof (a[1], expr);
               (%o4)                         false
               (%i5) freeof (cos (a[1]), expr);
               (%o5)                         false
               (%i6) freeof (b^(c+d), expr);
               (%o6)                         false
               (%i7) freeof ("^", expr);
               (%o7)                         false
               (%i8) freeof (w, sin, a[2], sin (a[2]), b*(c+d), expr);
               (%o8)                         true

       * freeof evaluates its arguments.

               (%i1) expr: (a+b)^5$
               (%i2) c: a$
               (%i3) freeof (c, expr);
               (%o3)                         false

       * freeof does not consider equivalent expressions. Simplification may yield an equivalent but different expression.

               (%i1) expr: (a+b)^5$
               (%i2) expand (expr);
                         5        4       2  3       3  2      4      5
               (%o2)    b  + 5 a b  + 10 a  b  + 10 a  b  + 5 a  b + a
               (%i3) freeof (a+b, %);
               (%o3)                         true
               (%i4) freeof (a+b, expr);
               (%o4)                         false
               (%i5) exp (x);
                                                x
               (%o5)                          %e
               (%i6) freeof (exp, exp (x));
               (%o6)                         true

       * A summation or definite integral is free of its dummy variable. An indefinite integral is not free of its variable of integration.

               (%i1) freeof (i, 'sum (f(i), i, 0, n));
               (%o1)                         true
               (%i2) freeof (x, 'integrate (x^2, x, 0, 1));
               (%o2)                         true
               (%i3) freeof (x, 'integrate (x^2, x));
               (%o3)                         false

 -- Function: genfact (X, Y, Z)
     Returns the generalized factorial, defined as x (x-z) (x - 2 z) ... (x - (y - 1) z).  Thus, for integral X, genfact (x, x, 1) = x! and genfact (x, x/2, 2) = x!!.

 -- Function: imagpart (EXPR)
     Returns the imaginary part of the expression EXPR.

     imagpart is a computational function, not a simplifying function.

     See also abs, carg, polarform, rectform, and realpart.

 -- Function: infix (OP)
 -- Function: infix (OP, LBP, RBP)
 -- Function: infix (OP, LBP, RBP, LPOS, RPOS, POS)
     Declares OP to be an infix operator. An infix operator is a function of two arguments, with the name of the function written between the arguments. For example, the subtraction operator - is an infix operator.

     infix (OP) declares OP to be an infix operator with default binding powers (left and right both equal to 180) and parts of speech (left and right both equal to any).

     infix (OP, LBP, RBP) declares OP to be an infix operator with stated left and right binding powers and default parts of speech (left and right both equal to any).

     infix (OP, LBP, RBP, LPOS, RPOS, POS) declares OP to be an infix operator with stated left and right binding powers and parts of speech.

     The precedence of OP with respect to other operators derives from the left and right binding powers of the operators in question. If the left and right binding powers of OP are both greater the left and right binding powers of some other operator, then OP takes precedence over the other operator. If the binding powers are not both greater or less, some more complicated relation holds.

     The associativity of OP depends on its binding powers. Greater left binding power (LBP) implies an instance of OP is evaluated before other operators to its left in an expression, while greater right binding power (RBP) implies  an instance of OP is evaluated before other operators to its right in an expression. Thus greater LBP makes OP right-associative, while greater RBP makes OP left-associative. If LBP is equal to RBP, OP is left-associative.

     See also Syntax.

     Examples:

     If the left and right binding powers of OP are both greater the left and right binding powers of some other operator, then OP takes precedence over the other operator.

          (%i1) :lisp (get '$+ 'lbp)
          100
          (%i1) :lisp (get '$+ 'rbp)
          100
          (%i1) infix ("##", 101, 101);
          (%o1)                          ##
          (%i2) "##"(a, b) := sconcat("(", a, ",", b, ")");
          (%o2)       (a ## b) := sconcat("(", a, ",", b, ")")
          (%i3) 1 + a ## b + 2;
          (%o3)                       (a,b) + 3
          (%i4) infix ("##", 99, 99);
          (%o4)                          ##
          (%i5) 1 + a ## b + 2;
          (%o5)                       (a+1,b+2)

     Greater LBP makes OP right-associative, while greater RBP makes OP left-associative.

          (%i1) infix ("##", 100, 99);
          (%o1)                          ##
          (%i2) "##"(a, b) := sconcat("(", a, ",", b, ")")$
          (%i3) foo ## bar ## baz;
          (%o3)                    (foo,(bar,baz))
          (%i4) infix ("##", 100, 101);
          (%o4)                          ##
          (%i5) foo ## bar ## baz;
          (%o5)                    ((foo,bar),baz)

 -- Option variable: inflag
     Default value: false

     When inflag is true, functions for part extraction inspect the internal form of expr.

     Note that the simplifier re-orders expressions. Thus first (x + y) returns x if inflag is true and y if inflag is false. (first (y + x) gives the same results.)

     Also, setting inflag to true and calling part or substpart is the same as calling inpart or substinpart.

     Functions affected by the setting of inflag are: part, substpart, first, rest, last, length, the for ... in construct, map, fullmap, maplist, reveal and pickapart.

 -- Function: inpart (EXPR, N_1, ..., N_K)
     is similar to part but works on the internal representation of the expression rather than the displayed form and thus may be faster since no formatting is done.  Care should be taken with respect to the order of subexpressions in sums and products (since the order of variables in the internal form is often different from that in the displayed form) and in dealing with unary minus, subtraction, and division (since these operators are removed from the expression). part (x+y, 0) or inpart (x+y, 0) yield +, though in order to refer to the operator it must be enclosed in "s.  For example ... if inpart (%o9,0) = "+" then ....

     Examples:

          (%i1) x + y + w*z;
          (%o1)                      w z + y + x
          (%i2) inpart (%, 3, 2);
          (%o2)                           z
          (%i3) part (%th (2), 1, 2);
          (%o3)                           z
          (%i4) 'limit (f(x)^g(x+1), x, 0, minus);
                                            g(x + 1)
          (%o4)                 limit   f(x)
                                x -> 0-
          (%i5) inpart (%, 1, 2);
          (%o5)                       g(x + 1)

 -- Function: isolate (EXPR, X)
     Returns EXPR with subexpressions which are sums and which do not contain var replaced by intermediate expression labels (these being atomic symbols like %t1, %t2, ...).  This is often useful to avoid unnecessary expansion of subexpressions which don't contain the variable of interest.  Since the intermediate labels are bound to the subexpressions they can all be substituted back by evaluating the expression in which they occur.

     exptisolate (default value: false) if true will cause isolate to examine exponents of atoms (like %e) which contain var.

     isolate_wrt_times if true, then isolate will also isolate with respect to products. See isolate_wrt_times.

     Do example (isolate) for examples.

 -- Option variable: isolate_wrt_times
     Default value: false

     When isolate_wrt_times is true, isolate will also isolate with respect to products.  E.g. compare both settings of the switch on

          (%i1) isolate_wrt_times: true$
          (%i2) isolate (expand ((a+b+c)^2), c);

          (%t2)                          2 a

          (%t3)                          2 b

                                    2            2
          (%t4)                    b  + 2 a b + a

                               2
          (%o4)               c  + %t3 c + %t2 c + %t4
          (%i4) isolate_wrt_times: false$
          (%i5) isolate (expand ((a+b+c)^2), c);
                               2
          (%o5)               c  + 2 b c + 2 a c + %t4

 -- Option variable: listconstvars
     Default value: false

     When listconstvars is true, it will cause listofvars to include %e, %pi, %i, and any variables declared constant in the list it returns if they appear in the expression listofvars is called on. The default is to omit these.

 -- Option variable: listdummyvars
     Default value: true

     When listdummyvars is false, "dummy variables" in the expression will not be included in the list returned by listofvars. (The meaning of "dummy variables" is as given in freeof. "Dummy variables" are mathematical things like the index of a sum or product, the limit variable, and the definite integration variable.) Example:

          (%i1) listdummyvars: true$
          (%i2) listofvars ('sum(f(i), i, 0, n));
          (%o2)                        [i, n]
          (%i3) listdummyvars: false$
          (%i4) listofvars ('sum(f(i), i, 0, n));
          (%o4)                          [n]

 -- Function: listofvars (EXPR)
     Returns a list of the variables in EXPR.

     listconstvars if true causes listofvars to include %e, %pi, %i, and any variables declared constant in the list it returns if they appear in EXPR.  The default is to omit these.

          (%i1) listofvars (f (x[1]+y) / g^(2+a));
          (%o1)                     [g, a, x , y]
                                            1

 -- Function: lfreeof (LIST, EXPR)
     For each member M of list, calls freeof (M, EXPR). It returns false if any call to freeof does and true otherwise.

 -- Function: lopow (EXPR, X)
     Returns the lowest exponent of X which explicitly appears in EXPR.  Thus

          (%i1) lopow ((x+y)^2 + (x+y)^a, x+y);
          (%o1)                       min(a, 2)

 -- Function: lpart (LABEL, EXPR, N_1, ..., N_K)
     is similar to dpart but uses a labelled box. A labelled box is similar to the one produced by dpart but it has a name in the top line.

 -- Function: multthru (EXPR)
 -- Function: multthru (EXPR_1, EXPR_2)
     Multiplies a factor (which should be a sum) of EXPR by the other factors of EXPR.  That is, EXPR is F_1 F_2 ... F_N where at least one factor, say F_I, is a sum of terms.  Each term in that sum is multiplied by the other factors in the product.  (Namely all the factors except F_I).  multthru does not expand exponentiated sums. This function is the fastest way to distribute products (commutative or noncommutative) over sums.  Since quotients are represented as products multthru can be used to divide sums by products as well.

     multthru (EXPR_1, EXPR_2) multiplies each term in EXPR_2 (which should be a sum or an equation) by EXPR_1.  If EXPR_1 is not itself a sum then this form is equivalent to multthru (EXPR_1*EXPR_2).

          (%i1) x/(x-y)^2 - 1/(x-y) - f(x)/(x-y)^3;
                                1        x         f(x)
          (%o1)             - ----- + -------- - --------
                              x - y          2          3
                                      (x - y)    (x - y)
          (%i2) multthru ((x-y)^3, %);
                                     2
          (%o2)             - (x - y)  + x (x - y) - f(x)
          (%i3) ratexpand (%);
                                     2
          (%o3)                   - y  + x y - f(x)
          (%i4) ((a+b)^10*s^2 + 2*a*b*s + (a*b)^2)/(a*b*s^2);
                                  10  2              2  2
                           (b + a)   s  + 2 a b s + a  b
          (%o4)            ------------------------------
                                            2
                                       a b s
          (%i5) multthru (%);  /* note that this does not expand (b+a)^10 */
                                                  10
                                 2   a b   (b + a)
          (%o5)                  - + --- + ---------
                                 s    2       a b
                                     s
          (%i6) multthru (a.(b+c.(d+e)+f));
          (%o6)            a . f + a . c . (e + d) + a . b
          (%i7) expand (a.(b+c.(d+e)+f));
          (%o7)         a . f + a . c . e + a . c . d + a . b

 -- Function: nounify (F)
     Returns the noun form of the function name F.  This is needed if one wishes to refer to the name of a verb function as if it were a noun.  Note that some verb functions will return their noun forms if they can't be evaluated for certain arguments.  This is also the form returned if a function call is preceded by a quote.

 -- Function: nterms (EXPR)
     Returns the number of terms that EXPR would have if it were fully expanded out and no cancellations or combination of terms occurred. Note that expressions like sin (EXPR), sqrt (EXPR), exp (EXPR), etc. count as just one term regardless of how many terms EXPR has (if it is a sum).

 -- Function: op (EXPR)
     Returns the main operator of the expression EXPR. op (EXPR) is equivalent to part (EXPR, 0).

     op returns a string if the main operator is a built-in or user-defined prefix, binary or n-ary infix, postfix, matchfix, or nofix operator. Otherwise, if EXPR is a subscripted function expression, op returns the subscripted function; in this case the return value is not an atom. Otherwise, EXPR is an array function or ordinary function expression, and op returns a symbol.

     op observes the value of the global flag inflag.

     op evaluates it argument.

     See also args.

     Examples:

          (%i1) stringdisp: true$
          (%i2) op (a * b * c);
          (%o2)                          "*"
          (%i3) op (a * b + c);
          (%o3)                          "+"
          (%i4) op ('sin (a + b));
          (%o4)                          sin
          (%i5) op (a!);
          (%o5)                          "!"
          (%i6) op (-a);
          (%o6)                          "-"
          (%i7) op ([a, b, c]);
          (%o7)                          "["
          (%i8) op ('(if a > b then c else d));
          (%o8)                         "if"
          (%i9) op ('foo (a));
          (%o9)                          foo
          (%i10) prefix (foo);
          (%o10)                        "foo"
          (%i11) op (foo a);
          (%o11)                        "foo"
          (%i12) op (F [x, y] (a, b, c));
          (%o12)                        F
                                         x, y
          (%i13) op (G [u, v, w]);
          (%o13)                          G

 -- Function: operatorp (EXPR, OP)
 -- Function: operatorp (EXPR, [OP_1, ..., OP_N])

     operatorp (EXPR, OP) returns true if OP is equal to the operator of EXPR.

     operatorp (EXPR, [OP_1, ..., OP_N]) returns true if some element OP_1, ..., OP_N is equal to the operator of EXPR.

 -- Function: optimize (EXPR)
     Returns an expression that produces the same value and side effects as EXPR but does so more efficiently by avoiding the recomputation of common subexpressions.  optimize also has the side effect of "collapsing" its argument so that all common subexpressions are shared. Do example (optimize) for examples.

 -- Option variable: optimprefix
     Default value: %

     optimprefix is the prefix used for generated symbols by the optimize command.

 -- Function: ordergreat (V_1, ..., V_N)
     Sets up aliases for the variables V_1, ..., V_N such that V_1 > V_2 > ...  > V_N, and V_N > any other variable not mentioned as an argument.

     See also orderless.

 -- Function: ordergreatp (EXPR_1, EXPR_2)
     Returns true if EXPR_2 precedes EXPR_1 in the ordering set up with the ordergreat function.

 -- Function: orderless (V_1, ..., V_N)
     Sets up aliases for the variables V_1, ..., V_N such that V_1 < V_2 < ...  < V_N, and V_N < any other variable not mentioned as an argument.

     Thus the complete ordering scale is: numerical constants < declared constants < declared scalars < first argument to orderless < ...  < last argument to orderless < variables which begin with A < ... < variables which begin with Z < last argument to ordergreat < ... < first argument to ordergreat < declared mainvars.

     See also ordergreat and mainvar.

 -- Function: orderlessp (EXPR_1, EXPR_2)
     Returns true if EXPR_1 precedes EXPR_2 in the ordering set up by the orderless command.

 -- Function: part (EXPR, N_1, ..., N_K)
     Returns parts of the displayed form of expr. It obtains the part of expr as specified by the indices N_1, ..., N_K.  First part N_1 of expr is obtained, then part N_2 of that, etc.  The result is part N_K of ... part N_2 of part N_1 of expr.

     part can be used to obtain an element of a list, a row of a matrix, etc.

     If the last argument to a part function is a list of indices then several subexpressions are picked out, each one corresponding to an index of the list.  Thus part (x + y + z, [1, 3]) is z+x.

     piece holds the last expression selected when using the part functions.  It is set during the execution of the function and thus may be referred to in the function itself as shown below.

     If partswitch is set to true then end is returned when a selected part of an expression doesn't exist, otherwise an error message is given.

     Example: part (z+2*y, 2, 1) yields 2.

     example (part) displays additional examples.

 -- Function: partition (EXPR, X)
     Returns a list of two expressions.  They are (1) the factors of EXPR (if it is a product), the terms of EXPR (if it is a sum), or the list (if it is a list) which don't contain var and, (2) the factors, terms, or list which do.

          (%i1) partition (2*a*x*f(x), x);
          (%o1)                     [2 a, x f(x)]
          (%i2) partition (a+b, x);
          (%o2)                      [b + a, 0]
          (%i3) partition ([a, b, f(a), c], a);
          (%o3)                  [[b, c], [a, f(a)]]

 -- Option variable: partswitch
     Default value: false

     When partswitch is true, end is returned when a selected part of an expression doesn't exist, otherwise an error message is given.

 -- Function: pickapart (EXPR, N)
     Assigns intermediate expression labels to subexpressions of EXPR at depth N, an integer. Subexpressions at greater or lesser depths are not assigned labels. pickapart returns an expression in terms of intermediate expressions equivalent to the original expression EXPR.

     See also part, dpart, lpart, inpart, and reveal.

     Examples:

          (%i1) expr: (a+b)/2 + sin (x^2)/3 - log (1 + sqrt(x+1));
                                                    2
                                               sin(x )   b + a
          (%o1)       - log(sqrt(x + 1) + 1) + ------- + -----
                                                  3        2
          (%i2) pickapart (expr, 0);

                                                    2
                                               sin(x )   b + a
          (%t2)       - log(sqrt(x + 1) + 1) + ------- + -----
                                                  3        2

          (%o2)                          %t2
          (%i3) pickapart (expr, 1);

          (%t3)                - log(sqrt(x + 1) + 1)

                                            2
                                       sin(x )
          (%t4)                        -------
                                          3

                                        b + a
          (%t5)                         -----
                                          2

          (%o5)                    %t5 + %t4 + %t3
          (%i5) pickapart (expr, 2);

          (%t6)                 log(sqrt(x + 1) + 1)

                                            2
          (%t7)                        sin(x )

          (%t8)                         b + a

                                   %t8   %t7
          (%o8)                    --- + --- - %t6
                                    2     3
          (%i8) pickapart (expr, 3);

          (%t9)                    sqrt(x + 1) + 1

                                          2
          (%t10)                         x

                            b + a              sin(%t10)
          (%o10)            ----- - log(%t9) + ---------
                              2                    3
          (%i10) pickapart (expr, 4);

          (%t11)                     sqrt(x + 1)

                                2
                           sin(x )   b + a
          (%o11)           ------- + ----- - log(%t11 + 1)
                              3        2
          (%i11) pickapart (expr, 5);

          (%t12)                        x + 1

                             2
                        sin(x )   b + a
          (%o12)        ------- + ----- - log(sqrt(%t12) + 1)
                           3        2
          (%i12) pickapart (expr, 6);
                            2
                       sin(x )   b + a
          (%o12)       ------- + ----- - log(sqrt(x + 1) + 1)
                          3        2

 -- System variable: piece
     Holds the last expression selected when using the part functions. It is set during the execution of the function and thus may be referred to in the function itself.

 -- Function: polarform (EXPR)
     Returns an expression r %e^(%i theta) equivalent to EXPR, such that r and theta are purely real.

 -- Function: powers (EXPR, X)
     Gives the powers of X occuring in EXPR.

     load (powers) loads this function.

 -- Function: product (EXPR, I, I_0, I_1)
     Represents a product of the values of EXPR as the index I varies from I_0 to I_1. The noun form 'product is displayed as an uppercase letter pi.

     product evaluates EXPR and lower and upper limits I_0 and I_1, product quotes (does not evaluate) the index I.

     If the upper and lower limits differ by an integer, EXPR is evaluated for each value of the index I, and the result is an explicit product.

     Otherwise, the range of the index is indefinite. Some rules are applied to simplify the product. When the global variable simpproduct is true, additional rules are applied. In some cases, simplification yields a result which is not a product; otherwise, the result is a noun form 'product.

     See also nouns and evflag.

     Examples:

          (%i1) product (x + i*(i+1)/2, i, 1, 4);
          (%o1)           (x + 1) (x + 3) (x + 6) (x + 10)
          (%i2) product (i^2, i, 1, 7);
          (%o2)                       25401600
          (%i3) product (a[i], i, 1, 7);
          (%o3)                 a  a  a  a  a  a  a
                                 1  2  3  4  5  6  7
          (%i4) product (a(i), i, 1, 7);
          (%o4)          a(1) a(2) a(3) a(4) a(5) a(6) a(7)
          (%i5) product (a(i), i, 1, n);
                                       n
                                     /===\
                                      ! !
          (%o5)                       ! !  a(i)
                                      ! !
                                     i = 1
          (%i6) product (k, k, 1, n);
                                         n
                                       /===\
                                        ! !
          (%o6)                         ! !  k
                                        ! !
                                       k = 1
          (%i7) product (k, k, 1, n), simpproduct;
          (%o7)                          n!
          (%i8) product (integrate (x^k, x, 0, 1), k, 1, n);
                                       n
                                     /===\
                                      ! !    1
          (%o8)                       ! !  -----
                                      ! !  k + 1
                                     k = 1
          (%i9) product (if k <= 5 then a^k else b^k, k, 1, 10);
                                        15  40
          (%o9)                        a   b

 -- Function: realpart (EXPR)
     Returns the real part of EXPR. realpart and imagpart will work on expressions involving trigonometic and hyperbolic functions, as well as square root, logarithm, and exponentiation.

 -- Function: rectform (EXPR)
     Returns an expression a + b %i equivalent to EXPR, such that A and B are purely real.

 -- Function: rembox (EXPR, unlabelled)
 -- Function: rembox (EXPR, LABEL)
 -- Function: rembox (EXPR)
     Removes boxes from EXPR.

     rembox (EXPR, unlabelled) removes all unlabelled boxes from EXPR.

     rembox (EXPR, LABEL) removes only boxes bearing LABEL.

     rembox (EXPR) removes all boxes, labelled and unlabelled.

     Boxes are drawn by the box, dpart, and lpart functions.

     Examples:

          (%i1) expr: (a*d - b*c)/h^2 + sin(%pi*x);
                                            a d - b c
          (%o1)                sin(%pi x) + ---------
                                                2
                                               h
          (%i2) dpart (dpart (expr, 1, 1), 2, 2);
                                  """""""    a d - b c
          (%o2)               sin("%pi x") + ---------
                                  """""""      """"
                                               " 2"
                                               "h "
                                               """"
          (%i3) expr2: lpart (BAR, lpart (FOO, %, 1), 2);
                            FOO"""""""""""   BAR""""""""
                            "    """"""" "   "a d - b c"
          (%o3)             "sin("%pi x")" + "---------"
                            "    """"""" "   "  """"   "
                            """"""""""""""   "  " 2"   "
                                             "  "h "   "
                                             "  """"   "
                                             """""""""""
          (%i4) rembox (expr2, unlabelled);
                                            BAR""""""""
                             FOO"""""""""   "a d - b c"
          (%o4)              "sin(%pi x)" + "---------"
                             """"""""""""   "    2    "
                                            "   h     "
                                            """""""""""
          (%i5) rembox (expr2, FOO);
                                            BAR""""""""
                                 """""""    "a d - b c"
          (%o5)              sin("%pi x") + "---------"
                                 """""""    "  """"   "
                                            "  " 2"   "
                                            "  "h "   "
                                            "  """"   "
                                            """""""""""
          (%i6) rembox (expr2, BAR);
                             FOO"""""""""""
                             "    """"""" "   a d - b c
          (%o6)              "sin("%pi x")" + ---------
                             "    """"""" "     """"
                             """"""""""""""     " 2"
                                                "h "
                                                """"
          (%i7) rembox (expr2);
                                            a d - b c
          (%o7)                sin(%pi x) + ---------
                                                2
                                               h

 -- Function: sum (EXPR, I, I_0, I_1)
     Represents a summation of the values of EXPR as the index I varies from I_0 to I_1. The noun form 'sum is displayed as an uppercase letter sigma.

     sum evaluates its summand EXPR and lower and upper limits I_0 and I_1, sum quotes (does not evaluate) the index I.

     If the upper and lower limits differ by an integer, the summand EXPR is evaluated for each value of the summation index I, and the result is an explicit sum.

     Otherwise, the range of the index is indefinite. Some rules are applied to simplify the summation. When the global variable simpsum is true, additional rules are applied. In some cases, simplification yields a result which is not a summation; otherwise, the result is a noun form 'sum.

     When the evflag (evaluation flag) cauchysum is true, a product of summations is expressed as a Cauchy product, in which the index of the inner summation is a function of the index of the outer one, rather than varying independently.

     The global variable genindex is the alphabetic prefix used to generate the next index of summation, when an automatically generated index is needed.

     gensumnum is the numeric suffix used to generate the next index of summation, when an automatically generated index is needed. When gensumnum is false, an automatically-generated index is only genindex with no numeric suffix.

     See also sumcontract, intosum, bashindices, niceindices, nouns, evflag, and zeilberger.

     Examples:

          (%i1) sum (i^2, i, 1, 7);
          (%o1)                          140
          (%i2) sum (a[i], i, 1, 7);
          (%o2)           a  + a  + a  + a  + a  + a  + a
                           7    6    5    4    3    2    1
          (%i3) sum (a(i), i, 1, 7);
          (%o3)    a(7) + a(6) + a(5) + a(4) + a(3) + a(2) + a(1)
          (%i4) sum (a(i), i, 1, n);
                                      n
                                     ====
                                     \
          (%o4)                       >    a(i)
                                     /
                                     ====
                                     i = 1
          (%i5) sum (2^i + i^2, i, 0, n);
                                    n
                                   ====
                                   \       i    2
          (%o5)                     >    (2  + i )
                                   /
                                   ====
                                   i = 0
          (%i6) sum (2^i + i^2, i, 0, n), simpsum;
                                        3      2
                             n + 1   2 n  + 3 n  + n
          (%o6)             2      + --------------- - 1
                                            6
          (%i7) sum (1/3^i, i, 1, inf);
                                      inf
                                      ====
                                      \     1
          (%o7)                        >    --
                                      /      i
                                      ====  3
                                      i = 1
          (%i8) sum (1/3^i, i, 1, inf), simpsum;
                                          1
          (%o8)                           -
                                          2
          (%i9) sum (i^2, i, 1, 4) * sum (1/i^2, i, 1, inf);
                                        inf
                                        ====
                                        \     1
          (%o9)                      30  >    --
                                        /      2
                                        ====  i
                                        i = 1
          (%i10) sum (i^2, i, 1, 4) * sum (1/i^2, i, 1, inf), simpsum;
                                            2
          (%o10)                       5 %pi
          (%i11) sum (integrate (x^k, x, 0, 1), k, 1, n);
                                      n
                                     ====
                                     \       1
          (%o11)                      >    -----
                                     /     k + 1
                                     ====
                                     k = 1
          (%i12) sum (if k <= 5 then a^k else b^k, k, 1, 10));
          Incorrect syntax: Too many )'s
          else b^k, k, 1, 10))
                            ^
          (%i12) linenum:11;
          (%o11)                         11
          (%i12) sum (integrate (x^k, x, 0, 1), k, 1, n);
                                      n
                                     ====
                                     \       1
          (%o12)                      >    -----
                                     /     k + 1
                                     ====
                                     k = 1
          (%i13) sum (if k <= 5 then a^k else b^k, k, 1, 10);
                    10    9    8    7    6    5    4    3    2
          (%o13)   b   + b  + b  + b  + b  + a  + a  + a  + a  + a

 -- Function: lsum (EXPR, X, L)
     Represents the sum of EXPR for each element X in L.

     A noun form 'lsum is returned if the argument L does not evaluate to a list.

     Examples:

          (%i1) lsum (x^i, i, [1, 2, 7]);
                                      7    2
          (%o1)                      x  + x  + x
          (%i2) lsum (i^2, i, rootsof (x^3 - 1));
                               ====
                               \      2
          (%o2)                 >    i
                               /
                               ====
                                             3
                               i in rootsof(x  - 1)

 -- Function: verbify (F)
     Returns the verb form of the function name F.

     See also verb, noun, and nounify.

     Examples:

          (%i1) verbify ('foo);
          (%o1)                          foo
          (%i2) :lisp $%
          $FOO
          (%i2) nounify (foo);
          (%o2)                          foo
          (%i3) :lisp $%
          %FOO