L7-diffRules.mws
Calculus I
Lesson 7: Differentiation Rules
In this worksheet, we will review the definition of the derivative of a function, look at Maple's commands for differentiation, and use them to verify the basic differentiation formulas.
The definition of the Derivative
First, the definition. The derivativeof a function
at the point
is
,
provided, of course, that the limit exists. Since the derivative depends on the point
where it is evaluated, it is itself a function.
Maple
uses the notation
for this function; the more usual notation is
' . You should by now be familiar with several interpretations for
' : it is the instantaneous rate of change of
at
; it is the slope of the tangent line to the graph of
; if
represents the position of an object at time
, then
'(
) is its velocity.
Maple's
differentiation commands
>
restart;
It is easy to write a
Maple
procedure which computes the derivative of a function using the definition. (The command unapply is used to convert an expression to a function.)
>
myD := proc(f) unapply(limit((f(x+h)-f(x))/h,h=0), x) end:
>
f := x -> x^2;
>
myD(f);
>
myD(sin);
However, the built-in command
D
does the same thing:
>
D(f);
>
D(sin);
Note that
D
differentiates a
function,
and that the derivative of a function is again a function. For example,
can be evaluated at a point:
>
D(f)(3); D(f)(-5); D(f)(0);
but
Maple
provides another command which is closer to ordinary mathematical practice (it is
Maple's
equivalent of the
notation.) The command
diff
differentiates an
expression,
and gives back another expression.
>
diff(x^2, x); diff(x^3 + 5*x, x);
Notice that when you use
diff
, you must tell
Maple
the independent variable. Guess what the answer to the next command will be before you hit <enter>.
>
diff(x^2,y);
That's all there is to differentiation in
Maple
. Just remember that the derivative of a function is another function, and the derivative of an expression is another expression, and that they are computed with
D
and
diff
respectively. This is a nice example of
Maple
forcing you to think clearly, by the way. The distinction between differentiating functions and expressions was not invented by the
Maple
programmers: it is a real one, and is reflected in the fact that we have both the prime (') notation and the
notation for differentiation, but it is usually glossed over or ignored in textbooks.
Differentiation rules
Now let's use
D
and diff to compute some derivatives. While doing this, we will take the opportunity to verify three of the basic differentiation rules. (The remaining one is the Chain Rule, which we will explore in another worksheet.) First, the derivative is
linear:
for any constants
and
.
Second, we have the
product rule:
.
Third, the
quotient rule:
.
The linearity rule is the simplest.
>
diff(x^2, x); diff(x^3, x);
>
diff(7*x^2 + 4*x^3, x); diff(5*x^2 - Pi*x^3, x);
Here it is again, using
D
.
>
f := x -> cos(x^2); g := x -> x*exp(2*x);
>
D(f); D(g);
>
D(3*f - g);
If you look carefully at
Maple's
syntax, you can see that this last answer verifies the rule, but it might be easier to check by evaluating the various functions at
:
>
D(3*f - g)(x);
>
3*D(f)(x) - D(g)(x);
>
Now let's look at the product and quotient rules, with the same functions
and
. The product rule first:
>
D(f*g);
>
D(f*g)(x);
>
D(f)*g + f*D(g);
>
D(f)(x)*g(x) + f(x)*D(g)(x);
In terms of expressions, the same calculations look like
>
diff(f(x)*g(x), x);
>
diff(f(x), x)*g(x) + f(x)*diff(g(x), x);
In either form , you can see that the product rule works. Now for the quotient rule:
>
diff(f(x)/g(x), x);
>
simplify(%);
>
(diff(f(x), x)*g(x) - f(x)*diff(g(x), x)) / (g(x))^2;
>
simplify(%);
(You can do the calculation with
D
if you wish.)
>