define - Maple Help
For the best experience, we recommend viewing online help using Google Chrome or Microsoft Edge.

Online Help

define

define characteristics of an operator name

 

Calling Sequence

Parameters

Description

Rules

Examples

Calling Sequence

define(oper, rule1, rule2, ...)

definemore(oper, rule1, rule2, ...)

undefine(oper)

redefine(oper, rulelist)

Parameters

oper

-

name of the operator being defined

rule1, rule2, ...

-

one or more key names of a property, or an equation that defines a rule

rulelist

-

list; a list of equational rules, or property keywords

Description

• 

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.

Rules

• 

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 , where  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 , where  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 , where  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 . (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.

Examples

(1)

(2)

(3)

(4)

Define a commutative and associative operation.

(5)

(6)

You can use define to program recursive procedures.

(7)

(8)

(9)

(10)

An example of programming a one-line GCD.

(11)

(12)

(13)

The identity property can be used to define a monoid operation.

(14)

(15)

(16)

A simple integrator can be defined as follows.

This definition works for any variable.

(17)

(18)

Use definemore to improve the integrator.

(19)

(20)

(21)

(22)

Note: If INT does not recognize the pattern, it returns unevaluated.

(23)

The following example defined the procedure P by specifying its derivative.

(24)

(25)

(26)

If the derivative is specified for a procedure defined using the linear property, then Maple can take advantage of this.

(27)

(28)

(29)

(30)

(31)

(32)

(33)

Use undefine to completely remove the definition of a procedure defined using the define command.

(34)

(35)

See Also

examples/define

neutral

operator

patmatch

procedure

unassign

undefined

 


Download Help Document