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

# 5. Operators

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

## 5.1 nary

An `nary` operator is used to denote a function of any number of arguments, each of which is separated by an occurrence of the operator, e.g. A+B or A+B+C. The `nary("x")` function is a syntax extension function to declare `x` to be an `nary` operator. Functions may be declared to be `nary`. If `declare(j,nary);` is done, this tells the simplifier to simplify, e.g. `j(j(a,b),j(c,d))` to `j(a, b, c, d)`.

See also `Syntax`.

Categories: Operators · Syntax

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

## 5.2 nofix

`nofix` operators are used to denote functions of no arguments. The mere presence of such an operator in a command will cause the corresponding function to be evaluated. For example, when one types "exit;" to exit from a Maxima break, "exit" is behaving similar to a `nofix` operator. The function `nofix("x")` is a syntax extension function which declares `x` to be a `nofix` operator.

See also `Syntax`.

Categories: Operators · Syntax

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

## 5.3 postfix

`postfix` operators like the `prefix` variety denote functions of a single argument, but in this case the argument immediately precedes an occurrence of the operator in the input string, e.g. 3! . The `postfix("x")` function is a syntax extension function to declare `x` to be a `postfix` operator.

See also `Syntax`.

Categories: Operators · Syntax

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

## 5.4 prefix

A `prefix` operator is one which signifies a function of one argument, which argument immediately follows an occurrence of the operator. `prefix("x")` is a syntax extension function to declare `x` to be a `prefix` operator.

See also `Syntax`.

Categories: Operators · Syntax

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

## 5.5 Arithmetic operators

Operator: +
Operator: -
Operator: *
Operator: /
Operator: ^

  The symbols `+` `*` `/` and `^` represent addition, multiplication, division, and exponentiation, respectively. The names of these operators are `"+"` `"*"` `"/"` and `"^"`, which may appear where the name of a function or operator is required.

  The symbols `+` and `-` represent unary addition and negation, respectively, and the names of these operators are `"+"` and `"-"`, respectively.

  Subtraction `a - b` is represented within Maxima as addition, `a + (- b)`. Expressions such as `a + (- b)` are displayed as subtraction. Maxima recognizes `"-"` only as the name of the unary negation operator, and not as the name of the binary subtraction operator.

  Division `a / b` is represented within Maxima as multiplication, `a * b^(- 1)`. Expressions such as `a * b^(- 1)` are displayed as division. Maxima recognizes `"/"` as the name of the division operator.

  Addition and multiplication are n-ary, commutative operators. Division and exponentiation are binary, noncommutative operators.

  Maxima sorts the operands of commutative operators to construct a canonical representation. For internal storage, the ordering is determined by `orderlessp`. For display, the ordering for addition is determined by `ordergreatp`, and for multiplication, it is the same as the internal ordering.

  Arithmetic computations are carried out on literal numbers (integers, rationals, ordinary floats, and bigfloats). Except for exponentiation, all arithmetic operations on numbers are simplified to numbers. Exponentiation is simplified to a number if either operand is an ordinary float or bigfloat or if the result is an exact integer or rational; otherwise an exponentiation may be simplified to `sqrt` or another exponentiation or left unchanged.

  Floating-point contagion applies to arithmetic computations: if any operand is a bigfloat, the result is a bigfloat; otherwise, if any operand is an ordinary float, the result is an ordinary float; otherwise, the operands are rationals or integers and the result is a rational or integer.

  Arithmetic computations are a simplification, not an evaluation. Thus arithmetic is carried out in quoted (but simplified) expressions.

  Arithmetic operations are applied element-by-element to lists when the global flag `listarith` is `true`, and always applied element-by-element to matrices. When one operand is a list or matrix and another is an operand of some other type, the other operand is combined with each of the elements of the list or matrix.

  Examples:

  Addition and multiplication are n-ary, commutative operators. Maxima sorts the operands to construct a canonical representation. The names of these operators are `"+"` and `"*"`.

      (%i1) c + g + d + a + b + e + f;
      (%o1)               g + f + e + d + c + b + a
      (%i2) [op (%), args (%)];
      (%o2)              [+, [g, f, e, d, c, b, a]]
      (%i3) c * g * d * a * b * e * f;
      (%o3)                     a b c d e f g
      (%i4) [op (%), args (%)];
      (%o4)              [*, [a, b, c, d, e, f, g]]
      (%i5) apply ("+", [a, 8, x, 2, 9, x, x, a]);
      (%o5)                    3 x + 2 a + 19
      (%i6) apply ("*", [a, 8, x, 2, 9, x, x, a]);
                                       2  3
      (%o6)                       144 a  x

  Division and exponentiation are binary, noncommutative operators. The names of these operators are `"/"` and `"^"`.

      (%i1) [a / b, a ^ b];
                                    a   b
      (%o1)                        [-, a ]
                                    b
      (%i2) [map (op, %), map (args, %)];
      (%o2)              [[/, ^], [[a, b], [a, b]]]
      (%i3) [apply ("/", [a, b]), apply ("^", [a, b])];
                                    a   b
      (%o3)                        [-, a ]
                                    b

  Subtraction and division are represented internally in terms of addition and multiplication, respectively.

      (%i1) [inpart (a - b, 0), inpart (a - b, 1), inpart (a - b, 2)];
      (%o1)                      [+, a, - b]
      (%i2) [inpart (a / b, 0), inpart (a / b, 1), inpart (a / b, 2)];
                                         1
      (%o2)                       [*, a, -]
                                         b

  Computations are carried out on literal numbers. Floating-point contagion applies.

      (%i1) 17 + b - (1/2)*29 + 11^(2/4);
                                             5
      (%o1)                   b + sqrt(11) + -
                                             2
      (%i2) [17 + 29, 17 + 29.0, 17 + 29b0];
      (%o2)                   [46, 46.0, 4.6b1]

  Arithmetic computations are a simplification, not an evaluation.

      (%i1) simp : false;
      (%o1)                         false
      (%i2) '(17 + 29*11/7 - 5^3);
                                    29 11    3
      (%o2)                    17 + ----- - 5
                                      7
      (%i3) simp : true;
      (%o3)                         true
      (%i4) '(17 + 29*11/7 - 5^3);
                                      437
      (%o4)                         - ---
                                       7

  Arithmetic is carried out element-by-element for lists (depending on `listarith`) and matrices.

      (%i1) matrix ([a, x], [h, u]) - matrix ([1, 2], [3, 4]);
                              [ a - 1  x - 2 ]
      (%o1)                   [              ]
                              [ h - 3  u - 4 ]
      (%i2) 5 * matrix ([a, x], [h, u]);
                                [ 5 a  5 x ]
      (%o2)                     [          ]
                                [ 5 h  5 u ]
      (%i3) listarith : false;
      (%o3)                         false
      (%i4) [a, c, m, t] / [1, 7, 2, 9];
                                [a, c, m, t]
      (%o4)                     ------------
                                [1, 7, 2, 9]
      (%i5) [a, c, m, t] ^ x;
                                            x
      (%o5)                     [a, c, m, t]
      (%i6) listarith : true;
      (%o6)                         true
      (%i7) [a, c, m, t] / [1, 7, 2, 9];
                                    c  m  t
      (%o7)                     [a, -, -, -]
                                    7  2  9
      (%i8) [a, c, m, t] ^ x;
                                x   x   x   x
      (%o8)                   [a , c , m , t ]

  Categories: Operators

Operator: **

  Exponentiation operator. Maxima recognizes `**` as the same operator as `^` in input, and it is displayed as `^` in 1-dimensional output, or by placing the exponent as a superscript in 2-dimensional output.

  The `fortran` function displays the exponentiation operator as `**`, whether it was input as `**` or `^`.

  Examples:

      (%i1) is (a**b = a^b);
      (%o1)                         true
      (%i2) x**y + x^z;
                                    z    y
      (%o2)                        x  + x
      (%i3) string (x**y + x^z);
      (%o3)                        x^z+x^y
      (%i4) fortran (x**y + x^z);
            x**z+x**y
      (%o4)                         done

  Categories: Operators

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

## 5.6 Relational operators

Operator: <
Operator: <=
Operator: >=
Operator: >

  The symbols `<` `<=` `>=` and `>` represent less than, less than or equal, greater than or equal, and greater than, respectively. The names of these operators are `"<"` `"<="` `">="` and `">"`, which may appear where the name of a function or operator is required.

  These relational operators are all binary operators; constructs such as `a < b < c` are not recognized by Maxima.

  Relational expressions are evaluated to Boolean values by the functions `is` and `maybe`, and the programming constructs `if`, `while`, and `unless`. Relational expressions are not otherwise evaluated or simplified to Boolean values, although the arguments of relational expressions are evaluated (when evaluation is not otherwise prevented by quotation).

  When a relational expression cannot be evaluated to `true` or `false`, the behavior of `is` and `if` are governed by the global flag `prederror`. When `prederror` is `true`, `is` and `if` trigger an error. When `prederror` is `false`, `is` returns `unknown`, and `if` returns a partially-evaluated conditional expression.

  `maybe` always behaves as if `prederror` were `false`, and `while` and `unless` always behave as if `prederror` were `true`.

  Relational operators do not distribute over lists or other aggregates.

  See also `=` `#` `equal` and `notequal`.

  Examples:

  Relational expressions are evaluated to Boolean values by some functions and programming constructs.

      (%i1) [x, y, z] : [123, 456, 789];
      (%o1)                    [123, 456, 789]
      (%i2) is (x < y);
      (%o2)                         true
      (%i3) maybe (y > z);
      (%o3)                         false
      (%i4) if x >= z then 1 else 0;
      (%o4)                           0
      (%i5) block ([S], S : 0, for i:1 while i <= 100 do S : S + i, return (S));
      (%o5)                         5050

  Relational expressions are not otherwise evaluated or simplified to Boolean values, although the arguments of relational expressions are evaluated.

      (%o1)                    [123, 456, 789]
      (%i2) [x < y, y <= z, z >= y, y > z];
      (%o2)    [123 < 456, 456 <= 789, 789 >= 456, 456 > 789]
      (%i3) map (is, %);
      (%o3)               [true, true, true, false]

  Categories: Operators

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

## 5.7 General operators

Operator: ^^

  Noncommutative exponentiation operator. `^^` is the exponentiation operator corresponding to noncommutative multiplication `.`, just as the ordinary exponentiation operator `^` corresponds to commutative multiplication `*`.

  Noncommutative exponentiation is displayed by `^^` in 1-dimensional output, and by placing the exponent as a superscript within angle brackets `< >` in 2-dimensional output.

  Examples:

      (%i1) a . a . b . b . b + a * a * a * b * b;
                              3  2    <2>    <3>
      (%o1)                  a  b  + a    . b
      (%i2) string (a . a . b . b . b + a * a * a * b * b);
      (%o2)                  a^3*b^2+a^^2 . b^^3

  Categories: Operators

Operator: !

  The factorial operator. For any complex number `x` (including integer, rational, and real numbers) except for negative integers, `x!` is defined as `gamma(x+1)`.

  For an integer `x`, `x!` simplifies to the product of the integers from 1 to `x` inclusive. `0!` simplifies to 1. For a floating point number `x`, `x!` simplifies to the value of `gamma (x+1)`. For `x` equal to `n/2` where `n` is an odd integer, `x!` simplifies to a rational factor times `sqrt (%pi)` (since `gamma (1/2)` is equal to `sqrt (%pi)`). If `x` is anything else, `x!` is not simplified.

  The variables `factlim`, `minfactorial`, and `factcomb` control the simplification of expressions containing factorials.

  The functions `gamma`, `bffac`, and `cbffac` are varieties of the gamma function. `makegamma` substitutes `gamma` for factorials and related functions.

  See also `binomial`.

  The factorial of an integer, half-integer, or floating point argument is simplified unless the operand is greater than `factlim`.

      (%i1) factlim : 10;
      (%o1)                          10
      (%i2) [0!, (7/2)!, 4.77!, 8!, 20!];
                  105 sqrt(%pi)
      (%o2)   [1, -------------, 81.44668037931199, 40320, 20!]
                       16

  The factorial of a complex number, known constant, or general expression is not simplified. Even so it may be possible simplify the factorial after evaluating the operand.

      (%i1) [(%i + 1)!, %pi!, %e!, (cos(1) + sin(1))!];
      (%o1)      [(%i + 1)!, %pi!, %e!, (sin(1) + cos(1))!]
      (%i2) ev (%, numer, %enumer);
      (%o2) [(%i + 1)!, 7.188082728976037, 4.260820476357,
                                                     1.227580202486819]

  The factorial of an unbound symbol is not simplified.

      (%i1) kill (foo);
      (%o1)                         done
      (%i2) foo!;
      (%o2)                         foo!

  Factorials are simplified, not evaluated. Thus `x!` may be replaced even in a quoted expression.

      (%i1) '([0!, (7/2)!, 4.77!, 8!, 20!]);
                105 sqrt(%pi)
      (%o1) [1, -------------, 81.44668037931199, 40320,
                     16
                                                   2432902008176640000]

  Categories: Gamma and factorial functions · Operators

Operator: !!

  The double factorial operator.

  For an integer, float, or rational number `n`, `n!!` evaluates to the product `n (n-2) (n-4) (n-6) ... (n - 2 (k-1))` where `k` is equal to `entier (n/2)`, that is, the largest integer less than or equal to `n/2`. Note that this definition does not coincide with other published definitions for arguments which are not integers.

  For an even (or odd) integer `n`, `n!!` evaluates to the product of all the consecutive even (or odd) integers from 2 (or 1) through `n` inclusive.

  For an argument `n` which is not an integer, float, or rational, `n!!` yields a noun form `genfact (n, n/2, 2)`.

  Categories: Gamma and factorial functions · Operators

Operator: #

  Represents the negation of syntactic equality `=`.

  Note that because of the rules for evaluation of predicate expressions (in particular because `not expr` causes evaluation of expr), `not a = b` is equivalent to `is(a # b)`, instead of `a # b`.

  Examples:

      (%i1) a = b;
      (%o1)                         a = b
      (%i2) is (a = b);
      (%o2)                         false
      (%i3) a # b;
      (%o3)                         a # b
      (%i4) not a = b;
      (%o4)                         true
      (%i5) is (a # b);
      (%o5)                         true
      (%i6) is (not a = b);
      (%o6)                         true

  Categories: Operators

Operator: .

  The dot operator, for matrix (non-commutative) multiplication. When `"."` is used in this way, spaces should be left on both sides of it, e.g. `A . B`. This distinguishes it plainly from a decimal point in a floating point number.

  See also `dot`, `dot0nscsimp`, `dot0simp`, `dot1simp`, `dotassoc`, `dotconstrules`, `dotdistrib`, `dotexptsimp`, `dotident`, and `dotscrules`.

  Categories: Operators

Operator: :

  Assignment operator.

  When the left-hand side is a simple variable (not subscripted), `:` evaluates its right-hand side and associates that value with the left-hand side.

  When the left-hand side is a subscripted element of a list, matrix, declared Maxima array, or Lisp array, the right-hand side is assigned to that element. The subscript must name an existing element; such objects cannot be extended by naming nonexistent elements.

  When the left-hand side is a subscripted element of an undeclared Maxima array, the right-hand side is assigned to that element, if it already exists, or a new element is allocated, if it does not already exist.

  When the left-hand side is a list of simple and/or subscripted variables, the right-hand side must evaluate to a list, and the elements of the right-hand side are assigned to the elements of the left-hand side, in parallel.

  See also `kill` and `remvalue`, which undo the association between the left-hand side and its value.

  Examples:

  Assignment to a simple variable.

      (%i1) a;
      (%o1)                           a
      (%i2) a : 123;
      (%o2)                          123
      (%i3) a;
      (%o3)                          123

  Assignment to an element of a list.

      (%i1) b : [1, 2, 3];
      (%o1)                       [1, 2, 3]
      (%i2) b[3] : 456;
      (%o2)                          456
      (%i3) b;
      (%o3)                      [1, 2, 456]

  Assignment creates an undeclared array.

      (%i1) c[99] : 789;
      (%o1)                          789
      (%i2) c[99];
      (%o2)                          789
      (%i3) c;
      (%o3)                           c
      (%i4) arrayinfo (c);
      (%o4)                   [hashed, 1, [99]]
      (%i5) listarray (c);
      (%o5)                         [789]

  Multiple assignment.

      (%i1) [a, b, c] : [45, 67, 89];
      (%o1)                     [45, 67, 89]
      (%i2) a;
      (%o2)                          45
      (%i3) b;
      (%o3)                          67
      (%i4) c;
      (%o4)                          89

  Multiple assignment is carried out in parallel. The values of `a` and `b` are exchanged in this example.

      (%i1) [a, b] : [33, 55];
      (%o1)                       [33, 55]
      (%i2) [a, b] : [b, a];
      (%o2)                       [55, 33]
      (%i3) a;
      (%o3)                          55
      (%i4) b;
      (%o4)                          33

  Categories: Evaluation · Operators

Operator: ::

  Assignment operator.

  `::` is the same as `:` (which see) except that `::` evaluates its left-hand side as well as its right-hand side.

  Examples:

      (%i1) x : 'foo;
      (%o1)                          foo
      (%i2) x :: 123;
      (%o2)                          123
      (%i3) foo;
      (%o3)                          123
      (%i4) x : '[a, b, c];
      (%o4)                       [a, b, c]
      (%i5) x :: [11, 22, 33];
      (%o5)                     [11, 22, 33]
      (%i6) a;
      (%o6)                          11
      (%i7) b;
      (%o7)                          22
      (%i8) c;
      (%o8)                          33

  Categories: Evaluation · Operators

Operator: ::=

  Macro function definition operator. `::=` defines a function (called a "macro" for historical reasons) which quotes its arguments, and the expression which it returns (called the "macro expansion") is evaluated in the context from which the macro was called. A macro function is otherwise the same as an ordinary function.

  `macroexpand` returns a macro expansion (without evaluating it). `macroexpand (foo (x))` followed by `''%` is equivalent to `foo (x)` when `foo` is a macro function.

  `::=` puts the name of the new macro function onto the global list `macros`. `kill`, `remove`, and `remfunction` unbind macro function definitions and remove names from `macros`.

  `fundef` or `dispfun` return a macro function definition or assign it to a label, respectively.

  Macro functions commonly contain `buildq` and `splice` expressions to construct an expression, which is then evaluated.

  Examples

  A macro function quotes its arguments, so message (1) shows `y - z`, not the value of `y - z`. The macro expansion (the quoted expression `'(print ("(2) x is equal to", x))` is evaluated in the context from which the macro was called, printing message (2).

      (%i1) x: %pi;
      (%o1)                          %pi
      (%i2) y: 1234;
      (%o2)                         1234
      (%i3) z: 1729 * w;
      (%o3)                        1729 w
      (%i4) printq1 (x) ::= block (print ("(1) x is equal to", x),
            '(print ("(2) x is equal to", x)));
      (%o4) printq1(x) ::= block(print("(1) x is equal to", x),
                                      '(print("(2) x is equal to", x)))
      (%i5) printq1 (y - z);
      (1) x is equal to y - z
      (2) x is equal to %pi
      (%o5)                          %pi

  An ordinary function evaluates is arguments, so message (1) shows the value of `y - z`. The return value is not evaluated, so message (2) is not printed until the explicit evaluation `''%`.

      (%i1) x: %pi;
      (%o1)                          %pi
      (%i2) y: 1234;
      (%o2)                         1234
      (%i3) z: 1729 * w;
      (%o3)                        1729 w
      (%i4) printe1 (x) := block (print ("(1) x is equal to", x),
            '(print ("(2) x is equal to", x)));
      (%o4) printe1(x) := block(print("(1) x is equal to", x),
                                      '(print("(2) x is equal to", x)))
      (%i5) printe1 (y - z);
      (1) x is equal to 1234 - 1729 w
      (%o5)              print((2) x is equal to, x)
      (%i6) ''%;
      (2) x is equal to %pi
      (%o6)                          %pi

  `macroexpand` returns a macro expansion. `macroexpand (foo (x))` followed by `''%` is equivalent to `foo (x)` when `foo` is a macro function.

      (%i1) x: %pi;
      (%o1)                          %pi
      (%i2) y: 1234;
      (%o2)                         1234
      (%i3) z: 1729 * w;
      (%o3)                        1729 w
      (%i4) g (x) ::= buildq ([x], print ("x is equal to", x));
      (%o4)    g(x) ::= buildq([x], print("x is equal to", x))
      (%i5) macroexpand (g (y - z));
      (%o5)              print(x is equal to, y - z)
      (%i6) ''%;
      x is equal to 1234 - 1729 w
      (%o6)                     1234 - 1729 w
      (%i7) g (y - z);
      x is equal to 1234 - 1729 w
      (%o7)                     1234 - 1729 w

  Categories: Function definition · Operators

Operator: :=

  The function definition operator. `f(x_1, ..., x_n) := expr` defines a function named f with arguments x_1, ..., x_n and function body expr. `:=` never evaluates the function body (unless explicitly evaluated by quote-quote `''`). The function so defined may be an ordinary Maxima function (with arguments enclosed in parentheses) or an array function (with arguments enclosed in square brackets).

  When the last or only function argument x_n is a list of one element, the function defined by `:=` accepts a variable number of arguments. Actual arguments are assigned one-to-one to formal arguments x_1, ..., x_(n - 1), and any further actual arguments, if present, are assigned to x_n as a list.

  All function definitions appear in the same namespace; defining a function `f` within another function `g` does not automatically limit the scope of `f` to `g`. However, `local(f)` makes the definition of function `f` effective only within the block or other compound expression in which `local` appears.

  If some formal argument x_k is a quoted symbol, the function defined by `:=` does not evaluate the corresponding actual argument. Otherwise all actual arguments are evaluated.

  See also `define` and `::=`.

  Examples:

  `:=` never evaluates the function body (unless explicitly evaluated by quote-quote).

      (%i1) expr : cos(y) - sin(x);
      (%o1)                    cos(y) - sin(x)
      (%i2) F1 (x, y) := expr;
      (%o2)                   F1(x, y) := expr
      (%i3) F1 (a, b);
      (%o3)                    cos(y) - sin(x)
      (%i4) F2 (x, y) := ''expr;
      (%o4)              F2(x, y) := cos(y) - sin(x)
      (%i5) F2 (a, b);
      (%o5)                    cos(b) - sin(a)

  The function defined by `:=` may be an ordinary Maxima function or an array function.

      (%i1) G1 (x, y) := x.y - y.x;
      (%o1)               G1(x, y) := x . y - y . x
      (%i2) G2 [x, y] := x.y - y.x;
      (%o2)                G2     := x . y - y . x
                             x, y

  When the last or only function argument x_n is a list of one element, the function defined by `:=` accepts a variable number of arguments.

      (%i1) H ([L]) := apply ("+", L);
      (%o1)                H([L]) := apply("+", L)
      (%i2) H (a, b, c);
      (%o2)                       c + b + a

  `local` makes a local function definition.

      (%i1) foo (x) := 1 - x;
      (%o1)                    foo(x) := 1 - x
      (%i2) foo (100);
      (%o2)                         - 99
      (%i3) block (local (foo), foo (x) := 2 * x, foo (100));
      (%o3)                          200
      (%i4) foo (100);
      (%o4)                         - 99

  Categories: Function definition · Operators

Operator: =

  The equation operator.

  An expression `a = b`, by itself, represents an unevaluated equation, which might or might not hold. Unevaluated equations may appear as arguments to `solve` and `algsys` or some other functions.

  The function `is` evaluates `=` to a Boolean value. `is(a = b)` evaluates `a = b` to `true` when a and b are identical. That is, a and b are atoms which are identical, or they are not atoms and their operators are identical and their arguments are identical. Otherwise, `is(a = b)` evaluates to `false`; it never evaluates to `unknown`. When `is(a = b)` is `true`, a and b are said to be syntactically equal, in contrast to equivalent expressions, for which `is(equal(a, b))` is `true`. Expressions can be equivalent and not syntactically equal.

  The negation of `=` is represented by `#`. As with `=`, an expression `a # b`, by itself, is not evaluated. `is(a # b)` evaluates `a # b` to `true` or `false`.

  In addition to `is`, some other operators evaluate `=` and `#` to `true` or `false`, namely `if`, `and`, `or`, and `not`.

  Note that because of the rules for evaluation of predicate expressions (in particular because `not expr` causes evaluation of expr), `not a = b` is equivalent to `is(a # b)`, instead of `a # b`.

  `rhs` and `lhs` return the right-hand and left-hand sides, respectively, of an equation or inequation.

  See also `equal` and `notequal`.

  Examples:

  An expression `a = b`, by itself, represents an unevaluated equation, which might or might not hold.

      (%i1) eq_1 : a * x - 5 * y = 17;
      (%o1)                    a x - 5 y = 17
      (%i2) eq_2 : b * x + 3 * y = 29;
      (%o2)                    3 y + b x = 29
      (%i3) solve ([eq_1, eq_2], [x, y]);
                              196         29 a - 17 b
      (%o3)          [[x = ---------, y = -----------]]
                           5 b + 3 a       5 b + 3 a
      (%i4) subst (%, [eq_1, eq_2]);
               196 a     5 (29 a - 17 b)
      (%o4) [--------- - --------------- = 17,
             5 b + 3 a      5 b + 3 a
                                        196 b     3 (29 a - 17 b)
                                      --------- + --------------- = 29]
                                      5 b + 3 a      5 b + 3 a
      (%i5) ratsimp (%);
      (%o5)                  [17 = 17, 29 = 29]

  `is(a = b)` evaluates `a = b` to `true` when a and b are syntactically equal (that is, identical). Expressions can be equivalent and not syntactically equal.

      (%i1) a : (x + 1) * (x - 1);
      (%o1)                    (x - 1) (x + 1)
      (%i2) b : x^2 - 1;
                                    2
      (%o2)                        x  - 1
      (%i3) [is (a = b), is (a # b)];
      (%o3)                     [false, true]
      (%i4) [is (equal (a, b)), is (notequal (a, b))];
      (%o4)                     [true, false]

  Some operators evaluate `=` and `#` to `true` or `false`.

      (%i1) if expand ((x + y)^2) = x^2 + 2 * x * y + y^2 then FOO else
            BAR;
      (%o1)                          FOO
      (%i2) eq_3 : 2 * x = 3 * x;
      (%o2)                       2 x = 3 x
      (%i3) eq_4 : exp (2) = %e^2;
                                    2     2
      (%o3)                       %e  = %e
      (%i4) [eq_3 and eq_4, eq_3 or eq_4, not eq_3];
      (%o4)                  [false, true, true]

  Because `not expr` causes evaluation of expr, `not a = b` is equivalent to `is(a # b)`.

      (%i1) [2 * x # 3 * x, not (2 * x = 3 * x)];
      (%o1)                   [2 x # 3 x, true]
      (%i2) is (2 * x # 3 * x);
      (%o2)                         true

  Categories: Operators

Operator: and

  The logical conjunction operator. `and` is an n-ary infix operator; its operands are Boolean expressions, and its result is a Boolean value.

  `and` forces evaluation (like `is`) of one or more operands, and may force evaluation of all operands.

  Operands are evaluated in the order in which they appear. `and` evaluates only as many of its operands as necessary to determine the result. If any operand is `false`, the result is `false` and no further operands are evaluated.

  The global flag `prederror` governs the behavior of `and` when an evaluated operand cannot be determined to be `true` or `false`. `and` prints an error message when `prederror` is `true`. Otherwise, operands which do not evaluate to `true` or `false` are accepted, and the result is a Boolean expression.

  `and` is not commutative: `a and b` might not be equal to `b and a` due to the treatment of indeterminate operands.

  Categories: Operators

Operator: or

  The logical disjunction operator. `or` is an n-ary infix operator; its operands are Boolean expressions, and its result is a Boolean value.

  `or` forces evaluation (like `is`) of one or more operands, and may force evaluation of all operands.

  Operands are evaluated in the order in which they appear. `or` evaluates only as many of its operands as necessary to determine the result. If any operand is `true`, the result is `true` and no further operands are evaluated.

  The global flag `prederror` governs the behavior of `or` when an evaluated operand cannot be determined to be `true` or `false`. `or` prints an error message when `prederror` is `true`. Otherwise, operands which do not evaluate to `true` or `false` are accepted, and the result is a Boolean expression.

  `or` is not commutative: `a or b` might not be equal to `b or a` due to the treatment of indeterminate operands.

  Categories: Operators

Operator: not

  The logical negation operator. `not` is a prefix operator; its operand is a Boolean expression, and its result is a Boolean value.

  `not` forces evaluation (like `is`) of its operand.

  The global flag `prederror` governs the behavior of `not` when its operand cannot be determined to be `true` or `false`. `not` prints an error message when `prederror` is `true`. Otherwise, operands which do not evaluate to `true` or `false` are accepted, and the result is a Boolean expression.

  Categories: Operators

Function: abs (expr)

  Returns the absolute value expr. If expr is complex, returns the complex modulus of expr.

  Categories: Mathematical functions

Keyword: additive

  If `declare(f,additive)` has been executed, then:

  (1) If `f` is univariate, whenever the simplifier encounters `f` applied to a sum, `f` will be distributed over that sum. I.e. `f(y+x)` will simplify to `f(y)+f(x)`.

  (2) If `f` is a function of 2 or more arguments, additivity is defined as additivity in the first argument to `f`, as in the case of `sum` or `integrate`, i.e. `f(h(x)+g(x),x)` will simplify to `f(h(x),x)+f(g(x),x)`. This simplification does not occur when `f` is applied to expressions of the form `sum(x[i],i,lower-limit,upper-limit)`.

  Categories: Operators · Declarations and inferences

Keyword: allbut

  works with the `part` commands (i.e. `part`, `inpart`, `substpart`, `substinpart`, `dpart`, and `lpart`). For example,

      (%i1) expr : e + d + c + b + a;
      (%o1)                   e + d + c + b + a
      (%i2) part (expr, [2, 5]);
      (%o2)                         d + a

  while

      (%i1) expr : e + d + c + b + a;
      (%o1)                   e + d + c + b + a
      (%i2) part (expr, allbut (2, 5));
      (%o2)                       e + c + b

  `allbut` is also recognized by `kill`.

      (%i1) [aa : 11, bb : 22, cc : 33, dd : 44, ee : 55];
      (%o1)                 [11, 22, 33, 44, 55]
      (%i2) kill (allbut (cc, dd));
      (%o0)                         done
      (%i1) [aa, bb, cc, dd];
      (%o1)                   [aa, bb, 33, 44]

  `kill(allbut(a_1, a_2, ...))` has the effect of `kill(all)` except that it does not kill the symbols a_1, a_2, ... .

Declaration: antisymmetric

  If `declare(h,antisymmetric)` is done, this tells the simplifier that `h` is antisymmetric. E.g. `h(x,z,y)` will simplify to `- h(x, y, z)`. That is, it will give (-1)^n times the result given by `symmetric` or `commutative`, where n is the number of interchanges of two arguments necessary to convert it to that form.

  Categories: Operators · Declarations and inferences

Function: cabs (expr)

  Returns the complex absolute value (the complex modulus) of expr.

  Categories: Complex variables

Function: ceiling (x)

  When x is a real number, return the least integer that is greater than or equal to x.

  If x is a constant expression (`10 * %pi`, for example), `ceiling` evaluates x using big floating point numbers, and applies `ceiling` to the resulting big float. Because `ceiling` uses floating point evaluation, it's possible, although unlikely, that `ceiling` could return an erroneous value for constant inputs. To guard against errors, the floating point evaluation is done using three values for `fpprec`.

  For non-constant inputs, `ceiling` tries to return a simplified value. Here are examples of the simplifications that `ceiling` knows about:

      (%i1) ceiling (ceiling (x));
      (%o1)                      ceiling(x)
      (%i2) ceiling (floor (x));
      (%o2)                       floor(x)
      (%i3) declare (n, integer)$
      (%i4) [ceiling (n), ceiling (abs (n)), ceiling (max (n, 6))];
      (%o4)                [n, abs(n), max(n, 6)]
      (%i5) assume (x > 0, x < 1)$
      (%i6) ceiling (x);
      (%o6)                           1
      (%i7) tex (ceiling (a));
      $$\left \lceil a \right \rceil$$
      (%o7)                         false

  The function `ceiling` does not automatically map over lists or matrices. Finally, for all inputs that are manifestly complex, `ceiling` returns a noun form.

  If the range of a function is a subset of the integers, it can be declared to be `integervalued`. Both the `ceiling` and `floor` functions can use this information; for example:

      (%i1) declare (f, integervalued)$
      (%i2) floor (f(x));
      (%o2)                         f(x)
      (%i3) ceiling (f(x) - 1);
      (%o3)                       f(x) - 1

  Categories: Mathematical functions

Function: charfun (p)

  Return 0 when the predicate p evaluates to `false`; return 1 when the predicate evaluates to `true`. When the predicate evaluates to something other than `true` or `false` (unknown), return a noun form.

  Examples:

      (%i1) charfun (x < 1);
      (%o1)                    charfun(x < 1)
      (%i2) subst (x = -1, %);
      (%o2)                           1
      (%i3) e : charfun ('"and" (-1 < x, x < 1))$
      (%i4) [subst (x = -1, e), subst (x = 0, e), subst (x = 1, e)];
      (%o4)                       [0, 1, 0]

  Categories: Mathematical functions

Declaration: commutative

  If `declare(h,commutative)` is done, this tells the simplifier that `h` is a commutative function. E.g. `h(x,z,y)` will simplify to `h(x, y, z)`. This is the same as `symmetric`.

  Categories: Operators · Declarations and inferences

Function: compare (x, y)

  Return a comparison operator op (`<`, `<=`, `>`, `>=`, `=`, or `#`) such that `is (x op y)` evaluates to `true`; when either x or y depends on `%i` and `x # y`, return `notcomparable`; when there is no such operator or Maxima isn't able to determine the operator, return `unknown`.

  Examples:

      (%i1) compare (1, 2);
      (%o1)                           <
      (%i2) compare (1, x);
      (%o2)                        unknown
      (%i3) compare (%i, %i);
      (%o3)                           =
      (%i4) compare (%i, %i + 1);
      (%o4)                     notcomparable
      (%i5) compare (1/x, 0);
      (%o5)                           #
      (%i6) compare (x, abs(x));
      (%o6)                          <=

  The function `compare` doesn't try to determine whether the real domains of its arguments are nonempty; thus

      (%i1) compare (acos (x^2 + 1), acos (x^2 + 1) + 1);
      (%o1)                           <

  The real domain of `acos (x^2 + 1)` is empty.

  Categories: Declarations and inferences

Function: entier (x)

  Returns the largest integer less than or equal to x where x is numeric. `fix` (as in `fixnum`) is a synonym for this, so `fix(x)` is precisely the same.

  Categories: Mathematical functions

Function: equal (a, b)

  Represents equivalence, that is, equal value.

  By itself, `equal` does not evaluate or simplify. The function `is` attempts to evaluate `equal` to a Boolean value. `is(equal(a, b))` returns `true` (or `false`) if and only if a and b are equal (or not equal) for all possible values of their variables, as determined by evaluating `ratsimp(a - b)`; if `ratsimp` returns 0, the two expressions are considered equivalent. Two expressions may be equivalent even if they are not syntactically equal (i.e., identical).

  When `is` fails to reduce `equal` to `true` or `false`, the result is governed by the global flag `prederror`. When `prederror` is `true`, `is` complains with an error message. Otherwise, `is` returns `unknown`.

  In addition to `is`, some other operators evaluate `equal` and `notequal` to `true` or `false`, namely `if`, `and`, `or`, and `not`.

  The negation of `equal` is `notequal`.

  Examples:

  By itself, `equal` does not evaluate or simplify.

      (%i1) equal (x^2 - 1, (x + 1) * (x - 1));
                              2
      (%o1)            equal(x  - 1, (x - 1) (x + 1))
      (%i2) equal (x, x + 1);
      (%o2)                    equal(x, x + 1)
      (%i3) equal (x, y);
      (%o3)                      equal(x, y)

  The function `is` attempts to evaluate `equal` to a Boolean value. `is(equal(a, b))` returns `true` when `ratsimp(a - b)` returns 0. Two expressions may be equivalent even if they are not syntactically equal (i.e., identical).

      (%i1) ratsimp (x^2 - 1 - (x + 1) * (x - 1));
      (%o1)                           0
      (%i2) is (equal (x^2 - 1, (x + 1) * (x - 1)));
      (%o2)                         true
      (%i3) is (x^2 - 1 = (x + 1) * (x - 1));
      (%o3)                         false
      (%i4) ratsimp (x - (x + 1));
      (%o4)                          - 1
      (%i5) is (equal (x, x + 1));
      (%o5)                         false
      (%i6) is (x = x + 1);
      (%o6)                         false
      (%i7) ratsimp (x - y);
      (%o7)                         x - y
      (%i8) is (equal (x, y));
      (%o8)                        unknown
      (%i9) is (x = y);
      (%o9)                         false

  When `is` fails to reduce `equal` to `true` or `false`, the result is governed by the global flag `prederror`.

      (%i1) [aa : x^2 + 2*x + 1, bb : x^2 - 2*x - 1];
                          2             2
      (%o1)             [x  + 2 x + 1, x  - 2 x - 1]
      (%i2) ratsimp (aa - bb);
      (%o2)                        4 x + 2
      (%i3) prederror : true;
      (%o3)                         true
      (%i4) is (equal (aa, bb));
      Maxima was unable to evaluate the predicate:
             2             2
      equal(x  + 2 x + 1, x  - 2 x - 1)
       -- an error.  Quitting.  To debug this try debugmode(true);
      (%i5) prederror : false;
      (%o5)                         false
      (%i6) is (equal (aa, bb));
      (%o6)                        unknown

  Some operators evaluate `equal` and `notequal` to `true` or `false`.

      (%i1) if equal (y, y - 1) then FOO else BAR;
      (%o1)                          BAR
      (%i2) eq_1 : equal (x, x + 1);
      (%o2)                    equal(x, x + 1)
      (%i3) eq_2 : equal (y^2 + 2*y + 1, (y + 1)^2);
                               2                   2
      (%o3)             equal(y  + 2 y + 1, (y + 1) )
      (%i4) [eq_1 and eq_2, eq_1 or eq_2, not eq_1];
      (%o4)                  [false, true, true]

  Because `not expr` causes evaluation of expr, `not equal(a, b)` is equivalent to `is(notequal(a, b))`.

      (%i1) [notequal (2*z, 2*z - 1), not equal (2*z, 2*z - 1)];
      (%o1)            [notequal(2 z, 2 z - 1), true]
      (%i2) is (notequal (2*z, 2*z - 1));
      (%o2)                         true

  Categories: Operators

Function: floor (x)

  When x is a real number, return the largest integer that is less than or equal to x.

  If x is a constant expression (`10 * %pi`, for example), `floor` evaluates x using big floating point numbers, and applies `floor` to the resulting big float. Because `floor` uses floating point evaluation, it's possible, although unlikely, that `floor` could return an erroneous value for constant inputs. To guard against errors, the floating point evaluation is done using three values for `fpprec`.

  For non-constant inputs, `floor` tries to return a simplified value. Here are examples of the simplifications that `floor` knows about:

      (%i1) floor (ceiling (x));
      (%o1)                      ceiling(x)
      (%i2) floor (floor (x));
      (%o2)                       floor(x)
      (%i3) declare (n, integer)$
      (%i4) [floor (n), floor (abs (n)), floor (min (n, 6))];
      (%o4)                [n, abs(n), min(n, 6)]
      (%i5) assume (x > 0, x < 1)$
      (%i6) floor (x);
      (%o6)                           0
      (%i7) tex (floor (a));
      $$\left \lfloor a \right \rfloor$$
      (%o7)                         false

  The function `floor` does not automatically map over lists or matrices. Finally, for all inputs that are manifestly complex, `floor` returns a noun form.

  If the range of a function is a subset of the integers, it can be declared to be `integervalued`. Both the `ceiling` and `floor` functions can use this information; for example:

      (%i1) declare (f, integervalued)$
      (%i2) floor (f(x));
      (%o2)                         f(x)
      (%i3) ceiling (f(x) - 1);
      (%o3)                       f(x) - 1

  Categories: Mathematical functions

Function: notequal (a, b)

  Represents the negation of `equal(a, b)`.

  Examples:

      (%i1) equal (a, b);
      (%o1)                      equal(a, b)
      (%i2) maybe (equal (a, b));
      (%o2)                        unknown
      (%i3) notequal (a, b);
      (%o3)                    notequal(a, b)
      (%i4) not equal (a, b);
      (%o4)                    notequal(a, b)
      (%i5) maybe (notequal (a, b));
      (%o5)                        unknown
      (%i6) assume (a > b);
      (%o6)                        [a > b]
      (%i7) equal (a, b);
      (%o7)                      equal(a, b)
      (%i8) maybe (equal (a, b));
      (%o8)                         false
      (%i9) notequal (a, b);
      (%o9)                    notequal(a, b)
      (%i10) maybe (notequal (a, b));
      (%o10)                        true

  Categories: Operators

Operator: eval

  As an argument in a call to `ev (expr)`, `eval` causes an extra evaluation of expr. See `ev`.

  Categories: Evaluation flags

Function: evenp (expr)

  Returns `true` if expr is an even integer. `false` is returned in all other cases.

  Categories: Predicate functions

Function: fix (x)

  A synonym for `entier (x)`.

  Categories: Mathematical functions

Function: fullmap (f, expr_1, ...)

  Similar to `map`, but `fullmap` keeps mapping down all subexpressions until the main operators are no longer the same.

  `fullmap` is used by the Maxima simplifier for certain matrix manipulations; thus, Maxima sometimes generates an error message concerning `fullmap` even though `fullmap` was not explicitly called by the user.

  Examples:

      (%i1) a + b * c;
      (%o1)                        b c + a
      (%i2) fullmap (g, %);
      (%o2)                   g(b) g(c) + g(a)
      (%i3) map (g, %th(2));
      (%o3)                     g(b c) + g(a)

  Categories: Function application · Expressions

Function: fullmapl (f, list_1, ...)

  Similar to `fullmap`, but `fullmapl` only maps onto lists and matrices.

  Example:

      (%i1) fullmapl ("+", [3, [4, 5]], [[a, 1], [0, -1.5]]);
      (%o1)                [[a + 3, 4], [4, 3.5]]

  Categories: Function application · Expressions

Function: is (expr)

  Attempts to determine whether the predicate expr is provable from the facts in the `assume` database.

  If the predicate is provably `true` or `false`, `is` returns `true` or `false`, respectively. Otherwise, the return value is governed by the global flag `prederror`. When `prederror` is `true`, `is` complains with an error message. Otherwise, `is` returns `unknown`.

  `ev(expr, pred)` (which can be written `expr, pred` at the interactive prompt) is equivalent to `is(expr)`.

  See also `assume`, `facts`, and `maybe`.

  Examples:

  `is` causes evaluation of predicates.

      (%i1) %pi > %e;
      (%o1)                       %pi > %e
      (%i2) is (%pi > %e);
      (%o2)                         true

  `is` attempts to derive predicates from the `assume` database.

      (%i1) assume (a > b);
      (%o1)                        [a > b]
      (%i2) assume (b > c);
      (%o2)                        [b > c]
      (%i3) is (a < b);
      (%o3)                         false
      (%i4) is (a > c);
      (%o4)                         true
      (%i5) is (equal (a, c));
      (%o5)                         false

  If `is` can neither prove nor disprove a predicate from the `assume` database, the global flag `prederror` governs the behavior of `is`.

      (%i1) assume (a > b);
      (%o1)                        [a > b]
      (%i2) prederror: true$
      (%i3) is (a > 0);
      Maxima was unable to evaluate the predicate:
      a > 0
       -- an error.  Quitting.  To debug this try debugmode(true);
      (%i4) prederror: false$
      (%i5) is (a > 0);
      (%o5)                        unknown

  Categories: Predicate functions · Declarations and inferences

Function: maybe (expr)

  Attempts to determine whether the predicate expr is provable from the facts in the `assume` database.

  If the predicate is provably `true` or `false`, `maybe` returns `true` or `false`, respectively. Otherwise, `maybe` returns `unknown`.

  `maybe` is functionally equivalent to `is` with `prederror: false`, but the result is computed without actually assigning a value to `prederror`.

  See also `assume`, `facts`, and `is`.

  Examples:

      (%i1) maybe (x > 0);
      (%o1)                        unknown
      (%i2) assume (x > 1);
      (%o2)                        [x > 1]
      (%i3) maybe (x > 0);
      (%o3)                         true

  Categories: Predicate functions · Declarations and inferences

Function: isqrt (x)

  Returns the "integer square root" of the absolute value of x, which is an integer.

  Categories: Mathematical functions

Function: lmax (L)

  When L is a list or a set, return `apply ('max, args (L))`. When L isn't a list or a set, signal an error.

  Categories: Mathematical functions · Lists · Sets

Function: lmin (L)

  When L is a list or a set, return `apply ('min, args (L))`. When L isn't a list or a set, signal an error.

  Categories: Mathematical functions · Lists · Sets

Function: max (x_1, ..., x_n)

  Return a simplified value for the maximum of the expressions x_1 through x_n. When `get (trylevel, maxmin)`, is 2 or greater, `max` uses the simplification `max (e, -e) --> |e|`. When `get (trylevel, maxmin)` is 3 or greater, max tries to eliminate expressions that are between two other arguments; for example, `max (x, 2*x, 3*x) --> max (x, 3*x)`. To set the value of `trylevel` to 2, use `put (trylevel, 2, maxmin)`.

  Categories: Mathematical functions

Function: min (x_1, ..., x_n)

  Return a simplified value for the minimum of the expressions `x_1` through `x_n`. When `get (trylevel, maxmin)`, is 2 or greater, `min` uses the simplification `min (e, -e) --> -|e|`. When `get (trylevel, maxmin)` is 3 or greater, `min` tries to eliminate expressions that are between two other arguments; for example, `min (x, 2*x, 3*x) --> min (x, 3*x)`. To set the value of `trylevel` to 2, use `put (trylevel, 2, maxmin)`.

  Categories: Mathematical functions

Function: polymod (p)
Function: polymod (p, m)

  Converts the polynomial p to a modular representation with respect to the current modulus which is the value of the variable `modulus`.

  `polymod (p, m)` specifies a modulus m to be used instead of the current value of `modulus`.

  See `modulus`.

  Categories: Polynomials

Function: mod (x, y)

  If x and y are real numbers and y is nonzero, return `x - y * floor(x / y)`. Further for all real x, we have `mod (x, 0) = x`. For a discussion of the definition `mod (x, 0) = x`, see Section 3.4, of "Concrete Mathematics," by Graham, Knuth, and Patashnik. The function `mod (x, 1)` is a sawtooth function with period 1 with `mod (1, 1) = 0` and `mod (0, 1) = 0`.

  To find the principal argument (a number in the interval `(-%pi, %pi]`) of a complex number, use the function `x |-> %pi - mod (%pi - x, 2*%pi)`, where x is an argument.

  When x and y are constant expressions (`10 * %pi`, for example), `mod` uses the same big float evaluation scheme that `floor` and `ceiling` uses. Again, it's possible, although unlikely, that `mod` could return an erroneous value in such cases.

  For nonnumerical arguments x or y, `mod` knows several simplification rules:

      (%i1) mod (x, 0);
      (%o1)                           x
      (%i2) mod (a*x, a*y);
      (%o2)                      a mod(x, y)
      (%i3) mod (0, x);
      (%o3)                           0

  Categories: Mathematical functions

Function: oddp (expr)

  is `true` if expr is an odd integer. `false` is returned in all other cases.

  Categories: Predicate functions

Operator: pred

  As an argument in a call to `ev (expr)`, `pred` causes predicates (expressions which evaluate to `true` or `false`) to be evaluated. See `ev`.

  Categories: Evaluation flags

Function: make_random_state (n)
Function: make_random_state (s)
Function: make_random_state (true)
Function: make_random_state (false)

  A random state object represents the state of the random number generator. The state comprises 627 32-bit words.

  `make_random_state (n)` returns a new random state object created from an integer seed value equal to n modulo 2^32. n may be negative.

  `make_random_state (s)` returns a copy of the random state s.

  `make_random_state (true)` returns a new random state object, using the current computer clock time as the seed.

  `make_random_state (false)` returns a copy of the current state of the random number generator.

  Categories: Random numbers

Function: set_random_state (s)

  Copies s to the random number generator state.

  `set_random_state` always returns `done`.

  Categories: Random numbers

Function: random (x)

  Returns a pseudorandom number. If x is an integer, `random (x)` returns an integer from 0 through `x - 1` inclusive. If x is a floating point number, `random (x)` returns a nonnegative floating point number less than x. `random` complains with an error if x is neither an integer nor a float, or if x is not positive.

  The functions `make_random_state` and `set_random_state` maintain the state of the random number generator.

  The Maxima random number generator is an implementation of the Mersenne twister MT 19937.

  Examples:

      (%i1) s1: make_random_state (654321)$
      (%i2) set_random_state (s1);
      (%o2)                         done
      (%i3) random (1000);
      (%o3)                          768
      (%i4) random (9573684);
      (%o4)                        7657880
      (%i5) random (2^75);
      (%o5)                11804491615036831636390
      (%i6) s2: make_random_state (false)$
      (%i7) random (1.0);
      (%o7)                   .2310127244107132
      (%i8) random (10.0);
      (%o8)                   4.394553645870825
      (%i9) random (100.0);
      (%o9)                   32.28666704056853
      (%i10) set_random_state (s2);
      (%o10)                        done
      (%i11) random (1.0);
      (%o11)                  .2310127244107132
      (%i12) random (10.0);
      (%o12)                  4.394553645870825
      (%i13) random (100.0);
      (%o13)                  32.28666704056853

  Categories: Random numbers · Numerical methods

Function: rationalize (expr)

  Convert all double floats and big floats in the Maxima expression expr to their exact rational equivalents. If you are not familiar with the binary representation of floating point numbers, you might be surprised that `rationalize (0.1)` does not equal 1/10. This behavior isn't special to Maxima - the number 1/10 has a repeating, not a terminating, binary representation.

      (%i1) rationalize (0.5);
                                      1
      (%o1)                           -
                                      2
      (%i2) rationalize (0.1);
                                     1
      (%o2)                          --
                                     10
      (%i3) fpprec : 5$
      (%i4) rationalize (0.1b0);
                                   209715
      (%o4)                        -------
                                   2097152
      (%i5) fpprec : 20$
      (%i6) rationalize (0.1b0);
                           236118324143482260685
      (%o6)                ----------------------
                           2361183241434822606848
      (%i7) rationalize (sin (0.1*x + 5.6));
                                    x    28
      (%o7)                     sin(-- + --)
                                    10   5

  Example use:

      (%i1) unitfrac(r) := block([uf : [], q],
          if not(ratnump(r)) then
             error("The input to 'unitfrac' must be a rational number"),
          while r # 0 do (
              uf : cons(q : 1/ceiling(1/r), uf),
              r : r - q),
          reverse(uf));
      (%o1) unitfrac(r) := block([uf : [], q],
      if not ratnump(r) then
         error("The input to 'unitfrac' must be a rational number"),
                                        1
      while r # 0 do (uf : cons(q : ----------, uf), r : r - q),
                                            1
                                    ceiling(-)
                                            r
      reverse(uf))
      (%i2) unitfrac (9/10);
                                  1  1  1
      (%o2)                      [-, -, --]
                                  2  3  15
      (%i3) apply ("+", %);
                                     9
      (%o3)                          --
                                     10
      (%i4) unitfrac (-9/10);
                                        1
      (%o4)                       [- 1, --]
                                        10
      (%i5) apply ("+", %);
                                      9
      (%o5)                         - --
                                      10
      (%i6) unitfrac (36/37);
                              1  1  1  1    1
      (%o6)                  [-, -, -, --, ----]
                              2  3  8  69  6808
      (%i7) apply ("+", %);
                                     36
      (%o7)                          --
                                     37

  Categories: Numerical evaluation

Function: round (x)

  When x is a real number, returns the closest integer to x. Multiples of 1/2 are rounded to the nearest even integer. Evaluation of x is similar to `floor` and `ceiling`.

  Categories: Mathematical functions

Function: sign (expr)

  Attempts to determine the sign of expr on the basis of the facts in the current data base. It returns one of the following answers: `pos` (positive), `neg` (negative), `zero`, `pz` (positive or zero), `nz` (negative or zero), `pn` (positive or negative), or `pnz` (positive, negative, or zero, i.e. nothing known).

  Categories: Declarations and inferences

Function: signum (x)

  For numeric x, returns 0 if x is 0, otherwise returns -1 or +1 as x is less than or greater than 0, respectively.

  If x is not numeric then a simplified but equivalent form is returned. For example, `signum(-x)` gives `-signum(x)`.

  Categories: Mathematical functions

Function: sort (L, P)
Function: sort (L)

  Sorts a list L according to a predicate `P` of two arguments, such that `P (L[k], L[k + 1])` is `true` for any two successive elements. The predicate may be specified as the name of a function or binary infix operator, or as a `lambda` expression. If specified as the name of an operator, the name is enclosed in "double quotes".

  The sorted list is returned as a new object; the argument L is not modified. To construct the return value, `sort` makes a shallow copy of the elements of L.

  If the predicate P is not a total order on the elements of L, then `sort` might run to completion without error, but the result is undefined. `sort` complains if the predicate evaluates to something other than `true` or `false`.

  `sort (L)` is equivalent to `sort (L, orderlessp)`. That is, the default sorting order is ascending, as determined by `orderlessp`. All Maxima atoms and expressions are comparable under `orderlessp`, although there are isolated examples of expressions for which `orderlessp` is not transitive; this is a bug.

  Examples:

      (%i1) sort ([11, -17, 29b0, 7.55, 3, -5/2, b + a, 9 * c,
            19 - 3 * x]);
                     5
      (%o1) [- 17, - -, 3, 7.55, 11, 2.9b1, b + a, 9 c, 19 - 3 x]
                     2
      (%i2) sort ([11, -17, 29b0, 7.55, 3, -5/2, b + a, 9*c, 19 - 3*x],
            ordergreatp);
                                                         5
      (%o2) [19 - 3 x, 9 c, b + a, 2.9b1, 11, 7.55, 3, - -, - 17]
                                                         2
      (%i3) sort ([%pi, 3, 4, %e, %gamma]);
      (%o3)                [3, 4, %e, %gamma, %pi]
      (%i4) sort ([%pi, 3, 4, %e, %gamma], "<");
      (%o4)                [%gamma, %e, 3, %pi, 4]
      (%i5) my_list: [[aa,hh,uu], [ee,cc], [zz,xx,mm,cc], [%pi,%e]];
      (%o5) [[aa, hh, uu], [ee, cc], [zz, xx, mm, cc], [%pi, %e]]
      (%i6) sort (my_list);
      (%o6) [[%pi, %e], [aa, hh, uu], [ee, cc], [zz, xx, mm, cc]]
      (%i7) sort (my_list, lambda ([a, b], orderlessp (reverse (a),
            reverse (b))));
      (%o7) [[%pi, %e], [ee, cc], [zz, xx, mm, cc], [aa, hh, uu]]

  Categories: Lists

Function: sqrt (x)

  The square root of x. It is represented internally by `x^(1/2)`. See also `rootscontract`.

  `radexpand` if `true` will cause nth roots of factors of a product which are powers of n to be pulled outside of the radical, e.g. `sqrt(16*x^2)` will become `4*x` only if `radexpand` is `true`.

  Categories: Mathematical functions

Option variable: sqrtdispflag

  Default value: `true`

  When `sqrtdispflag` is `false`, causes `sqrt` to display with exponent 1/2.

  Categories: Mathematical functions · Display flags and variables

Function: sublis (list, expr)

  Makes multiple parallel substitutions into an expression.

  The variable `sublis_apply_lambda` controls simplification after `sublis`.

  Example:

      (%i1) sublis ([a=b, b=a], sin(a) + cos(b));
      (%o1)                    sin(b) + cos(a)

  Categories: Expressions

Function: sublist (list, p)

  Returns the list of elements of list for which the predicate `p` returns `true`.

  Example:

      (%i1) L: [1, 2, 3, 4, 5, 6];
      (%o1)                  [1, 2, 3, 4, 5, 6]
      (%i2) sublist (L, evenp);
      (%o2)                       [2, 4, 6]

  Categories: Lists

Option variable: sublis_apply_lambda

  Default value: `true`

  Controls whether `lambda`'s substituted are applied in simplification after `sublis` is used or whether you have to do an `ev` to get things to apply. `true` means do the application.

  Categories: Expressions

Function: subst (a, b, c)

  Substitutes a for b in c. b must be an atom or a complete subexpression of c. For example, `x+y+z` is a complete subexpression of `2*(x+y+z)/w` while `x+y` is not. When b does not have these characteristics, one may sometimes use `substpart` or `ratsubst` (see below). Alternatively, if b is of the form `e/f` then one could use `subst (a*f, e, c)` while if b is of the form `e^(1/f)` then one could use `subst (a^f, e, c)`. The `subst` command also discerns the `x^y` in `x^-y` so that `subst (a, sqrt(x), 1/sqrt(x))` yields `1/a`. a and b may also be operators of an expression enclosed in double-quotes `"` or they may be function names. If one wishes to substitute for the independent variable in derivative forms then the `at` function (see below) should be used.

  `subst` is an alias for `substitute`.

  `subst (eq_1, expr)` or `subst ([eq_1, ..., eq_k], expr)` are other permissible forms. The eq_i are equations indicating substitutions to be made. For each equation, the right side will be substituted for the left in the expression expr.

  `exptsubst` if `true` permits substitutions like `y` for `%e^x` in `%e^(a*x)` to take place.

  When `opsubst` is `false`, `subst` will not attempt to substitute into the operator of an expression. E.g. `(opsubst: false, subst (x^2, r, r+r[0]))` will work.

  Examples:

      (%i1) subst (a, x+y, x + (x+y)^2 + y);
                                          2
      (%o1)                      y + x + a
      (%i2) subst (-%i, %i, a + b*%i);
      (%o2)                       a - %i b

  For further examples, do `example (subst)`.

  Categories: Expressions

Function: substinpart (x, expr, n_1, ..., n_k)

  Similar to `substpart`, but `substinpart` works on the internal representation of expr.

  Examples:

      (%i1) x . 'diff (f(x), x, 2);
                                    2
                                   d
      (%o1)                   x . (--- (f(x)))
                                     2
                                   dx
      (%i2) substinpart (d^2, %, 2);
                                        2
      (%o2)                        x . d
      (%i3) substinpart (f1, f[1](x + 1), 0);
      (%o3)                       f1(x + 1)

  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

      (%i1) part (x + y + z, [1, 3]);
      (%o1)                         z + x

  `piece` holds the value of 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.

      (%i1) expr: 27*y^3 + 54*x*y^2 + 36*x^2*y + y + 8*x^3 + x + 1;
                    3         2       2            3
      (%o1)     27 y  + 54 x y  + 36 x  y + y + 8 x  + x + 1
      (%i2) part (expr, 2, [1, 3]);
                                        2
      (%o2)                         54 y
      (%i3) sqrt (piece/54);
      (%o3)                        abs(y)
      (%i4) substpart (factor (piece), expr, [1, 2, 3, 5]);
                                     3
      (%o4)               (3 y + 2 x)  + y + x + 1
      (%i5) expr: 1/x + y/x - 1/z;
                                   1   y   1
      (%o5)                      - - + - + -
                                   z   x   x
      (%i6) substpart (xthru (piece), expr, [2, 3]);
                                  y + 1   1
      (%o6)                       ----- - -
                                    x     z

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

  Categories: Expressions

Function: substpart (x, expr, n_1, ..., n_k)

  Substitutes x for the subexpression picked out by the rest of the arguments as in `part`. It returns the new value of expr. x may be some operator to be substituted for an operator of expr. In some cases x needs to be enclosed in double-quotes `"` (e.g. `substpart ("+", a*b, 0)` yields `b + a`).

      (%i1) 1/(x^2 + 2);
                                     1
      (%o1)                        ------
                                    2
                                   x  + 2
      (%i2) substpart (3/2, %, 2, 1, 2);
                                     1
      (%o2)                       --------
                                   3/2
                                  x    + 2
      (%i3) a*x + f(b, y);
      (%o3)                     a x + f(b, y)
      (%i4) substpart ("+", %, 1, 0);
      (%o4)                    x + f(b, y) + a

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

  Categories: Expressions

Function: subvarp (expr)

  Returns `true` if expr is a subscripted variable, for example `a[i]`.

  Categories: Predicate functions

Function: symbolp (expr)

  Returns `true` if expr is a symbol, else `false`. In effect, `symbolp(x)` is equivalent to the predicate `atom(x) and not numberp(x)`.

  See also Identifiers.

  Categories: Predicate functions

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`. See also `ordergreat` and `orderless`.

  Examples:

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

  Categories: Expressions

Function: vectorpotential (givencurl)

  Returns the vector potential of a given curl vector, in the current coordinate system. `potentialzeroloc` has a similar role as for `potential`, but the order of the left-hand sides of the equations must be a cyclic permutation of the coordinate variables.

  Categories: Package vect

Function: xthru (expr)

  Combines all terms of expr (which should be a sum) over a common denominator without expanding products and exponentiated sums as `ratsimp` does. `xthru` cancels common factors in the numerator and denominator of rational expressions but only if the factors are explicit.

  Sometimes it is better to use `xthru` before `ratsimp`ing an expression in order to cause explicit factors of the gcd of the numerator and denominator to be canceled thus simplifying the expression to be `ratsimp`ed.

      (%i1) ((x+2)^20 - 2*y)/(x+y)^20 + (x+y)^(-19) - x/(x+y)^20;
                                      20
                       1       (x + 2)   - 2 y       x
      (%o1)        --------- + --------------- - ---------
                          19             20             20
                   (y + x)        (y + x)        (y + x)
      (%i2) xthru (%);
                                       20
                                (x + 2)   - y
      (%o2)                     -------------
                                         20
                                  (y + x)

  Categories: Expressions

Function: zeroequiv (expr, v)

  Tests whether the expression expr in the variable v is equivalent to zero, returning `true`, `false`, or `dontknow`.

  `zeroequiv` has these restrictions:

  1. Do not use functions that Maxima does not know how to differentiate and evaluate.
  2. If the expression has poles on the real line, there may be errors in the result (but this is unlikely to occur).
  3. If the expression contains functions which are not solutions to first order differential equations (e.g. Bessel functions) there may be incorrect results.
  4. The algorithm uses evaluation at randomly chosen points for carefully selected subexpressions. This is always a somewhat hazardous business, although the algorithm tries to minimize the potential for error.

  For example `zeroequiv (sin(2*x) - 2*sin(x)*cos(x), x)` returns `true` and `zeroequiv (%e^x + x, x)` returns `false`. On the other hand `zeroequiv (log(a*b) - log(a) - log(b), a)` returns `dontknow` because of the presence of an extra parameter `b`.

  Categories: Predicate functions

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

This document was generated by Robert Dodier on August, 24 2008 using texi2html 1.76.