Maple allows us to use symbols, like f, g, and so on to represent
functions. The syntax for defining functions in Maple uses the
assignment operator := and the symbol ->
which is built up from
-
and >
. For example to define ,
enter
f:= x->x^2*(sin(x)+1)^2;After a function has been defined, it can be evaluated at a point or used in a subsequent Maple command. To plot this function, we can use
plot(f(x), x=0..2*Pi);To evaluate a function at a point to find a numerical value use the
evalf
command. For example,
evalf(f(2));
We can also use this construction to define a constant. For example,
a:=Pi/2;defines a to be
We can also use this construction to define a function that depends on a parameter. For example,
f:=(x,a)->sin(a*x);Then we can plot the function for a particular value of a by using:
plot(f(x,3), x=0..2*Pi);We can also use this to plot several functions in a family of functions:
plot({f(x,1),f(x,2),f(x,3)}, x=0..2*Pi);