This page is optional reading for those who are interested in knowing more about the Maple language.
Suppose we define a Maple function f like this:
> f := x -> x^3 + x;
What is the difference between f and f(x)? The answer is that f is a function while f(x) is an expression. Recall that a function is a rule which generates a certain `output' for each `input'. In the case of a Maple function, both the input and the output of every function are expressions; the expression f(x) is the output generated by f from the input expression x.
It is common among mathematicians to use an expression to define a function in a sort of indirect way. For example, the expression x^3 + x is an indirect way of defining the function f above. For this to make sense we have to `know' that x is the name of the independent variable, i.e. the input, for the function that is being defined. Of course this is an arbitrary convention, and not one that it would be reasonable for Maple to adopt. Maple does not presume to know how you intend to use a particular name, unless you have assigned that name a value with the assignment operator `:='.
Look at what happens if we try to use the differentiation operator D to differentiate the expression x^3 + x.
> D(x^3+x);
This is the same result that we would get if we differentiated the expression f(x), since f(x) is equal to x^3 + x.
> D(f(x));
Since Maple does not know anything about x, the only thing that it can do is to express the derivative of x^3 + x in terms of the derivative of x. You may think that the derivative of x is 1, but that is only because you are using the arbitrary convention that was mentioned above, i.e. you are thinking of x as the name of the independent variable.
It would be possible to make Maple behave in a more conventional way by assigning x
a value, making it a name for the `identity function', i.e. the function whose output is always equal to its input. In fact, this is the function that is indirectly defined by the expression x, when we follow the usual convention. This can be done in Maple as follows:
> x := x -> x;
NOTE: The definition above illustrates an important lesson about the `goes to' operator ->. The -> is only allowed to have a single name on its left, and this name is always treated as if it had no value, even if it had been assigned a value earlier in the Maple session. (A programmer might say that the variable to the left of -> is always a local variable.) The x to the left of the `:=' is a different x. After executing the command above, x is a name for the identity function.
> x(3);
Observe what happens now that Maple understands what we mean by x:
> D(x);
> D(f(x));
But it is not really necessary to do all this. Maple tries to accommodate our mathematical idiosynchrases by providing a way to differentiate expressions, where the expression is thought of as indirectly defining a function. This is done with the command diff. Of course we must specify the name of the independent variable for this to be possible.
Here are some examples. (The second argument to diff is the name of the independent variable.)
> diff(x^3 + x, x);
> diff(x^2 + x, y);
> diff(x*y^2 + x^2, x);
> diff(x*y^2 + x^2, y);