6 | THE RULES OF DIFFERENTIATION
6 | THE RULES OF DIFFERENTIATION
This chapter of Single Variable Calculus by Dr JH Klopper is licensed under an Attribution-NonCommercial-NoDerivatives 4.0 International Licence available at http://creativecommons.org/licenses/by-nc-nd/4.0/?ref=chooser-v1 .
6.1 Introduction
6.1 Introduction
Before we consider the rules of differentiation, we have to consider which function are differentiable and perhaps define the interval on which they are differentiable.
6.2 Continuity
6.2 Continuity
When we studied limits. As a reminder we reconsider the definition of continuity.
Definition 6.2.1 A single variable function is continuous at a point if is defined, the limit of exists at , and the limit of at is .
f(x)
(a,f(a))
f(a)
f
x=a
f
x=a
f(a)
As example we have polynomials that are continuous everywhere.
A function is continuous on an interval if it is continuous everywhere on the interval even if they are not continuous outside of that interval.
[a,b]
In this section we consider functions that are not continuous.
6.2.1 Rational functions
6.2.1 Rational functions
Rational functions are the quotient of two polynomials and , written in (), where .
g(x)
h(x)
h(x)!=0
g(x)
h(x)
(
1
)When has real roots then there are values of where is not defined or that there is a removable discontinuity. From Definition 6.2.1 this means that these functions are not continuous
h(x)
x
f
Consider the rational function in ().
f(x)=-1
2
x
x
(
2
)The denominator is when and is not defined at . Figure 6.2.1.1 shows a vertical asymptote at .
h(x)=x
0
x=0
x=0
x=0
In[]:=
Plot-1,{x,-5,5},PlotLabel->"Figure 6.2.1.1",AxesLabel->{"x","y"},GridLines->Automatic,ImageSize->Large
2
x
x
Out[]=
Note that even if in () is discontinuous, it is continuous on the intervals and .
f
(-∞,0)
(0,∞)
Next we consider the rational function in ().
f(x)=-1
2
x
x-1
(
3
)The denominator has a real root . At the denominator is and the function is not defined at . There is a discontinuity at . This discontinuity is removable, though, as shown in ().
h(x)=x-1
x=1
x=1
0
x=1
x=1
f(x)==x+1
(x-1)(x+1)
x-1
(
4
)Here, is defined everywhere, shown in Figure 6.2.1.2.
f
In[]:=
Plot-1,{x,-3,3},PlotLabel->"Figure 6.2.1.2",AxesLabel->{"x","y"},GridLines->Automatic,ImageSize->Large
2
x
x-1
Out[]=
6.2.2 Jump discontinuities
6.2.2 Jump discontinuities
Some functions that are piecewise defined may have jump discontinuities. Consider the function in ().
f(x)=
|
(
5
)Figure 6.2.2.1 visualizes the jump discontinuity.
In[]:=
Plot
,{x,-2,2},PlotLabel->"Figure 6.2.2.1",AxesLabel->{"x","y"},GridLines->Automatic,ImageSize->Large
|
Out[]=
From Definition 6.2.1, the function in (5) is defined at , but the limit does not exist at since the left- and right-hand limits are not the same. The Limit function shows the difference in the one-sided limits.
f
x=0
x=0
In[]:=
Limit
,x->0,Direction->"FromBelow"
|
Out[]=
0
In[]:=
Limit
,x->0,Direction->"FromAbove"
|
Out[]=
2
In () we see another piecewise defined function.
f(x)=
|
|
(
6
)The function is defined at and the left- and right-hand limits exist and are equal. The limit at is , but and by Definition 6.2.1, the function is discontinuous at .
f
x=4
x=1
2
f(1)=4
x=1
The function is defined using the Piecewise function below.
In[]:=
f[x_]:=Piecewise[{{2x,x!=1},{4,x==1}}]
The Limit function confirms the limit.
In[]:=
Limit[f[x],x->1,Direction->"FromBelow"]
Out[]=
2
In[]:=
Limit[f[x],x->1,Direction->"FromAbove"]
Out[]=
2
Figure 6.2.2.2 shows visualizes the discontinuity.
In[]:=
Plot[2x,{x,-1,2},PlotRange->{{-1,2},{-2,5}},PlotLabel->"6.2.2.2",AxesLabel->{"x","y"},GridLines->Automatic,ImageSize->Large,Epilog->{PointSize[Large],Point[{1,4}]}]
Out[]=
The floor function in () has many discontinuities (depending on the interval on which we define it).
f(x)=⌊x⌋
(
7
)In the code cells below we create the user-defined function f and use the Limit function to show that the limit does not exist as . The same would apply to all other integer values of .
x=0
x
In[]:=
f[x_]:=Floor[x]
In[]:=
Limit[f[x],x->0]
Out[]=
Indeterminate
In[]:=
Limit[f[x],x->0,Direction->"FromBelow"]
Out[]=
-1
In[]:=
Limit[f[x],x->0,Direction->"FromAbove"]
Out[]=
0
Figure 6.2.2.3 shows the jump discontinuities.
In[]:=
Plot[Floor[x],{x,-3,3},PlotLabel->"Figure 6.2.2.3",AxesLabel->{"x","y"},GridLines->Automatic,ImageSize->Large]
Out[]=
6.2.3 Constrained domains
6.2.3 Constrained domains
Certain single variable functions have restricted domains. That is to say, they are only defined on certain intervals. One such example is the square root function, which is not defined for negative values of , at least not when we only consider real-valued functions. Figure 6.2.3.1 visualizes the square root function.
x
In[]:=
Plot[
x
,{x,-1,5},PlotLabel->"Figure 6.2.3.1",AxesLabel->{"x","y"},GridLines->Automatic,ImageSize->Large]Out[]=
The values of at , but only the right-hand limit exists here.
f(x)=
x
x=0
Another such function is , where we have, as example, the logarithm base . Figure 6.2.3.2 shows that the function is not defined for non-positive numbers.
f(x)=log(x)
10
In[]:=
Plot[Log[10,x],{x,-1,5},PlotLabel->"Figure 6.2.3.2",AxesLabel->{"x","y"},GridLines->Automatic,ImageSize->Large]
Out[]=
The logarithm function has no limit as even from the right with f approaching negative infinity as from the right.
x->0
(x)
x->0
6.2.4 Cusps and corners
6.2.4 Cusps and corners
Some functions have cusps, where there are abrupt changes in the function. Consider the single variable function in ().
f(x)=
|x|
(
8
)The function in () is defined for all values of . Figure 6.2.4.1 visualizes the function.
x
In[]:=
Plot
Abs[x]
,{x,-1,1},PlotLabel->"Figure 6.2.4.1",AxesLabel->{"x","y"},GridLines->Automatic,ImageSize->LargeOut[]=
It is clear that the function is defined at and that a limit exists at . We use the Limit function below to calculate the left- and right-hand limits.
x=0
x=0
In[]:=
Limit
Abs[x]
,x->0,Direction->"FromBelow"Out[]=
0
In[]:=
Limit
Abs[x]
,x->0,Direction->"FromAbove"Out[]=
0
The limit as is also the value of the function at and all three criteria for continuity are met. We will see, though, that continuity does not guarantee that the function is differentiable at a specific value of .
x->0
x=0
x
The function is () has a corner at , visualized in Figure 6.2.4.2, and the same arguments apply to the example of a function with a cusp above.
x=0
f(x)=|a|
(
9
)In[]:=
Plot[Abs[x],{x,-1,1},PlotLabel->"Figure 6.2.4.2",AxesLabel->{"x","y"},GridLines->Automatic,ImageSize->Large]
Out[]=
6.2.5 Continuity laws
6.2.5 Continuity laws
If and are two continuous functions, then the following laws in () hold.
f(x)
g(x)
f(x)+g(x)iscontinuous(sumlaw)f(x)-g(x)iscontinuous(differencelaw)cf(x)iscontinuous(scalarmultiplicationlaw)f(x)g(x)iscontinuous(productlaw),g(x)!=0iscontinuous(quotientlaw)
f(x)
g(x)
(
10
)6.2.6 Intermediate value theorem
6.2.6 Intermediate value theorem
A continuous function takes on every values between and under the conditions stated in Theorem 6.2.6.1 known as the intermediate value theorem.
f
f(a)
f(b)
Theorem 6.2.6.1 Let be a continuous function on the closed interval and let be any number between and , where . Then there exists a number (the open interval), such that .
f
[a,b]
n
f(a)
f(b)
f(a)!=f(b)
c∈(a,b)
f(c)=n
The mean value theorem can be used to show that a function has a root on a domain. Consider the function in ().
f(x)=3-5+2x-2
3
x
2
x
(
11
)Figure 6.2.6.1 shows the curve of the function on the domain .
[0,2]
In[]:=
Plot[3-5+2x-2,{x,0,2},PlotLabel->"Figure 6.2.6.1",AxesLabel->{"x","y"},GridLines->Automatic,ImageSize->Large]
3
x
2
x
Out[]=
For the domain we have and . By the intermediate value theorem we must have a values on the open domain such that . This confirms that the function has a root on the domain.
[a,b]=[0,2]
f(a)=f(0)=-2
f(b)=f(2)=6
x=c
(0,2)
f(c)=0
6.3 Differentiability
6.3 Differentiability
We have explored some derivatives already. In the previous section we also considered continuity. Here, we consider differentiability.
Since the derivative is a limit, we start by considering left- and right-hand derivatives.
Figure 6.3.1 revisits a function with a cusp, namely . We have seen that this function is continuous at .
f(x)=|x|
x=0
In[]:=
Plot[Abs[x],{x,-1,1},PlotLabel->"Figure 6.3.1",AxesLabel->{"x","y"},GridLines->Automatic,ImageSize->Large]
Out[]=
This function can be rewritten as a piecewise-defined function, shown in ().
f(x)=
|
|
(
12
)We can explore the derivative from the left and the right at . The function is defined differently on the left and the right hand sides of . In (), we consider the first derivative of with respect to , where .
x=0
x=0
f
x
x<0
f'(x)=f'(x)=f'(x)=-1
lim
h->0
-(x+h)-(-x)
h
lim
h->0
-h
h
(
13
)In (), we consider the derivative of with respect to , where .
f
x
x>=0
f'(x)=f'(x)=f'(x)=1
lim
h->0
(x+h)-x
h
lim
h->0
h
h
(
14
)The left- and right-hand derivatives are not the same at . This brings us to the definition of differentiability of a single variable function.
x=0
Definition 6.3.1 A function is differentiable at if exists. Note that the left- and right-hand derivatives must be equal.
f(x)
x=a
f'(a)
It is clear that a function that is differentiable on a domain, must also be continuous on that domain. It is not so that a function that is continuous on a domain is differentiable on that domain, as we have seen in the previous example.
A function is not differentiable at all the discontinuities that we have discussed.
6.4 The rules of differentiation
6.4 The rules of differentiation
There are several rules for differentiation that can be used to calculate the derivative of many functions symbolically. We have already explored the first rule, known as the power rule, in the previous chapter, and briefly mention it here as the first rule. Note that in all examples of differentiation rules below, we only consider differentiable function, at least on a specified domain.
6.4.1 Power rule
6.4.1 Power rule
For any term in a polynomial, written as , where !=0, we have the derivative as shown in ().
a
n
n
x
a
n
d
dx
a
n
n
x
a
n
n-1
x
(
15
)
Problem 6.4.1.1 Calculate the first derivative with respect to of the function in ().
x
f(x)=
3
4
x
(
16
)We rewrite the function in () and use the power rule to calculate the first derivative.
f(x)=3f'(x)=(-4×3)f'(x)=-12f'(x)=
-4
x
-4-1
x
-5
x
-12
5
x
(
17
)The result is confirmed using the D function.
In[]:=
D,x
3
4
x
Out[]=
-
12
5
x
The value of is the power rule can also be a fraction.
n
Problem 6.4.1.2 Calculate the first derivative with respect to of the function in ().
x
f(x)=
3
2
5
x
(
18
)As before, we rewrite the function in () and solve for the first derivative using the power rule.
f(x)=3f'(x)=-×3f'(x)=-f'(x)=-f'(x)=
-
2
5
x
2
5
--1
2
5
x
6
5
--
2
5
5
5
x
6
5
-
7
5
x
-6
5
7
5
x
(
19
)We confirm the result with code.
In[]:=
D,x
3
2
5
x
Out[]=
-
6
5
7/5
x
6.4.2 Constant multiple rule
6.4.2 Constant multiple rule
We demonstrate this rule for the function and the constant in ().
f(x)
c
d
dx
d
dx
(
20
)We note that the constant can be extracted outside of the derivative.
c
Problem 6.4.2.1 Calculate the first derivative with respect to of the function in ().
x
f(x)=3
2
x
(
21
)In (), we make use of the constant multiple rule. This problem can also be solved using the product rule, though. In fact, we do make use of the product rule after extracting the constant from the derivative.
c=3
d
dx
d
dx
2
x
d
dx
2
x
2-1
x
(
22
)We confirm the result with code.
In[]:=
D[3,x]
2
x
Out[]=
6x
6.4.3 Sum and difference rules
6.4.3 Sum and difference rules
For two functions and we have the sum and difference rules as shown in ().
f(x)
g(x)
d
dx
d
dx
d
dx
(
23
)
Problem 6.4.3.1 Calculate the first derivative with respect to of the sum of two function in ().
x
3+7
2
x
4
x
(
24
)The solution is shown in () and then confirmed using code.
f(x)+g(x)=3+7[f(x)+g(x)]=(3+7)=(3)+(7)[f(x)+g(x)]=3()+7()[f(x)+g(x)]=3(2x)+7(4)[f(x)+g(x)]=6x+28
2
x
4
x
d
dx
d
dx
2
x
4
x
d
dx
2
x
d
dx
4
x
d
dx
d
dx
2
x
d
dx
4
x
d
dx
3
x
d
dx
3
x
(
25
)In[]:=
D[3+7,x]
2
x
4
x
Out[]=
6x+28
3
x
The result would be the same if we consider a problem with the difference of two functions.
Problem 6.4.3.1 Calculate the first derivative with respect to of the sum of two function in ().
x
3-7
2
x
4
x
(
26
)The solution is shown in () and then confirmed using code.
f(x)-g(x)=3-7[f(x)+g(x)]=(3+7)=(3)-(7)[f(x)+g(x)]=3()-7()[f(x)+g(x)]=3(2x)-7(4)[f(x)+g(x)]=6x-28
2
x
4
x
d
dx
d
dx
2
x
4
x
d
dx
2
x
d
dx
4
x
d
dx
d
dx
2
x
d
dx
4
x
d
dx
3
x
d
dx
3
x
(
27
)In[]:=
D[3-7,x]
2
x
4
x
Out[]=
6x-28
3
x
6.4.4 Power rule
6.4.4 Power rule
Here we consider the product of two functions and . The product rule is shown in ().
g(x)
h(x)
d
dx
(
28
)Some mathematicians use the short-hand and such that the first derivative with respect to of can be written as (which might be easier to remember).
g(x)=u
h(x)=v
x
f(x)=g(x)h(x)
u'v-uv'
Problem 6.4.4.1 Calculate the first derivative with respect to of the function in ().
x
f(x)=sin(x)
2
x
(
29
)Here we have that and . We use the power rule in () to calculate the derivative in (), where we have that with , and with such that .
g(x)=
2
x
h(x)=sin(x)
u=
2
x
u'=2x
v=sin(x)
v'=cos(x)
f'(x)=u'v-uv'
f'(x)=(2x)[Sin(x)]+()[cos(x)]f'(x)=2xsin(x)+cos(x)
2
x
2
x
(
30
)The result is confirmed using code.
In[]:=
D[Sin[x],x]
2
x
Out[]=
2
x
The results is confirmed other than the Wolfram Language returning a reversed order of the terms.
6.4.5 Quotient rule
6.4.5 Quotient rule
Here we also consider two functions and such that . The quotient rule is shown in ().
g(x)
h(x)
h(x)!=0
f(x)==
g(x)
h(x)
d
dx
g(x)
h(x)
g(x)h'(x)-g'(x)h(x)
h
2
(x)
(
31
)Note that the denominator is the square of .
h(x)
If we use similar short-hand notation as let and , then we can write the quotient rule as in ().
g(x)=u
h(x)=v
d
dx
u
v
uv'-u'v
2
v
(
32
)
Problem 6.4.5.1 Calculate the first derivative with respect to of the function in ().
x
f(x)=
cos(x)
3
x
(
33
)It is important to note that this function has a discontinuity at and is not differentiable at . The solution is shown in (), where we make use of the short-hand notation and let and =v.
x=0
x=0
cos(x)=u
3
x
f'(x)=f'(x)=f'(x)=f'(x)=-f'(x)=-
u'v-uv'
2
v
[-sin(x)()]-[cos(x)(3)]
3
x
2
x
2
()
3
x
-sin(x)-3cos(x)
3
x
2
x
6
x
-sin(x)
3
x
6
x
3cos(x)
2
x
6
x
-sin(x)
3
x
3cos(x)
4
x
(
34
)The code below confirms the result.
In[]:=
D,x
Cos[x]
3
x
Out[]=
--
3Cos[x]
4
x
Sin[x]
3
x
6.4.6 Chain rule
6.4.6 Chain rule
The chain rule is commonly used as many problems present themselves as the composition of two functions, shown in ().
f(x)=g[h(x)]
(
35
)Consider the function and the function . The composition of functions plugs into and hence the in is replaces by such that .
g(x)=
2
x
h(x)=sin(x)
g[h(x)]
h(x)
g(x)
x
g(x)
sin(x)
f(x)=
2
[sin(x)]
The chain rule is demonstrated in ().
f'(x)=g'[h(x)]h'(x)
(
36
)It is easier to solve derivatives of the composition of functions using -substitution. The problem below demonstrates this technique.
u
Problem 6.4.6.1 Calculate the first derivative with respect to of the function in ().
x
f(x)=
2
[sin(x)]
(
37
)To solve this problem, we make the substitution in (), where we introduce the function .
u
Letu(x)=sin(x)
(usubstitution)
(
38
)We can now write ().
du
dx
(
39
)We can also rewrite the original problem with the substitution and take the first derivative, as shown in ().
f(u)=()=2u
2
u
d
du
2
u
(
40
)Now we have ().
f'(x)=2u[cos(x)]
(
41
)After back-substitution we have ().
f'(x)=2sin(x)cos(x)
(backsubstitution)
(
42
)The result is confirmed using code.
In[]:=
D[,x]
2
Sin[x]
Out[]=
2Cos[x]Sin[x]
It is often easier to consider the derivative of the composition of functions using -substitution as shown in ().
u
d
dx
df
du
du
dx
(
43
)In Problem 6.4.6.1 we wrote for which the first derivative with respect to is . We also made the substitution and the derivative of with respect to is . The product of these two derivatives (with back-substitution) is .
f(u)=
2
u
u
2u
u(x)=sin(x)
u
x
cos(x)
2sin(x)cos(x)
The chain rule can help us save some computation as we explore in the next problem.
Problem 6.4.6.2 Calculate the first derivative with respect to of the function in ().
x
f(x)=
4
(x-3)
(
44
)We could expand but that requires a lot of computation. Instead, we use the chain rule.
4
(x-3)
Using -substitution we have that and . Using (43), we calculate the derivative in ().
u
u(x)=x-3
f(u)=
4
u
f'(x)=(1)f'(x)=4
df
du
du
dx
(chainrule)
f'(x)=43
u
3
(x-3)
(backsubstitution)
(
45
)The code below confirms the result.
In[]:=
D[,x]
4
(x-3)
Out[]=
4
3
(-3+x)
We look at another similar problem.
Problem 6.4.6.3 Calculate the first derivative with respect to of the function in ().
x
f(x)=
2
(-+3)
3
x
2
x
(
46
)Using -substitution we have that and . Using (43), we calculate the derivative in ().
u
u(x)=-+3
3
x
2
x
f(u)=
2
u
f'(x)=-2x)(2u)f'(x)=(3-2x)[2(-+3)]
df
du
du
dx
(chainrule)
f'(x)=(32
x
2
x
3
x
2
x
(backsubstitution)
(
47
)The code below confirms the result.
In[]:=
D[,x]
2
(-+3)
3
x
2
x
Out[]=
2(-2x+3)(3-+)
2
x
2
x
3
x
In the previous problem we considered the square of a polynomial. We can also calculate the square root of a polynomial using the chain rule.
Problem 6.4.6.4 Calculate the first derivate with respect to of the function in ().
f(x)=
16-
2
x
(
48
)We rewrite the problem using -substitution and use the chain rule in ().
u
f(x)=u(x)=16-=-2xf(u)====(-2x)=(-2x)=(-2x)=-=-
1
2
(16-)
2
x
2
x
(usubstitution)
du
dx
1
2
u
df
du
1
2
-
1
2
u
df
dx
df
du
du
dx
(chainrule)
df
dx
1
2
-
1
2
u
df
dx
1
2
-
1
2
u
df
dx
1
2
u
df
dx
x
u
df
dx
x
16-
2
x
(backsubstitution)
(
49
)We confirm the result with code.
In[]:=
D
16-
,x2
x
Out[]=
-
x
16-
2
x
We have explore the first derivative of the function . We can use the chain rule to solve for more complication functions of the natural logarithm.
Problem 6.4.6.5 Calculate the first derivate with respect to of the function in (), where .
a∈
f(x)=ln(x+a)
(
50
)We solve the problem in () where we use the substitution .
f(x)=ln(x+a)u(x)=x+a=1f(u)=ln(u)===(1)=
du
dx
df
du
1
u
df
dx
df
du
du
dx
df
dx
1
u
df
dx
1
x+a
(
51
)We confirm the result with code.
In[]:=
D[Log[x+a],x]
Out[]=
1
a+x