Next: , Previous: , Up: Maxima’s Database   [Contents][Index]

11.2 Functions and Variables for Properties

Property: alphabetic

alphabetic is a property type recognized by declare. The expression declare(s, alphabetic) tells Maxima to recognize as alphabetic all of the characters in s, which must be a string.

See also Identifiers.

Example:

(%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~]
Property: bindtest

The command declare(x, bindtest) tells Maxima to trigger an error when the symbol x is evaluated unbound.

(%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
Property: constant

declare(a, constant) declares a to be a constant. The declaration of a symbol to be constant does not prevent the assignment of a nonconstant value to the symbol.

See constantp and declare.

Example:

(%i1) declare(c, constant);
(%o1)                         done
(%i2) constantp(c);
(%o2)                         true
(%i3) c : x;
(%o3)                           x
(%i4) constantp(c);
(%o4)                         false
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.

See the property constant which declares a symbol to be constant.

Examples:

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

Assigns the atom or list of atoms a_i the property or list of properties p_i. When a_i and/or p_i are lists, each of the atoms gets all of the properties.

declare quotes its arguments. declare always returns done.

As noted in the description for each declaration flag, for some flags featurep(object, feature) returns true if object has been declared to have feature.

For more information about the features system, see features. To remove a property from an atom, use remove.

declare recognizes the following properties:

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.

alphabetic

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

antisymmetric, commutative, symmetric

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

bindtest

Tells Maxima to trigger an error when a_i is evaluated unbound.

constant

Tells Maxima to consider a_i a symbolic constant.

even, odd

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

evenfun, oddfun

Tells Maxima to recognize a_i as an odd or even function.

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.

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.

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.

increasing, decreasing

Tells Maxima to recognize a_i as an increasing or decreasing function.

integer, noninteger

Tells Maxima to recognize a_i as an integer or noninteger variable.

integervalued

Tells Maxima to recognize a_i as an integer-valued function.

lassociative, rassociative

Tells Maxima to recognize a_i as a right-associative or left-associative function.

linear

Equivalent to declaring a_i both outative and additive.

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.

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.

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

nonarray

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

nonscalar

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

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.

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.

posfun

Tells Maxima to recognize a_i as a positive function.

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.

scalar

Tells Maxima to consider a_i a scalar variable.

Examples of the usage of the properties are available in the documentation for each separate description of a property.

Property: decreasing
Property: increasing

The commands declare(f, decreasing) or declare(f, increasing) tell Maxima to recognize the function f as an decreasing or increasing function.

See also declare for more properties.

Example:

(%i1) assume(a > b);
(%o1)                        [a > b]
(%i2) is(f(a) > f(b));
(%o2)                        unknown
(%i3) declare(f, increasing);
(%o3)                         done
(%i4) is(f(a) > f(b));
(%o4)                         true
Property: even
Property: odd

declare(a, even) or declare(a, odd) tells Maxima to recognize the symbol a as an even or odd integer variable. The properties even and odd are not recognized by the functions evenp, oddp, and integerp.

See also declare and askinteger.

Example:

(%i1) declare(n, even);
(%o1)                         done
(%i2) askinteger(n, even);
(%o2)                          yes
(%i3) askinteger(n);
(%o3)                          yes
(%i4) evenp(n);
(%o4)                         false
Property: feature

Maxima understands two distinct types of features, system features and features which apply to mathematical expressions. See also status for information about system features. See also features and featurep for information about mathematical features.

feature itself is not the name of a function or variable.

Function: featurep (a, f)

Attempts to determine whether the object a has the feature f on the basis of the facts in the current database. If so, it returns true, else false.

Note that featurep returns false when neither f nor the negation of f can be established.

featurep evaluates its argument.

See also declare and features.

(%i1) declare (j, even)$
(%i2) featurep (j, integer);
(%o2)                           true
Declaration: features

Maxima recognizes certain mathematical properties of functions and variables. These are called "features".

declare (x, foo) gives the property foo to the function or variable x.

declare (foo, feature) declares a new feature foo. For example, declare ([red, green, blue], feature) declares three new features, red, green, and blue.

The predicate featurep (x, foo) returns true if x has the foo property, and false otherwise.

The infolist features is a list of known features. These are

   integer        noninteger      even
   odd            rational        irrational
   real           imaginary       complex
   analytic       increasing      decreasing
   oddfun         evenfun         posfun
   constant       commutative     lassociative
   rassociative   symmetric       antisymmetric
   integervalued

plus any user-defined features.

features is a list of mathematical features. There is also a list of non-mathematical, system-dependent features. See status.

Example:

(%i1) declare (FOO, feature);
(%o1)                         done
(%i2) declare (x, FOO);
(%o2)                         done
(%i3) featurep (x, FOO);
(%o3)                         true
Function: get (a, i)

Retrieves the user property indicated by i associated with atom a or returns false if a doesn’t have property i.

get evaluates its arguments.

See also put and qput.

(%i1) put (%e, 'transcendental, 'type);
(%o1)                    transcendental
(%i2) put (%pi, 'transcendental, 'type)$
(%i3) put (%i, 'algebraic, 'type)$
(%i4) typeof (expr) := block ([q],
        if numberp (expr)
        then return ('algebraic),
        if not atom (expr)
        then return (maplist ('typeof, expr)),
        q: get (expr, 'type),
        if q=false
        then errcatch (error(expr,"is not numeric.")) else q)$
(%i5) typeof (2*%e + x*%pi);
x is not numeric.
(%o5)  [[transcendental, []], [algebraic, transcendental]]
(%i6) typeof (2*%e + %pi);
(%o6)     [transcendental, [algebraic, transcendental]]
Property: integer
Property: noninteger

declare(a, integer) or declare(a, noninteger) tells Maxima to recognize a as an integer or noninteger variable.

See also declare.

Example:

(%i1) declare(n, integer, x, noninteger);
(%o1)                         done
(%i2) askinteger(n);
(%o2)                          yes
(%i3) askinteger(x);
(%o3)                          no
Property: integervalued

declare(f, integervalued) tells Maxima to recognize f as an integer-valued function.

See also declare.

Example:

(%i1) exp(%i)^f(x);
                              %i f(x)
(%o1)                      (%e  )
(%i2) declare(f, integervalued);
(%o2)                         done
(%i3) exp(%i)^f(x);
                              %i f(x)
(%o3)                       %e
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.

See also declare.

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
Categories: Expressions ·
Property: nonscalar

Makes atoms behave as does a list or matrix with respect to the dot operator.

See also declare.

Function: nonscalarp (expr)

Returns true if expr is a non-scalar, i.e., it contains atoms declared as non-scalars, lists, or matrices.

See also the predicate function scalarp and declare.

Property: posfun

declare (f, posfun) declares f to be a positive function. is (f(x) > 0) yields true.

See also declare.

Function: printprops
    printprops (a, i)
    printprops ([a_1, …, a_n], i)
    printprops (all, i)

Displays the property with the indicator i associated with the atom a. a may also be a list of atoms or the atom all in which case all of the atoms with the given property will be used. For example, printprops ([f, g], atvalue). printprops is for properties that cannot otherwise be displayed, i.e. for atvalue, atomgrad, gradef, and matchdeclare.

Function: properties (a)

Returns a list of the names of all the properties associated with the atom a.

System variable: props

Default value: []

props are atoms which have any property other than those explicitly mentioned in infolists, such as specified by atvalue, matchdeclare, etc., as well as properties specified in the declare function.

Function: propvars (prop)

Returns a list of those atoms on the props list which have the property indicated by prop. Thus propvars (atvalue) returns a list of atoms which have atvalues.

Function: put (atom, value, indicator)

Assigns value to the property (specified by indicator) of atom. indicator may be the name of any property, not just a system-defined property.

rem reverses the effect of put.

put evaluates its arguments. put returns value.

See also qput and get.

Examples:

(%i1) put (foo, (a+b)^5, expr);
                                   5
(%o1)                       (b + a)
(%i2) put (foo, "Hello", str);
(%o2)                         Hello
(%i3) properties (foo);
(%o3)            [[user properties, str, expr]]
(%i4) get (foo, expr);
                                   5
(%o4)                       (b + a)
(%i5) get (foo, str);
(%o5)                         Hello
Function: qput (atom, value, indicator)

Assigns value to the property (specified by indicator) of atom. This is the same as put, except that the arguments are quoted.

See also get.

Example:

(%i1) foo: aa$ 
(%i2) bar: bb$
(%i3) baz: cc$
(%i4) put (foo, bar, baz);
(%o4)                          bb
(%i5) properties (aa);
(%o5)                [[user properties, cc]]
(%i6) get (aa, cc);
(%o6)                          bb
(%i7) qput (foo, bar, baz);
(%o7)                          bar
(%i8) properties (foo);
(%o8)            [value, [user properties, baz]]
(%i9) get ('foo, 'baz);
(%o9)                          bar
Property: rational
Property: irrational

declare(a, rational) or declare(a, irrational) tells Maxima to recognize a as a rational or irrational real variable.

See also declare.

Property: real
Property: imaginary
Property: complex

declare(a, real), declare(a, imaginary), or declare(a, complex) tells Maxima to recognize a as a real, pure imaginary, or complex variable.

See also declare.

Function: rem (atom, indicator)

Removes the property indicated by indicator from atom. rem reverses the effect of put.

rem returns done if atom had an indicator property when rem was called, or false if it had no such property.

Function: remove
    remove (a_1, p_1, …, a_n, p_n)
    remove ([a_1, …, a_m], [p_1, …, p_n], …)
    remove ("a", operator)
    remove (a, transfun)
    remove (all, p)

Removes properties associated with atoms.

remove (a_1, p_1, ..., a_n, p_n) removes property p_k from atom a_k.

remove ([a_1, ..., a_m], [p_1, ..., p_n], ...) removes properties p_1, ..., p_n from atoms a_1, …, a_m. There may be more than one pair of lists.

remove (all, p) removes the property p from all atoms which have it.

The removed properties may be system-defined properties such as function, macro, or mode_declare. remove does not remove properties defined by put.

A property may be transfun to remove the translated Lisp version of a function. After executing this, the Maxima version of the function is executed rather than the translated version.

remove ("a", operator) or, equivalently, remove ("a", op) removes from a the operator properties declared by prefix, infix, nary, postfix, matchfix, or nofix. Note that the name of the operator must be written as a quoted string.

remove always returns done whether or not an atom has a specified property. This behavior is unlike the more specific remove functions remvalue, remarray, remfunction, and remrule.

remove quotes its arguments.

Property: scalar

declare(a, scalar) tells Maxima to consider a a scalar variable.

See also declare.

Function: scalarp (expr)

Returns true if expr is a number, constant, or variable declared scalar with declare, or composed entirely of numbers, constants, and such variables, but not containing matrices or lists.

See also the predicate function nonscalarp.


Next: , Previous: , Up: Maxima’s Database   [Contents][Index]