For Experts Only: Finer Points of Functions and Expressions

Like any programming language, Maple has some fine points. Notice that up above, we typed in "D(f)" and NOT "D(f(x))", and there is a difference! As defined, "f" is a function, a rule for associating numbers with numbers via a "goes to" operation, and "f(x)" is the expression obtained by plugging the symbol "x" into the function "f".

Here is what happens if we attempt to use the "D" operator on expressions instead of on functions:

> D(f(x));

[Maple Math]

Why isn't Maple simplifying "D(x)" to 1? The answer is that the "x" in the definition of "f" up above is not hard-wired into the function, i.e., Maple doesn't know that "x" is the variable and "f" is the function. The expression

> h := y -> 2*y;

[Maple Math]

defines the SAME function as

> h := z -> 2*z;

[Maple Math]

(In programming terms, the "x" in "x -> 2*x" is a local variable.)

The following example should make this clear. The derivative of sine is cosine:

> D(sin);

[Maple Math]

but:

> D(sin(x));

[Maple Math]

To differentiate expressions, we have to use the "diff" command and specify which variable we want to use:

> diff(f(x),x);

[Maple Math]

Integration uses a similar syntax. Here's an indefinite integral that's hard by hand but not so bad for Maple: (Note that Maple automatically sets the constant of integration to zero!)

> int(1/(1+cos(x)),x);

[Maple Math]

Similarly,

> int(f(x),x);

[Maple Math]

Maple has no equivalent of the "D" operator for integration. In particular,

> int(f);

Error, (in int) wrong number (or type) of arguments

won't work.

Maple can do definite integrals, too, using a range of numbers. For example:

> int(cos(x)^2,x=0..Pi);

[Maple Math]