Chapter 2 - Maple Basics

2.8 User Defined Functions

The power of Maple really becomes apparent when defining new functions. Functions are best understood in terms of creating a relation between an independent variable and a mathematical expression involving the independent variable, i.e., given the value of the independent variable, it provides a "recipe" to compute the function. This relation is called a "map" in mathematics. The Maple syntax to accomplish this task is that of an assignment of a "map" to a variable, here the function name, i.e.,

function_name := map;

A map is defined in terms of specifying the relation between an independent variable and the function via a simple "arrow" ("minus" sign followed by the "greater" sign with no space)

independent_variable -> mathematical_function;

The function is evaluated by using its name with the value (algebraic or numerical) of its argument in parenthesis. This is the same syntax as for the intrinsic built-in functions. They may also include calls to other functions.

Functions provide relations between dependent variables and independent variables; they are therefore intuitively understood by plotting these relations.

Function evaluation can be used as arguments of Maple operators.

Another syntax,

unapply(expression,variable),

can be used to define functions. This syntax must be used to define functions in terms of Maple generated expressions (see ?unapply).

The user might prefer to exclusively use the "unapply" command instead of the "arrow" notation for consistency; it is in most cases a matter of choice since the two syntax's are mostly equivalent. The "unapply" notation will always work.


  Section 2.7 Chapter 2 Section 2.9       TOC

Any questions or suggestions should be directed to
Michel Vallières at vallieres@physics.drexel.edu