next up previous
Next: About this document ... Up: lab_temp Previous: lab_temp

Subsections


Derivatives

Purpose

The purpose of this lab is to teach you how to use Maple commands for computing derivatives.

Background

Maple has several commands for computing derivatives. The most common ones are the diff command for differentiating expressions and the D operator for differentiating functions. These are the commands we will consider here.

Functions and Expressions in Maple

Before describing the commands for differentiation, we need to review the concepts of expression and function in Maple. An expression is a collection of mathematical symbols, for example $x^2+\sin(3x)$ and $x^2-y^2$ are both expressions. A function, on the other hand, is a rule for associating an output value with an input value.

The connection is that expressions are often used to define functions. That is, we could let $f(x)=x^2+\sin(3x)$, which defines a function $f$. The rule for this function is to substitute a value for $x$ into the expression $x^2+\sin(3x)$ 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 $x$ requires the subs command, as in the following example.
> 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$ in Maple using the expression $x^2+\sin(3x)$ with the following command.
> f := x -> x^2+sin(3*x);
Evaluating our function at a specific value of $x$ is now easy.
> f(2);
One final thing to note is that Maple will use f to denote the function we have defined, but will use f(x) to denote the expression used to define the function.

The Maple D and diff commands

These commands can be summarized as follows.

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);

Suppose you want to find the equaton of the line tangent to the graph of $f(x)$ at the point $x=5$. This can be done in Maple using the point slope form of a line as shown below.

> tanline := D(f)(5)*(x-5)+f(5);

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);
The following is also INCORRECT syntax
> D(f(x));

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

> diff(p,x);
The diff command can also be applied to functions as shown below.
> diff(f(x),x);
Note, however, that the result of the diff command is an expression, not a function. This means that computing the value of the derivative at a specific value of $x$ requires you to use the subs command.

Exercises

  1. Enter the following as a function. Compute the derivative of the function using the diff command. Plot the original function and its derivative on the same graph over the range $-2 \leq x \leq 2$. In your writeup, identify which curve is the function and which is the derivative, for example by identifying a point where the derivative is zero.

    \begin{displaymath}f(x) = x^4 + 1.3 x^3-4x^2 +x-3\end{displaymath}

  2. Enter the following as a function. Compute the derivative using the D operator. Also, find the tangent line at $x=2$ and plot it on the same graph. Use the interval $0 \leq x \leq \pi$.

    \begin{displaymath}g(x) =x \sin(x) \end{displaymath}

  3. If an object is dropped off the edge of a $1000$ meter cliff and air resistance is neglected, the position of the object at time $t$ is given by $f(t) =1000 -4.9 t^2$, where $t$ is in seconds. The average velocity at time $T$ is

    \begin{displaymath}\frac{f(T) - f(0)}{T} \end{displaymath}

    Show, using a plot or algebra that the average velocity at time $T$ is exactly half the instantaneous velocity at time $T$.


next up previous
Next: About this document ... Up: lab_temp Previous: lab_temp
Jane E Bouchard
2005-01-28