Maxima 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.
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 .
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 .
bindtest
Tells Maxima to trigger an error when a_i is evaluated unbound.
noun
Tells Maxima to parse a_i as a noun.
The effect of this is to replace instances of a_i with 'a_i
or nounify(a_i)
, depending on the context.
constant
Tells Maxima to consider a_i a symbolic constant.
scalar
Tells Maxima to consider a_i a scalar variable.
nonscalar
Tells Maxima to consider a_i a nonscalar variable. The usual application is to declare a variable as a symbolic vector or matrix.
mainvar
Tells Maxima to consider a_i a "main variable" (mainvar
).
ordergreatp
determines the ordering of atoms as follows:
(main variables) > (other variables) > (scalar variables) > (constants) > (numbers)
alphabetic
Tells Maxima to recognize all characters in a_i (which must be a string) as alphabetic characters.
feature
Tells Maxima to recognize a_i as the name of a feature. Other atoms may then be declared to have the a_i property.
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)
.
Tells Maxima to recognize a_i as a symmetric or antisymmetric function.
commutative
is the same as symmetric
.
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
.
Tells Maxima to recognize a_i as an integer or noninteger variable.
Tells Maxima to recognize a_i as an even or odd integer variable.
Tells Maxima to recognize a_i as a rational or irrational real variable.
Tells Maxima to recognize a_i as a real, pure imaginary, or complex variable.
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.