define characteristics of an operator name
define(oper, rule1, rule2, ...)
definemore(oper, rule1, rule2, ...)
name of the operator being defined
rule1, rule2, ...
one or more key names of a property, or an equation that defines a rule
list; a list of equational rules, or property keywords
The define command defines procedures by means of rules. To define a procedure by using the define command, you specify the name of the procedure and rules that it must obey using the syntax of patmatch. The left-hand side of each defining equation must contain the name of the defined procedure. In addition, there are several property names that can be used as abbreviations for common constructions.
The name passed as the first argument to define must not be assigned. Therefore, to change the definition of a procedure defined using define use instead the redefine command, described below.
A procedure defined using define can be specialized further, adding more rules and properties to its definition, by using the definemore command. Its syntax is the same as for the define command, but the rules or properties are added to the definition of the defined procedure rather than replacing them.
The define command is not able in all cases to detect if some rules are contradictory, or may result in a non-terminating program.
A procedure defined using define does not automatically respect assumptions. However, you can use assumptions within a conditional pattern.
A rule can be an equational rule specified using the syntax of patmatch, or one of the reserved words linear, multilinear, orderless, flat, identity, zero, and diff, which name a property. The meanings of these reserved words are as follows.
The linear property causes the defined procedure to be linear in its first argument.
The multilinear property causes the defined procedure to be a multilinear function, that is, it is linear in each argument, independently.
The orderless property causes the defined procedure to be constant on permutations of its arguments. For two-argument procedures, this corresponds to commutativity.
The flat property causes the defined procedure to be associative.
The identity property is used to name an identity element for a two-argument procedure (or binary operation). It is used by specifying an equation of the form identity=EXPR, where EXPR is the expression that is to serve as an identity element.
The zero option is used to specify a zero of the defined procedure. It is used by specifying an equation of the form zero=EXPR, where EXPR is the expression that is to be a zero of the defined procedure.
The rules defining a procedure may include the specification of the derivative of the defined procedure. If the procedure name being defined is F, then its derivative must be specified in the form ⅆⅆxF⁡x=EXPR, where EXPR is an expression (which may depend on x) for the derivative of F.
If a function F has been created with define, you can remove its definition by calling undefine⁡F. (In many cases, simply unassign F will suffice, but in general, undefine must be used.)
A function name can be changed by using the redefine command. It takes exactly two arguments: the name of the function to be redefined, and a list of the defining properties that would be passed as subsequent arguments to define in a fresh definition.
Define a commutative and associative operation.
You can use define to program recursive procedures.
An example of programming a one-line GCD.
The identity property can be used to define a monoid operation.
a &x b &x c
a &x 1
1 &x b
A simple integrator can be defined as follows.
This definition works for any variable.
Use definemore to improve the integrator.
definemore⁡INT,'conditional'⁡INT⁡1a::algebraic⁢X::name+b::algebraic,X::name=ln⁡a⁢X+b,_type⁡a,freeof⁡X &and _type⁡b,freeof⁡X
definemore⁡INT,'conditional'⁡INT⁡sin⁡a::algebraic⁢X::name+b::algebraic,X::name=−1⁢cos⁡a⁢x+ba,_type⁡a,freeof⁡X &and _type⁡b,freeof⁡X
Note: If INT does not recognize the pattern, it returns unevaluated.
The following example defined the procedure P by specifying its derivative.
If the derivative is specified for a procedure defined using the linear property, then Maple can take advantage of this.
Use undefine to completely remove the definition of a procedure defined using the define command.
Download Help Document
What kind of issue would you like to report? (Optional)