[ < ] | [ > ] |  | [ << ] | [ Up ] | [ >> ] |  |  |  |  | [Top] | [Contents] | [Index] | [ ? ]

# 6. Expressions

0

[ < ] | [ > ] |  | [ << ] | [ Up ] | [ >> ] |  |  |  |  | [Top] | [Contents] | [Index] | [ ? ]

## 6.1 Introduction to Expressions

There are a number of reserved words which should not 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

0

[ < ] | [ > ] |  | [ << ] | [ Up ] | [ >> ] |  |  |  |  | [Top] | [Contents] | [Index] | [ ? ]

## 6.2 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.

·

@ref{Category: Complex variables}

0

[ < ] | [ > ] |  | [ << ] | [ Up ] | [ >> ] |  |  |  |  | [Top] | [Contents] | [Index] | [ ? ]

## 6.3 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)

·

@ref{Category: Evaluation} · @ref{Category: Nouns and verbs}

0

[ < ] | [ > ] |  | [ << ] | [ Up ] | [ >> ] |  |  |  |  | [Top] | [Contents] | [Index] | [ ? ]

## 6.4 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 @ref{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 @ref{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

·

@ref{Category: Syntax}

0

[ < ] | [ > ] |  | [ << ] | [ Up ] | [ >> ] |  |  |  |  | [Top] | [Contents] | [Index] | [ ? ]

## 6.5 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.

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

Examples:

    (%i1) s_1 : "This is a string.";
    (%o1)               This is a 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 string.
    (%i7) stringdisp : true;
    (%o7)                         true
    (%i8) s_1;
    (%o8)                  "This is a string."

·

@ref{Category: Syntax}

0

[ < ] | [ > ] |  | [ << ] | [ Up ] | [ >> ] |  |  |  |  | [Top] | [Contents] | [Index] | [ ? ]

## 6.6 Inequality

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

0

[ < ] | [ > ] |  | [ << ] | [ Up ] | [ >> ] |  |  |  |  | [Top] | [Contents] | [Index] | [ ? ]

## 6.7 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)

·

@ref{Category: Operators} · @ref{Category: Syntax}

0

[ < ] | [ > ] |  | [ << ] | [ Up ] | [ >> ] |  |  |  |  | [Top] | [Contents] | [Index] | [ ? ]

## 6.8 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

  ·

  @ref{Category: Evaluation} · @ref{Category: Differential equations}

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)-
                              -----------------

  ·

  @ref{Category: Expressions}

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.

  ·

  @ref{Category: Expressions}

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.

  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

  ·

  @ref{Category: Complex variables}

Special operator: constant

  `declare (a, constant)` declares a to be a constant. See `declare`.

  ·

  @ref{Category: Declarations and inferences} · @ref{Category: Constants}

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)

  ·

  @ref{Category: Predicate functions} · @ref{Category: Constants}

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.

  `nonarray`

    Tells Maxima to consider a_i not an array. This declaration prevents multiple evaluation of a subscripted variable name.

  `mainvar`

    Tells Maxima to consider a_i a "main variable". A main variable succeeds all other constants and variables in the canonical ordering of Maxima expressions, as determined by `ordergreatp`.

  `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

  ·

  @ref{Category: Declarations and inferences}

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")$`.

  ·

  @ref{Category: Expressions}

Function: dispform (expr)
Function: dispform (expr, all)

  Returns the external representation of expr.

  `dispform(expr)` returns the external representation with respect to the main (top-level) operator. `dispform(expr, all)` returns the external representation with respect to all operators in expr.

  See also `part`, `inpart`, and `inflag`.

  Examples:

  The internal representation of `- x` is "negative one times `x`" while the external representation is "minus `x`".

      (%i1) - x;
      (%o1)                          - x
      (%i2) ?format (true, "~S~%", %);
      ((MTIMES SIMP) -1 $X)
      (%o2)                         false
      (%i3) dispform (- x);
      (%o3)                          - x
      (%i4) ?format (true, "~S~%", %);
      ((MMINUS SIMP) $X)
      (%o4)                         false

  The internal representation of `sqrt(x)` is "`x` to the power 1/2" while the external representation is "square root of `x`".

      (%i1) sqrt (x);
      (%o1)                        sqrt(x)
      (%i2) ?format (true, "~S~%", %);
      ((MEXPT SIMP) $X ((RAT SIMP) 1 2))
      (%o2)                         false
      (%i3) dispform (sqrt (x));
      (%o3)                        sqrt(x)
      (%i4) ?format (true, "~S~%", %);
      ((%SQRT SIMP) $X)
      (%o4)                         false

  Use of the optional argument `all`.

      (%i1) expr : sin (sqrt (x));
      (%o1)                     sin(sqrt(x))
      (%i2) freeof (sqrt, expr);
      (%o2)                         true
      (%i3) freeof (sqrt, dispform (expr));
      (%o3)                         true
      (%i4) freeof (sqrt, dispform (expr, all));
      (%o4)                         false

  ·

  @ref{Category: Expressions}

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

  ·

  @ref{Category: Expressions}

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"
                                  """

  ·

  @ref{Category: Expressions}

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`.

  ·

  @ref{Category: Exponential and logarithm functions}

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 a floating point number, 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.

  ·

  @ref{Category: Exponential and logarithm functions} · @ref{Category: Simplification flags and variables}

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`.

  ·

  @ref{Category: Exponential and logarithm functions} · @ref{Category: Evaluation flags}

Option variable: exptisolate

  Default value: `false`

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

  ·

  @ref{Category: Expressions}

Option variable: exptsubst

  Default value: `false`

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

  ·

  @ref{Category: Exponential and logarithm functions} · @ref{Category: Expressions}

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, or if x_1 is neither the noun nor verb form of any operator 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.

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

  Examples:

  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

  ·

  @ref{Category: Expressions}

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!!`.

  ·

  @ref{Category: Gamma and factorial functions}

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`.

  ·

  @ref{Category: Complex variables}

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 lpos, rpos, and pos for the left operand, the right operand, and the operator result, respectively.

  "Part of speech", in reference to operator declarations, means expression type. Three types are recognized: `expr`, `clause`, and `any`, indicating an algebraic expression, a Boolean expression, or any kind of expression, respectively. Maxima can detect some syntax errors by comparing the declared part of speech to an actual expression.

  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)

  Maxima can detect some syntax errors by comparing the declared part of speech to an actual expression.

      (%i1) infix ("##", 100, 99, expr, expr, expr);
      (%o1)                          ##
      (%i2) if x ## y then 1 else 0;
      Incorrect syntax: Found algebraic expression where logical expression expected
      if x ## y then
                   ^
      (%i2) infix ("##", 100, 99, expr, expr, clause);
      (%o2)                          ##
      (%i3) if x ## y then 1 else 0;
      (%o3)                if x ## y then 1 else 0

  ·

  @ref{Category: Operators} · @ref{Category: Declarations and inferences} · @ref{Category: Syntax}

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`.

  ·

  @ref{Category: Expressions}

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)

  ·

  @ref{Category: Expressions}

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.

  ·

  @ref{Category: Expressions}

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

  ·

  @ref{Category: Expressions}

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.

  ·

  @ref{Category: Expressions}

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]

  ·

  @ref{Category: Expressions}

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.

  See also the option variable `listdummyvars` to exclude or include "dummy variables" in the list of variables.

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

  ·

  @ref{Category: Expressions}

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.

  ·

  @ref{Category: Expressions}

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)

  ·

  @ref{Category: Expressions}

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.

  ·

  @ref{Category: Expressions}

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

  ·

  @ref{Category: Expressions}

Property: nonarray

  The command `declare(a, nonarray)` tells Maxima to consider a not an array. This declaration prevents multiple evaluation, if a is a subscripted variable.

  Example:

      (%i1) a:'b$ b:'c$ c:'d$

      (%i4) a[x];
      (%o4)                          d
                                      x
      (%i5) declare(a, nonarray);
      (%o5)                         done
      (%i6) a[x];
      (%o6)                          a
                                      x

  ·

  @ref{Category: Expressions}

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.

  ·

  @ref{Category: Nouns and verbs}

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).

  ·

  @ref{Category: Expressions}

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

  ·

  @ref{Category: Expressions} · @ref{Category: Operators}

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.

  ·

  @ref{Category: Operators} · @ref{Category: Predicate functions}

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.

  ·

  @ref{Category: Expressions}

Option variable: optimprefix

  Default value: `%`

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

  ·

  @ref{Category: Expressions}

Function: ordergreat (v_1, ..., v_n)
Function: orderless (v_1, ..., v_n)

  `ordergreat` changes the canonical ordering of Maxima expressions such that v_1 succeeds v_2 succeeds ... succeeds v_n, and v_n succeeds any other symbol not mentioned as an argument.

  `orderless` changes the canonical ordering of Maxima expressions such that v_1 precedes v_2 precedes ... precedes v_n, and v_n precedes any other variable not mentioned as an argument.

  The order established by `ordergreat` and `orderless` is dissolved by `unorder`. `ordergreat` and `orderless` can be called only once each, unless `unorder` is called; only the last call to `ordergreat` and `orderless` has any effect.

  See also `ordergreatp`.

  ·

  @ref{Category: Expressions}

Function: ordergreatp (expr_1, expr_2)
Function: orderlessp (expr_1, expr_2)

  `ordergreatp` returns `true` if expr_1 succeeds expr_2 in the canonical ordering of Maxima expressions, and `false` otherwise.

  `orderlessp` returns `true` if expr_1 precedes expr_2 in the canonical ordering of Maxima expressions, and `false` otherwise.

  All Maxima atoms and expressions are comparable under `ordergreatp` and `orderlessp`, although there are isolated examples of expressions for which these predicates are not transitive; that is a bug.

  The canonical ordering of atoms (symbols, literal numbers, and strings) is the following.

  (integers and floats) precede (bigfloats) precede (declared constants) precede (strings) precede (declared scalars) precede (first argument to `orderless`) precedes ... precedes (last argument to `orderless`) precedes (other symbols) precede (last argument to `ordergreat`) precedes ... precedes (first argument to `ordergreat`) precedes (declared main variables)

  For non-atomic expressions, the canonical ordering is derived from the ordering for atoms. For the built-in `+` `*` and `^` operators, the ordering is not easily summarized. For other built-in operators and all other functions and operators, expressions are ordered by their arguments (beginning with the first argument), then by the name of the operator or function. In the case of subscripted expressions, the subscripted symbol is considered the operator and the subscript is considered an argument.

  The canonical ordering of expressions is modified by the functions `ordergreat` and `orderless`, and the `mainvar`, `constant`, and `scalar` declarations.

  See also `sort`.

  Examples:

  Ordering ordinary symbols and constants. Note that `%pi` is not ordered according to its numerical value.

      (%i1) stringdisp : true;
      (%o1)                         true
      (%i2) sort ([%pi, 3b0, 3.0, x, X, "foo", 3, a, 4, "bar", 4.0, 4b0]);
      (%o2) [3, 3.0, 4, 4.0, 3.0b0, 4.0b0, %pi, "bar", "foo", a, x, X]

  Effect of `ordergreat` and `orderless` functions.

      (%i1) sort ([M, H, K, T, E, W, G, A, P, J, S]);
      (%o1)           [A, E, G, H, J, K, M, P, S, T, W]
      (%i2) ordergreat (S, J);
      (%o2)                         done
      (%i3) orderless (M, H);
      (%o3)                         done
      (%i4) sort ([M, H, K, T, E, W, G, A, P, J, S]);
      (%o4)           [M, H, A, E, G, K, P, T, W, J, S]

  Effect of `mainvar`, `constant`, and `scalar` declarations.

      (%i1) sort ([aa, foo, bar, bb, baz, quux, cc, dd, A1, B1, C1]);
      (%o1)   [aa, bar, baz, bb, cc, dd, foo, quux, A1, B1, C1]
      (%i2) declare (aa, mainvar);
      (%o2)                         done
      (%i3) declare ([baz, quux], constant);
      (%o3)                         done
      (%i4) declare ([A1, B1], scalar);
      (%o4)                         done
      (%i5) sort ([aa, foo, bar, bb, baz, quux, cc, dd, A1, B1, C1]);
      (%o5)   [baz, quux, A1, B1, bar, bb, cc, dd, foo, C1, aa]

  Ordering non-atomic expressions.

      (%i1) sort ([1, 2, n, f(1), f(2), f(2, 1), g(1), g(1, 2), g(n), f(n, 1)]);
      (%o1) [1, 2, f(1), g(1), g(1, 2), f(2), f(2, 1), n, g(n),
                                                               f(n, 1)]
      (%i2) sort ([foo(1), X[1], X[k], foo(k), 1, k]);
      (%o2)            [1, foo(1), X , k, foo(k), X ]
                                    1              k

  ·

  @ref{Category: Expressions} · @ref{Category: Predicate functions}

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`. If no indices are specified `expr` is returned.

  `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.

  See also `inpart`, `substpart`, `substinpart`, `dpart`, and `lpart`.

  Examples:

      (%i1) part(z+2*y+a,2);
      (%o1)                                 2 y
      (%i2) part(z+2*y+a,[1,3]);
      (%o2)                                z + a
      (%i3) part(z+2*y+a,2,1);
      (%o3)                                  2

  `example (part)` displays additional examples.

  ·

  @ref{Category: Expressions}

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 x 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)]]

  ·

  @ref{Category: Expressions}

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.

  ·

  @ref{Category: Expressions}

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

  ·

  @ref{Category: Expressions}

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.

  ·

  @ref{Category: Expressions}

Function: polarform (expr)

  Returns an expression `r %e^(%i theta)` equivalent to expr, such that `r` and `theta` are purely real.

  ·

  @ref{Category: Complex variables} · @ref{Category: Exponential and logarithm functions}

Function: powers (expr, x)

  Gives the powers of x occuring in expr.

  `load (powers)` loads this function.

  ·

  @ref{Category: Expressions} · @ref{Category: Polynomials}

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

  ·

  @ref{Category: Sums and products}

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.

  ·

  @ref{Category: Complex variables}

Function: rectform (expr)

  Returns an expression `a + b %i` equivalent to expr, such that a and b are purely real.

  ·

  @ref{Category: Complex variables}

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

  ·

  @ref{Category: Expressions}

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);
                10    9    8    7    6    5    4    3    2
      (%o12)   b   + b  + b  + b  + b  + a  + a  + a  + a  + a

  ·

  @ref{Category: Sums and products}

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)

  ·

  @ref{Category: Sums and products}

Function: unorder ()

  Disables the aliasing created by the last use of the ordering commands `ordergreat` and `orderless`. `ordergreat` and `orderless` may not be used more than one time each without calling `unorder`.

  `unorder` does not substitute back in expressions the original symbols for the aliases introduced by `ordergreat` and `orderless`. Therefore, after execution of `unorder` the aliases appear in previous expressions.

  See also `ordergreat` and `orderless`.

  Examples:

  `ordergreat(a)` introduces an alias for the symbol `a`. Therefore, the difference of `%o2` and `%o4` does not vanish. `unorder` does not substitute back the symbol `a` and the alias appears in the output `%o7`.

      (%i1) unorder();
      (%o1)                          []
      (%i2) b*x+a^2;
                                         2
      (%o2)                       b x + a
      (%i3) ordergreat(a);
      (%o3)                         done
      (%i4) b*x+a^2;
                                   2
      (%o4)                       a  + b x
      (%i5) %th(1)-%th(3);
                                    2    2
      (%o5)                        a  - a
      (%i6) unorder();
      (%o6)                          [a]
      (%i7) %th(2);
                                      2    2
      (%o7)                      _101a  - a

  ·

  @ref{Category: Expressions}

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

  ·

  @ref{Category: Nouns and verbs}

0

[ << ] | [ >> ] |  |  |  |  |  | [Top] | [Contents] | [Index] | [ ? ]

This document was generated by Charlie & on January, 31 2011 using texi2html 1.76.