Topic 3 Derivatives
3.1 Derivative Functions
What makes derivative so important in modern mathematics is the ideal of linearly approximating curves using tangent lines. Geometrically, the derivative of a function at a point is the slope of the line tangent to at . Using limits (if it exists), the derivative is defined as
Consider as a variable, we may define a function called the derivative function. In terms of limits, the derivative function of a function , denoted by is given by
Using limit laws, we can show that differentiable functions are continuous.
Geometrically, the graph of differentiable function locally is flat without any hole or jump.
All elementary functions are differentiable over their domain. But there are also many functions which are not differential everywhere in their domain.
Example 3.1 Use the graph of the function to identify a value where is not differential. Verify your finding using the definition of differentiability.
Solution. First plot the function.
f:= x-> abs(x);
plot(f(x), x=-2..2);
You will see the function is not flat near . To verify that, we calculate the limit of the difference quotient for all and then evaluate the resulting function at .
diffquot:=(f(x+h)-f(x))/h;
derlimit:= limit(diffquot, h=0);
evalf(subs(x=1, derlimit));
Exercise 3.1 Determine whether the function is differential at using the definition of the differentiability.
Exercise 3.2 Determine whether the function is differential at using the definition of the differentiability.
Exercise 3.3 Using the definition to find the derivative for .
3.2 Calculating Derivatives
Calculating a derivative in Maple is as easy as calculating a limit. The command for differentiation is diff(function, variable)
. For higher derivatives, you may simply repeat the variable or use [variable$n]
to indicate the times differentiation.
Example 3.2 Calculate the first derivative and the second derivative for the function
Solution.
First represent the function rule simply by f
.
f:=2/(sqrt(2*(sin(x))^2+1))
Calculate the first derivative and denote the derivative by f1
.
f1:=diff(f, x);
Calculate the second derivative and denote the derivative by f2
. You may use one of the following three commands.
f2:=diff(f1, x);
f2:=diff(f, x, x);
f2:=diff(f, [x$2]);
Maple also has a tutoring command for differentiation: DiffTutor(function, variable)
which is again supported by the subpackage Student[Calculus1]
. However, DiffTutor
only works for the first derivative.
Example 3.3
Calculate the derivative for by hand and compare your calculation the the result given by DiffTutor
.
Solution. By hand, we may simplify the expression using rational exponents first and then apply derivative rules.
To see the result from DiffTutor
, we use the following command. Remember to load the Student[Calculus1]
first.
with(Student[Calculus1]):
DiffTutor((x^2-2*x-x^(-3))/sqrt(x), x);
Here is how does the output look like

The derivative of a function obtained by the DiffTutor command
Exercise 3.4 Calculate the first derivative for the function by hand and by Maple. Compare two results. Are they different? If so, can you explain the difference?
Exercise 3.5 Calculate the first derivative for the function by hand and by Maple. Compare two results. Are they different? If so, can you explain the difference?
Exercise 3.6 Calculate the first derivative for the function by hand and by Maple. Compare two results. Are they different? If so, can you explain the difference?
Exercise 3.7 Calculate the -th derivative for the function by hand and by Maple. Can you find a formula for the -th derivative of the function?
3.3 Chain Rule
Let and be two differentiable functions. Then the derivative of the composite function can be calculated using the following formula Why there is an extra factor ? This is mainly because .
Now let’s use Maple to understand the chain rule. In Maple, the symbol for composition is @
, that is, in Maple the composition is given by f@g
.
Since we will evaluate derivative functions, in addition to the command diff(expression, variable)
, we will also use D(function)(variable)
to find the derivative function. One major difference between those two commands is that D
is designed to differentiate functions, whereas diff
is for differentiating expressions.

A screen shot from Maple shows a comparison between the commands D and diff
Example 3.4 Let , and . Find , , and ? Compare the derivatives and draw a conclusion.
Solution. We first define the functions.
f:=x->sin(x);
g:=x->2*x;
F:=x->2*sin(x)*cos(x);
Find the derivative functions
Der_f_g:=D(f)(g(x)); # f'(g(x))
Der_fg:=diff(f(x)g(x), x); # (fg)'(x)
Der_fog:=D(f@g)(x); # (fog)'(x)
Der_F:=D(F)(x); # F'(x)
To compare the derivatives, we use the command expand
and simplify
to rewrite the expressions.
simplify(expand(Der_f_g));
simplify(expand(Der_fg));
simplify(expand(Der_fog));
simplify(expand(Der_F));
From the outputs, we see that . Why they are the same? This is because !.

An example about the chain rule solved using Maple
Remark.
You may also use D(unapply(f(x)*g(x), x))(x)
to calculate the derivative of the product function .
The chain rule is almost unavoidable in calculation of derivatives. Sometimes, using chain rule will simplify the calculation.
Example 3.5 Consider the function .
- Find the derivative function using
DiffTutor
. Which rule of derivative was applied first? - Find the point where the tangent line of is horizontal over the domain .
- Find an equation of the tangent line at .
- Plot the tangent line and the function together over the domain .
Solution.
You may use quotient rule to find the derivative. However, the chain rule may be a better choice because . Let’s try DiffTutor
.
restart; # Use `restart` to clear the internal memory.
with(Student[Calculus1]);
f:=1/(sin(x)+cos(x));
DiffTutor(f, x);
You see that the chain rule was applied first.

A example that chain rule was applied first by DiffTutor
To find the points where the tangent line is horizontal, we need to solve the equation .
solve(diff(f, x)=0)
To find the tangent line, we find the derivative . One way is to use unapply
.
unapply(diff(f, x), x)(0)
You may also use eval(expression, variable=value)
.
eval(diff(f, x), x=0)
Since , the tangent line at is defined by .
y:= -x+1
Now let’s verify visually that is the tangent line.
plot([f, y], x=-1/2..1/2)
Exercise 3.8 Let , and . Find , , and . Compare the derivatives and draw a conclusion.
Exercise 3.9 Let and and . Find , , and . Compare the derivatives and draw a conclusion.
Exercise 3.10 Consider the function .
- Define three functions , and so that .
- Describe how the derivative function was calculated by
DiffTutor
. - Find the point where the tangent line of is horizontal over the domain .
- Find an equation of the tangent line of at .
- Plot the tangent line and the function together over the domain .
3.4 Implicit Differentiation
Implicit differentiation is an application of the chain rule. It provides a way to find the slope of a tangent line of a function implicitly defined by an equation, that is, the dependent variable is not isolated.
In Maple, there are two useful commands that help us understand implicit defined functions.
The command implicitplot(equation, domain, range, options)
supported by the package plots
can be used to graph an implicitly defined function.
The command implicitdiff(function, dependent variable, independent variable)
can be used to find derivatives implicitly.
Example 3.6 Graph the function of defined by with it tangent line at over the domain and range .
Solution.
Let’s first assign an name to the equation. (Run restart
first if x
and y
were previously used an names.)
restart;
eqnf:=x^2+2*y^2=2*x+4*y;
Now let’s find the derivative function, and its value at .
D_eqnf:=implicitdiff(eqnf, y, x);
slope:=eval(D_eqnf, {x=2, y=0});
Let’s define the tangent line
tangentline:= y=slope*(x-2)+0
Now we are ready to plot the function with the tangent line together.
with(plots);
implicitplot([eqnf, tangentline], x=1..3, y=-1..2, color=[red, blue]);
Remark.
Another way, which is more flexible, to put two or more graphs together is to use the command display(graph1, graph2)
which is supported by the package plots
. For example, the following commands will show two curves in a single picture.
with(plots):
g1 := implicitplot(x^2+y^2=1, x=-1..1, y=0..1):
g2 := plot(1-abs(x), x=-1..1):
display(g1, g2, title="Two Together");
Note that we use colone :
at the end of a command to hide the output.
Exercise 3.11 For the ellipse , find the locations of all horizontal tangent lines and plot them implicitly on the same graph as the relation over the interval and .
Exercise 3.12
Find an equation of the line tangent to the curve at . (You may want to use solve
and subs
to find the when ).
Exercise 3.13
Find all points on the curve of where lines tangent to the curve at is perpendicular to the line . (Use ?solve
to learn how to solve a system of equations in Maple).
3.5 Rates of Change and Derivatives
Given a function , the average rate of change of is the difference quotient The instantaneous rate of change is the limit which is exactly the derivate of . However, in science, economy and many other field, the same concept bears different names. For example, the velocity is the instantaneous rate of change of the position function; the marginal cost is the derivative of the cost function.
Now let’s use Maple to help us understand such kind of application of derivatives.
Example 3.7 The position function of a particle moving along a straight line after seconds is meters.
- Find the time that the particle is at the rest.
- Find the distance the particle moved in the first 5 seconds.
- Plot the , and for together.
- When the particle is speeding up?
- Confirm you answer in 3. using graph of the speed function.
Solution. Let’s first define if position function
s:= t->2*t^3-6*t^2-18*t+1
The particle at rest when the velocity is 0. To find , we find first and then solve from .
v:=D(s);
solve({v(t)=0, t>0}, t); # assuming t>0.
From the output, you will find that after 3 second the particle is temporarily at rest.
The particle moves forward if and backward if . You may use the previous output or apply the command solve
for those two inequalities. Either way, you will find from to , and for . So the total distance should be calculated as
totdist:= abs(s(3)-s(0))+abs(s(5)-s(3))
The acceleration function . To plot those three functions together, you may use plot
.
a:=D(v);
plot([s(t), v(t), a(t)], t=0..5, color=[black, blue, red]);
The speed function of the particle is . When and , the particle is speeding up. When and , the particle is also speeding up. So the particle is speeding up if . Similarly, the particle is slowing down if .
solve({v(t)*a(t)>0, t>0}, t)
It shows that the particle is speeding up when or . This can also be seen from the graph of the speed function.
plot(abs(v(t)), t=0..5)
Exercise 3.14 The position function of a particle moving along a straight line after seconds is meters.
- Find the time that the particle is at the rest.
- Find the distance the particle moved in the first 5 seconds.
- Plot the , and for together.
- When the particle is speeding up?
- Confirm you answer in 3. using graph of the speed function.
Exercise 3.15 Suppose that the profit obtained from the sale of calculators is given by . Use the marginal profit function to estimate the profit from the sale of the 51st calculator.
3.7 Linearizations
Let be the function differentiable at . The linearization of at is defined to be the function . For any value near , the function value is approximately the same as . This method is called linear approximation. The tangent line approximation is fundamental to almost every application of the derivative.
Example 3.9 Find the linearization of the function at and use this linearization to estimate . How large is the error?
Solution. We first find the slope fr the linearization which is the derivative .
f:=x->surd(x+7, 3); # or f:=x->(x+7)^(1/3)
m:=simplify(D(f)(1)); # this is the slope (simplified).
Now we define the linearization and estimate using .
L:=x->m*(x-1)+f(1);
L(0.99);
The error may be calculated based on the output of the follow command.
f_L:=f(0.99)-L(0.99);
The results shows that the linear approximation is slightly over estimated with an error less than .
Exercise 3.19 Find the linear approximation of the function at . Use this linearization to approximate .
Exercise 3.20 Find the linear approximation of the function at . Use this linearization to approximate .
Exercise 3.21 Find the linear approximation of the function at . Use this linearization to approximate .
3.8 Newton’s Method
In science and engineering, many problems may be eventually reduced to nonlinear equations which likely has no algebraic (analytic) solution. In such a situation, numerical solutions are hoped for applications. We’ve seen a method to find a numerical solution using the intermediate value theorem. However, it is not very effective. Using linearization, a root-finding algorithm was developed by Newton and other mathematicians. The idea is to use the -coordinates of tangent lines to approximate a root of an equation. Let’s see an example first using the Maple command NewtonsMethod(function, starting point, options)
which is again supported by the subpackage Student[Calculus1]
.
Example 3.10 Starting at , obtain a solution of by Newton’s method.
Solution.
First load Student[Calculus1]
use with()
.
with(Student[Calculus1])
Now apply the NewtonsMethod command
NewtonsMethod(sin(x)-x/2, x=-1.5)
To see the graph, you may add the option output=plot
.
NewtonsMethod(sin(x)-x/2, x=-1.5, showroot=true, output=plot)
How does Newton’s methods work? It’s an iteration process. Consider the equation . Suppose is differentiable. To find a solution, we pick an initial value first. The -value of the -intercept of the linearization should produce a value that is closer. The value is given by the formula Iteratedly applying the above idea, we get the iteration formula
Remark. How many times should be iterated? It depends on the sizes of acceptable errors and a maximum number of iteration.
If the -values produced from two successive iterates is sufficiently small, say , and the function value at is sufficiently small, say , where and are acceptable errors, then we may say has a solution at .
If after iterated a maximum number of times and a solution was not found, then we may have to change the initial value or using other methods.
If it happens that , then the iteration process fails.
The above algorithm may be realized using the following Maple codes.
tol := 10^(-3);
N := 100;
f := x -> sin(x) - 1/2*x;
m := D(f);
newton := x -> evalf(x - f(x)/m(x)); # Newton's formula
x := -1.5;
for i to N do
x := newton(x);
if abs(x - newton(x)) < tol and abs(f(x)) < tol then
break;
eli i = N then
error "Newton's method did not converge";
end if;
end do;
print(x);
If you don’t want to check the size of error, the code can be simplified using the composite symbol @
in Maple.
restart;
f := x -> sin(x) - 1/2*x;
m := D(f);
newton := x -> evalf(x - f(x)/m(x));
N:=100
x[N]:=evalf((newton@@N)(-1.5)); # @@N means that newton compose with itself N times.
Exercise 3.22 Using Newton’s Method to find solutions of the polynomial equation .
Exercise 3.23 Using Newton’s Method to find solutions of the equation .
Exercise 3.24 Using Newton’s Method to find the solution of the equation in the interval . Among 1 and 2,which is a better initial value? Why?