Application Center - Maplesoft

App Preview:

Calculus I: Lesson 7: Differentiation Rules

You can switch back to the summary page by clicking here.

Learn about Maple
Download Application



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 f at the point x is

D(f)(x) := limit((f(x+h)-f(x))/h,h = 0) ,

provided, of course, that the limit exists. Since the derivative depends on the point x where it is evaluated, it is itself a function. Maple uses the notation D(f) for this function; the more usual notation is f ' . You should by now be familiar with several interpretations for f ' : it is the instantaneous rate of change of f at x ; it is the slope of the tangent line to the graph of f ; if f(x) represents the position of an object at time x , then f '( x ) 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;

f := proc (x) options operator, arrow; x^2 end proc...

> myD(f);

proc (x) options operator, arrow; 2*x end proc

> myD(sin);


However, the built-in command D does the same thing:

> D(f);

proc (x) options operator, arrow; 2*x end proc

> D(sin);


Note that D differentiates a function, and that the derivative of a function is again a function. For example, D(f) 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 d/dx 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 d/dx 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:

diff(a*f(x)+b*g(x),x) = a*diff(f(x),x)+b*diff(g(x),... for any constants a and b .

Second, we have the product rule:

diff(f(x)*g(x),x) = diff(f(x),x)*g(x)+f(x)*diff(g(x... .

Third, the quotient rule:

diff(f(x)/g(x),x) = (diff(f(x),x)*g(x)-f(x)*diff(g(... .

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

f := proc (x) options operator, arrow; cos(x^2) end...

g := proc (x) options operator, arrow; x*exp(2*x) e...

> D(f); D(g);

proc (x) options operator, arrow; -2*sin(x^2)*x end...

proc (x) options operator, arrow; exp(2*x)+2*x*exp(...

> D(3*f - g);

3*proc (x) options operator, arrow; -2*sin(x^2)*x e...

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 x :

> 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 f and g . The product rule first:

> D(f*g);

proc (x) options operator, arrow; -2*sin(x^2)*x end...

> D(f*g)(x);


> D(f)*g + f*D(g);

proc (x) options operator, arrow; -2*sin(x^2)*x end...

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