In a recent post, a Maple user misunderstood what an assignment to f(x) meant. Since this is a common source of confusion, I thought it would be worthwhile to say more about this subject.

What is f(x)?
First, f(x) is a "function application" in Maple. It is f applied to the argument x. It is not really the same as what one thinks of as a function in mathematics. Consider a mathematical function such as sin(x+y). In Maple, this can be represented by an expression sin(x+y) or a procedure proc(x, y) sin(x+y) end proc (which can also be written in "operator form" as (x, y)->sin(x+y)). The expression or the procedure can then be assigned to a name such as g. The mathematical function is then represented by g in Maple, and not by g(x, y). Instead, if g is a procedure, then g(x, y) means "the procedure g called with arguments x and y". The "function" help page explains these concepts in more detail.

What is f(x):=x^2 in 1-d math?
Now let's move on to what f(x) := x^2 means. In 1-d math, this means, "Create a remember table entry for procedure f." This stores the expression x^2 so that when you enter f(x), that expression is automatically retrieved, and you avoid the expense of executing the body of the procedure . Similarly, if you enter f(1) := 5, then the value 5 is automatically returned when you enter f(1). Note that if you subsequently enter f(y), you won't get y^2 returned, unless f was already defined to return y^2 with input y. Remember tables are very useful and are heavily used by some Maple library procedures. However, the majority of Maple users do not need to worry about this feature and can do very useful things in Maple without ever knowing about it.

What is f(x):=x^2 in 2-d math?
Because remember tables are not commonly used by most users, f(x):=x^2 is handled slightly differently in 2-d math. When f(x):=x^2 is entered in 2-d math, Maple wonders whether you really do want to create a remember-table entry. It then asks, via a dialog box, whether you actually mean to create a procedure that returns x^2 and assign it to f. If you say yes, then Maple executes f:=x->x^2 instead. If you say no, then the remember-table assignment is performed.

Setting typesetting rules

If you never use remember tables and prefer to use the syntax f(x):=x^2 instead of f:=x->x^2, there is a way of indicating this preference. Open the Typesetting Rules Assistant (available through the View menu) and check the appropriate box ("always", "query" or "never") under "Allow shortcut function definition." Alternatively, you can do this through the command Typesetting[Settings], and instructions for doing this are on the help page for that command. Note that this setting does not apply to 1-d math. If you have no real need of this shortcut notation, it's best to just get used to defining procedures in the usual way. Otherwise, there could be confusion if you frequently switch between 1-d and 2-d math or if you share worksheets with other users who don't use the shortcut notation.


Please Wait...