** Next:** About this document ...
**Up:** Labs and Projects for
** Previous:** Labs and Projects for

The connection is that expressions are often used to define a
function. That is, we could let , which defines a
function *f*. The rule for this function is to substitute a value for
*x* into the expression to obtain the output value. Not
all expressions can be used to define functions, however, and not all
functions are defined by expressions so these really are distinct
mathematical objects.

Maple mimics this mathematical distinction between expression and function. You can define expressions in Maple and even label them for later use with commands like the one below.

> p := x^2+sin(3*x);

This is an expression not a function, which means there is no rule associated with it. Thus evaluating the expression at a specific value of

> subs(x=2,p);

The syntax for defining a function in Maple uses an arrow to make the idea of a function as a process explicit. For example, we can define a function

> f := x -> x^2+sin(3*x);

Evaluating our function at a specific value of

> f(2);

One final thing to note is that Maple will use

> F(x) := x^2+3;

Since Maple doesn't complain, students often think that what they've done is correct. The output from the following commands, however, shows that the object we've defined doesn't behave like a function.

> F(x);

> F(1);

> F(t);

> F(2*x);

What is happening here is that we've defined something called a

- The
`D`operator acts on a function to produce the derivative of that function. - The
`diff`command acts on an expression and differentiates that expression with respect to a variable specified by the user.

When you use the `D` operator to compute the derivative of a
function, the result is also a function, as shown below.

> D(f);

If you provide a label, then you get a function you can use later in the session,

> df := D(f);

However, this is usually not necessary. See the examples below.

If you want to evaluate the derivative at a specific value of *x* or
just get the expression for the derivative, you can use the following
forms of the `D` operator.

> D(f)(2);

> D(f)(x);

This last form is the one to use for plotting, as shown below.

> plot(D(f)(x),x=-2..2);

The `D` operator cannot be used on expressions, for example
trying to use it to differentiate the expresssion we defined above
results in an error.

> D(p);

Error, (in D) univariate operand expectedIf you recall that Maple uses

> D(f(x));

Error, (in D) univariate operand expected

To differentiate expressions, you need to use the `diff`
command. Here is an example.

> diff(p,x);

The

> diff(f(x),x);

Note, however, that the result of the

To find the tangent line at to our function *f*, we
need two pieces of information. One is the slope of the tangent line,
which is given by , and the other is a point on the
line, which is . Then, using the
point-slope formula, the equation for the tangent line is

> tf := x -> D(f)(3/2)*(x-3/2)+f(3/2);

> plot({f(x),tf(x)},x=0..3);

Using the `diff` command to compute the tangent line is a
little harder, because the `subs` command must be used.

> tf2 := x -> subs(x=3/2,diff(f(x),x))*(x-3/2)+f(3/2);

> plot({f(x),tf2(x)},x=0..2);

- 1.
- Give an example of a situations where the
`D`operator would be easier to use than the`diff`command. Then give an example where the`diff`command would be better. In each case, make sure you justify your choice. - 2.
- Use either the
`D`or`diff`commands to find the derivative of the following function. Plot the graph of the derivative over the given range and evaluate the derivative at the indicated point. Graph for . Evaluate at . - 3.
- Consider the function
Find all of the points where the derivative of
*g*is equal to 1. - 4.
- The tangent line to a function at a particular value of
*x*intersects the graph of the function at least once, at the point of tangency. However, the tangent line may intersect the graph at other points. In this problem, we investigate whether the tangent line at one point can also be tangent to the graph at another point. For example, consider the function*g*(*x*) = (*x*-1)^{2}^{2}*x*=-1 is also tangent to the graph at*x*=1.Next, suppose we change the function slightly.

*h*(*x*) = (*x*-1)^{2}^{2}+*x*/2*x*such that the tangent lines coincide? The answer is yes. Find them.

2/1/2000