Download as pdf or txt
Download as pdf or txt
You are on page 1of 43

3 — Differentiation (Part I)

3.1 Definition of Derivatives


3.1.1 Slope of Tangent
Let f : D ! R be a function whose graph is given as in Figure 3.1. Fix a point (a, f (a)) on the
graph of f , and draw a tangent line which touches the graph at the point (a, f (a)). We ask: what
is the slope of this tangent?
Let’s consider another point (a+h, f (a+h)) on the graph which is slightly away from (a, f (a)).
Draw a straight-line Lh passing through both (a, f (a)) and (a + h, f (a + h)). Then the slope of
this straight-line Lh is given by:

f (a + h) f (a) f (a + h) f (a)
mh = =
(a + h) a h

Figure 3.1: tangent at x = a is the limit of line Lh as h ! 0

Let h approach 0, then this straight-line will get closer and closer to the tangent line at
(a, f (a)). Therefore, the slope of tangent at (a, f (a)) can be thought as the limit of mh as h ! 0.
To conclude, the slope of tangent to the graph y = f (x) at the point (a, f (a)) is given by:

f (a + h) f (a)
lim .
h!0 h
80 Differentiation (Part I)

p
⌅ Example 3.1 Find the slope of tangent to the graph y = x at the point (1, 1). Write down
the equation of this tangent.

p
⌅ Solution Let f (x) = x, Based on the above discussion, the required slope is given by:
p
f (1 + h) f (1) 1+h 1
lim = lim
h!0 h h!0 h
p p
1+h 1 1+h+1
= lim ·p
h!0 h 1+h+1
1+h 1
= lim p
h!0 h( 1 + h + 1)

1
= lim p
h!0 1+h+1
1 1
=p = .
1+0+1 2

Now we know the slope of the required tangent is 12 , and this tangent passes through (1, 1).
Therefore, the equation of the tangent is:
y 1 1 1 1
= , or equivalently, y = x + .
x 1 2 2 2

3.1.2 Derivative of a function


Due to the geometric significance of the limit

f (a + h) f (a)
lim ,
h!0 h
we have a special name and symbol for it:
Definition 3.1 — Derivative. Let f : D ! R be a function, and a 2 D. We denote:

f (a + h) f (a)
f 0 (a) = lim
h!0 h
and it is called the derivative of f at a.

Take f (x) = x2 as an example. To find f 0 (a), we evaluate the limit:

f (a + h) f (a)
f 0 (a) = lim
h!0 h
(a + h)2 a2
= lim
h!0 h
a2 + 2ah + h2 a2
= lim
h!0 h
2ah + h2
= lim
h!0 h
= lim 2a + h
h!0
= 2a.

Using this result, to find the slope of tangent at (⇡, f (⇡)), we do not need to compute the
limit again. We may simply substitute a = ⇡, then we get: f 0 (⇡) = 2⇡ and it will be the slope of
the required tangent.
Therefore, the given value a can be regarded as the input of f 0 , and the output f 0 (a) is the
slope of tangent at a. As such, f 0 (a) can be regarded as a function of a. The generic symbol for
3.1 Definition of Derivatives 81

the independent variable is x, so instead of using a as the variable, we often write:

f (x + h) f (x)
f 0 (x) = lim
h!0 h

which is regarded as a new function f 0 : D ! R. If f (x) = x2 , from the above computation we


have f 0 (x) = 2x.
There are many equivalent notations for f 0 (x). We will frequently use:
Notation
d df
f 0 (x) =
f (x) =
dx dx
The second notation is more common when we do not label the function. For instance, we
can write:
d
x2 + 5x
dx
to mean f 0 (x) where f (x) = x2 + 5x.

Since f 0 can be regarded as a function derived from f , we call f 0 the derivative of f . The
process of finding f 0 from f is called differentiation. The problem of finding the derivative
of f is usually rephrased as: Differentiate the function f .

3.1.3 Derivative of powers


In this last chapter, we have seen that if f (x) = x2 , then f 0 (x) = 2x. Here we derive a more
general result:
Proposition 3.1
d n
x = nxn 1
(3.1)
dx
for any positive integer n.

Proof.

d n (x + h)n xn
x = lim
dx h!0 h
xn + C1n xn 1 h + C2n xn 2 h2 + . . . + hn xn
= lim
h!0 h
xn + nxn 1 h + C2n xn 2 h2 + . . . + hn xn
= lim
h!0 h
nxn 1 h + C2n xn 2 h2 + C3n xn 3 h3 + . . . + hn
= lim
h!0 h
= lim nxn 1 + C2n xn 2 h + C3n xn 3 h2 + . . . + hn 1
h!0
= nxn 1

Proposition 3.2
d
c=0 (3.2)
dx
for any real constant c.
82 Differentiation (Part I)

Proof. Let f (x) = c, the constant function

d
c = f 0 (x)
dx
f (x + h) f (x)
= lim
h!0 h
c c
= lim
h!0 h
0
= lim
h!0 h
= lim 0
h!0
= 0.

i When h ! 0, the value of h is regarded to be very close to 0 but is not yet equal to 0.
Therefore, the fraction h0 as h ! 0 is regarded as a genuine 0, and so we have:

0
lim = lim 0.
h!0 h h!0

Do not get confused with the discussion of limits of the form 0


0
in the previous chapter!

Proposition 3.3
d p 1
x= p for x > 0 (3.3)
dx 2 x

Proof.
p p
d p x+h x
x = lim
dx h!0 h
p p p p
x+h x x+h+ x
= lim ·p p
h!0 h x+h+ x
p 2 p 2
x+h ( x) 1
= lim ·p p
h!0 h x+h+ x
x+h x
= lim p p
h!0 h x+h+ x
h
= lim p p
h!0 h x+h+ x
1
= lim p p
h!0 x+h+ x
1
=p p
x+0+ x
1
= p
2 x

⌅ Exercise 3.1 ✓ ◆
d 1 1
= for x 6= 0 (3.4)
dx x x2
3.1 Definition of Derivatives 83

Unless otherwise is stated, we can make use of (3.1)-(3.4) without re-proving them. A more
careful look into these rules reveal that they have the same pattern:
d n
x = nxn 1
for any positive integer n
dx
d 0 d
x = 1 = 0 = 0 · x0 1
dx dx
d 1 d p 1 1 1 1 1
x2 = x = p = · x 2 = · x1 2
dx dx 2 x 2 2
✓ ◆
d d 1 1
x 1 = = = ( 1)x 1 1
dx dx x x2

We speculate that whether the rule dx x = axa 1 is true in general for any real number a. It is
d a

indeed true but the proof will be postponed after we introduce the chain rule. Let’s first state it
as a theorem:
Theorem 3.4 — Power Rule.
d a
x = axa 1
(3.5)
dx
for any a 2 R.

3.1.4 Derivative of exponential functions


Let a > 1 be a fixed number. The function f : R ! R given by f (x) = ax is called the exponential
function. It is different xa discussed in the previous subsection, where we have dx x = axa 1 .
d a

Be cautious it is NOT true that:


d x
a = xax 1
INCORRECT!
dx
To derive the correct rule for ax , first recall a result proved in Example 2.13:

ah 1
lim = ln a (3.6)
h!0 h
We will use this result to derive the following rule:
Theorem 3.5 — Exponential Rule. For any a > 1, we have:

d x
a = ax ln a (3.7)
dx
xex."
e
u"
In particular,
=

1
d x
e = ex . (3.8)
x

= &

dx

Proof. ah
"

Let a 1 gt 1 =

y
= -

。 哈

h- →
,
y → 0 h =

logalyts }
d x ax+h ax
0

=
dx
a = lim
h!0 h mg

瓷肚州冰您
ax ah a x
= lim
h


h!0
w

= lim
x h
a (a 1) 以凸
h!0 h
a h
1 ”
= ax lim
lua

h!0 h =

= ax ln a (using Example 2.13)

The rule (3.8) follows easily from the fact that ln e = 1. ⌅


84 Differentiation (Part I)

i By observing the rules (3.7) and (3.8), we see that the exponential function ex behaves
most naturally among other exponential functions ax under differentiation. Therefore, we
call the number e to be the natural number.

3.1.5 Derivative of logarithms


The inverse function of f (x) = ax is the logarithm function f 1
(x) = loga x. The rule below
shows how we can differentiate logarithmic functions:
Theorem 3.6 — Logarithmic Rule. Let a > 1 be a constant. Then, we have:

d 1
loga x = for x > 0 (3.9)
dx x ln a
In particular when a = e, we have:

d 1
ln x = for x > 0 (3.10)
dx x

Proof.

d loga (x + h) loga x
loga x = lim
dx h!0 h
✓ ◆
1 x+h
= lim loga
h!0 h x
✓ ◆1
h h
= lim loga 1 +
h!0 x
✓ ◆y
1 x x 1 y
= lim loga 1 + (Let y = , then = )
y!1 y h h x
✓ ◆y
1 1
= lim loga 1 +
y!1 x y
✓ ◆y
1 1
= loga lim 1 + (since loga is continuous)
x y!1 y
1
= loga e
x
1 ln e 1
= = .
x ln a x ln a

i In HKDSE M2, the exam papers often use the term “from first principles” to mean finding
f (x + h) f (x)
f 0 (x) from the limit lim . Note that this particular limit is not really called
h!0 h
“first principles”. The term “first principles” has a much broader meaning, and it means that
you need work out the problem from scratch without using any well established theorems
or rules. In the context of finding derivatives, it means you cannotp use any rules such as
product rule, quotient rule, chain rule, etc. If one asks that “Prove 10 is irrational from p
first principles”, it means that your proof cannot use other established results such as 2
being irrational or other advanced theorems in number theory. It doesn’t mean you need to
prove it by finding derivatives from the above limit.

3.1.6 Derivatives of Sine and Cosine Functions


Next we find out the derivatives of sin x and cos x. After introducing other rules, such as product
rule, quotient rule, and chain rule, we will find out the derivatives of other trigonometric functions
such as tan x as well.
3.1 Definition of Derivatives 85

Theorem 3.7 — Derivatives of Sine and Cosine Functions.

d d
sin x = cos x cos x = sin x
dx dx

Proof. We will make use of the result:

sin x
lim = 1,
x!0 x

the sum-of-angle formulae:

sin(A + B) = sin A cos B + cos A sin B


cos(A + B) = cos A cos B sin A sin B

and the half-angle formula:


1 cos A A
= sin2 .
2 2
We first prove the derivative for sin x:

d sin(x + h) sin x
sin x = lim
dx h!0 h
sin x cos h + cos x sin h sin x
= lim
h!0 h
✓ ◆
(cos h 1) sin h
= lim sin x · + cos x ·
h!0 h h

(cos h 1)
We claim that lim = 0. To show this, we use the half-angle formula:
h!0 h

cos h 1 2 sin2 h2
lim = lim
h!0 h h!0 h
2 h
sin
= lim h 2
h!0
2
sin h2 h
= lim h
· sin
h!0
2
2
= 1 · 0 = 0.

Substitute it back in, we get:

d
sin x = sin x · 0 + cos x · 1 = cos x.
dx

Next we prove the derivative rule for cos x:

d cos(x + h) cos x
cos x = lim
dx h!0 h
cos x cos h sin x sin h cos x
= lim
h!0 h
✓ ◆
cos h 1 sin h
= lim cos x · sin x ·
h!0 h h
= cos x · 0 sin x · 1 = sin x.


86 Differentiation (Part I)

Alternatively, one can derive the above results using sum-to-product formula instead:
A+B A B
sin A sin B = 2 cos sin ,
2 2
A+B A B
cos A cos B = sin sin .
2 2
Using these, one can write

(x + h) + x (x + h) x 2x + h h
sin(x + h) sin x = 2 cos sin = 2 cos sin ,
2 2 2 2
(x + h) + x (x + h) x 2x + h h
cos(x + h) cos x = 2 sin sin = 2 sin sin .
2 2 2 2
We leave it as an exercise for readers to complete the rest of the proof.

⌅ Exercise 3.2 Derive sin x = cos x and dx


d
dx
d
cos x = sin x again using sum-to-product
formulae instead of compound- and half-angle formulae.

⌅ Exercise 3.3 — Source: modified from HKDSE M2 past exams, 2012-2022. Find the derivative
f 0 (x) of the following
p functions from first principles:
(a) f (x) = 2x
(b) f (x) = e2x
(c) f (x) = sin 2x
(d) f (x) = x3 3x
(e) f (x) = x 5
r+4
3
(f) f (x) =
x
1
(g) f (x) =
cos(6x)
(h) f (x) = (x2 1)ex
10x
(i) f (x) =
7 + 3x2
x
(j) f (x) = p , where x > 2.
2+x
1
(k) f (x) = 2
3x + 4
1
(l) f (x) = p , where x > 0.
5x + 4
f( x
) =
fanx =
sx
fx osxtx =
)
( =
seixa
=
x
3.2 Differentiability 87

3.2 Differentiability
Recall that the derivative f 0 of a function f is defined by the limit:

f (x + h) f (x)
f 0 (x) = lim .
h!0 h

We have seen some examples of limits that may not exist, especially when the function in-
volved is piecewise defined. Therefore, f 0 (x) which is defined by a limit may not always
exist.
Definition 3.2 — Differentiable Functions. Given a function f : R ! R, if the limit:

f (a + h) f (a)
lim
h!0 h
exists, then we say the f is differentiable at a.
Furthermore, if f is differentiable at every point a in an interval I, then we say that
f is differentiable on I. If f is differentiable on R, we may also say f is differentiable
everywhere.

3.2.1 Functions with “corners”


Consider the absolute value function:
(
x if x 0
f (x) =
x if x < 0

Let’s try to compute f 0 (0) from the limit definition:

f (0 + h) f (0)
f 0 (0) = lim
h!0 h
|h|
= lim
h!0 h

However, the left- and right-hand limits are not equal, since:

|h| h
lim = lim (since h < 0 when h ! 0 )
h!0 h h!0 h
= 1
|h| h
lim = lim+ (since h > 0 when h ! 0+ )
h!0+ h h!0 h
= 1.

Therefore, f 0 (0) does not exist, and so we say f is not differentiable at 0.


Yet f is differentiable at any other point a 6= 0. Suppose a < 0 (the case a > 0 is similar),
then:
f (a + h) f (a) |a + h| |a|
f 0 (a) = lim = lim
h!0 h h!0 h
When h ! 0, h is very small. If a < 0, then a + h is negative as well. Therefore, we have
|a + h| = a h and |a| = a, and so:

( a h) ( a) h
f 0 (a) = lim = lim = 1.
h!0 h h!0 h

Similarly, one can also show f 0 (a) = 1 if a > 0. Therefore, f is differentiable at any a 6= 0.

⌅ Exercise 3.4 Given that f (x) = |x|, show that f 0 (a) = 1 for any a > 0.
88 Differentiation (Part I)

Since checking whether f 0 (a) exists often require us to verify if the following left- and
right-limits are equal:

f (a + h) f (a) f (a + h) f (a)
lim and lim ,
h!0+ h h!0 h

we give these two limits special symbols:


Definition 3.3 — One-Sided Derivatives. Given a function f : R ! R, we define:

0 f (a + h) f (a)
f+ (a) = lim+
h!0 h
f (a + h) f (a)
f 0 (a) = lim
h!0 h
which is called the right-hand and left-hand derivatives respectively. f is differentiable at a if
and only if both f+0
(a) and f 0 (a) exist and they are equal.

Geometrically, f+ 0
(a) is the slope of tangent from the right while f 0 (a) is the slope of tangent
from the left. If they don’t match, the graph of the function will have a sharp corner at a. See the
graph of |x| as an example.

⌅ Example 3.2 Determine whether or not the following function is differentiable at x = 1?


(
x2 if x  1
f (x) = .
2x 1 if x > 1

⌅ Solution

0 f (1 + h) f (1)
f+ (1) = lim
h!0+ h
2(1 + h) 1 12
= lim+ (as h ! 0+ , we have 1 + h > 0)
h!0 h
2h
= lim+ = lim+ 2
h!0 h h!0
= 2.

f (1 + h) f (1)
f 0 (1) = lim
h!0 h
2
(1 + h) 12
= lim (as h ! 0 , we have 1 + h < 0)
h!0 h
1 + 2h + h2 1
= lim = lim (2 + h)
h!0 h h!0
= 2.

Since f+
0
(1) = f 0 (1) = 2, f is differentiable at x = 1 with f 0 (1) = 2.
3.2 Differentiability 89

⌅ Exercise 3.5 Determine whether or not the following function is differentiable at x = 0.


|x|
(a) f (x) =
x 1
(b) f (x) = x |x|
(c) f (x) = x3

3.2.2 Functions with vertical tangent


Another type of functions which are not differentiable at some point are those with vertical
tangent, whose slope is infinite. Here is an example: Let f : R ! R be defined by:
p
3
f (x) = x.

Let’s attempt to find f 0 (0):

f (0 + h) f (0)
lim
h!0 h
p3
h 0
= lim
h!0 h
h1/3
= lim
h!0 h
1
= lim 2/3
h!0 h
=1

Therefore, f is not differentiable at 0. The geometric intuition here is that the tangent at 0 is
vertical.
p
⌅ Exercise 3.6 Show that for any p 2 (0, 1), the function f (x) = |x| is not differentiable at
x = 0. Is it differentiable at any x = a, where a 6= 0?

3.2.3 Differentiability implies continuity


Theorem 3.8 Let f : R ! R be a function. If f is differentiable at a, then f is also continuous
at a.

Proof. Suppose f is differentiable at a, then the limit:

f (a + h) f (a)
lim
h!0 h
exists.
90 Differentiation (Part I)

By substitution, x = a + h (regarding a is fixed, and h is variable), we have:

f (a + h) f (a) f (x) f (a)


f 0 (a) = lim = lim .
h!0 h x!a x a
Then:

f (x) f (a)
lim · (x a) = lim f (x) f (a)
x!a x a x!a

f (x) f (a)
lim · lim (x a) = lim f (x) f (a)
x!a x a x!a x!a

f 0 (a) · 0 = lim f (x) f (a)


x!a
lim f (x) = f (a).
x!a

Therefore, f is continuous at a. ⌅

i Note that the converse of Theorem 3.8 is NOT true. If f is continuous at a, it may not
imply f is differentiable at a. A counterexample is f (x) = |x|: f is continuous at 0, but not
differentiable there.

⌅ Example 3.3 Suppose f : R ! R is a function defined by:


8
>
<2x + 5 if x < 2
f (x) = a if x = 2
>
: 2
bx + c if x > 2

Find all possible value(s) of a, b and c such that f is differentiable at 2.

⌅ Solution From the given information about f , we can first find out:

lim f (x) = lim (2x + 5) = 9.


x!2 x!2

Given that f is differentiable at 2, it is also continuous at 2. Hence the limit lim f (x) exists,
x!2
and:
lim f (x) = f (2) .
| {z } |{z}
x!2
=a
=9

Therefore, a = 9.
Again, using the fact that lim f (x) exists, we have:
x!2

lim f (x) = lim f (x) .


x!2+ x!2
| {z } | {z }
=4b+c =9

We get the equation:


4b + c = 9
HKAI 2012 ,
Paper 2

i
is differentiable
f
Given
f( π ) = -

f (π )
ranstant
' =
3

gx )
: =

{ fgtxt
≤π if x

osx if x >π

Given :
is continwous at X =π
g
-
la Fiadk

Ib Is diff at x =π ?
g

Am :
(a) g (
x) =

g ( x)
=

g (π )
( gi cts at π )

+ asx =π f + xtk )= (
f
( a ) tatk ( f is diff "
→ f os → 1 f(
π x ) =
f( )
π

1 = f Ha) tatk

1 = -

1 tatk

k = -

πth
(b gi = —
g
π) 0

( 了⼀州⼀州

π
= —
h

。+∞洲
s

= = 0
,

i i
sitmUtAtLMM

tmtG了

f
'例t
(
1 =
3+ 1 =
4 ( Fom definitionof [ f
)
π
)
# (π )
g +

∴ g

is not difft al x=π .


3.2 Differentiability 91

In order for f to be differentiable at 2, we need f+


0
(2) = f 0 (2), so we compute:

f (2 + h) f (2)
f 0 (2) = lim
h!0 h
2(2 + h) + 5 9
= lim
h!0 h
2h
= lim
h!0 h
=2
0 b(2 + h)2 + c 9
f+ (2) = lim+
h!0 h
4b + 4bh + bh2 + c 9
= lim+
h!0 h
4bh
= lim+ (from 4b + c = 9)
h!0 h
= 4b.

Therefore, we must have 4b = 2 and so b = 12 . Substitute into the equation 4b + c = 9, we get


c = 7. To conclude, (a, b, c) = (9, 12 , 7).

⌅ Example 3.4 — Source: Modifed from HKALE Pure Math 2012, Paper 2, Q1. Given that
f : R ! R is a differentiable function satisfying f (⇡) = 1 and f 0 (⇡) = 3. Let k be a real
constant and g : R ! R be defined by
(
f (x) + x + k if x  ⇡
g(x) = .
cos x if x > ⇡

Suppose that g(x) is continuous at x = ⇡.


(a) Find k.
(b) Is g differentiable at x = ⇡?

⌅ Solution (a) Given that g(x) is continuous at x = ⇡, we have

lim g(x) = g(⇡) = lim+ g(x).


x!⇡ x!⇡

Let’s compute them one-by-one:

lim g(x) = lim (f (x) + x + k)


x!⇡ x!⇡
= f (⇡) + ⇡ + k (since f is differentiable, so it is continuous)
= 1 + ⇡ + k.

lim g(x) = lim cos x


x!⇡ + x!⇡ +
= cos(⇡) (cos x is continuous)
= 1.

Also, we are given that g(⇡) = f (⇡) + ⇡ + k = 1 + ⇡ + k. Hence, we must have

1+⇡+k = 1 =) k = ⇡.
92 Differentiation (Part I)

(b) We need to find g+


0
(⇡) and g 0 (⇡) and see if they agree.

0 g(⇡ + h) g(⇡)
g+ (⇡) = lim+
h!0 h
cos(⇡ + h) (f (⇡) + x + k)
= lim+
h!0 h
cos h ( 1 + ⇡ ⇡)
= lim+
h!0 h
1 cos h 2 sin2 h2
= lim = lim
h!0+ h h!0+ h
h
h sin 2
= lim+ sin · h
h!0 2 2
0
= sin · 1 = 0.
2

g(⇡ + h) g(⇡)
g 0 (⇡) = lim
h!0 h
f (⇡ + h) + (⇡ + h) + k f (⇡) + ⇡ + k
= lim
h!0 h
f (⇡ + h) f (⇡) + h
= lim
h!0 h
✓ ◆
f (⇡ + h) f (⇡)
= lim , 1
h!0 h
= f 0 (⇡) ⼈ 1=3 ) 1 = 2.
细⼭

Therefore, g+
0
(⇡) 6= g 0 (⇡). This shows g is not differentiable at x = ⇡.

⌅ Exercise 3.7 — Source: Modified from HKALE Pure Math 2008, Paper 2, Q2. Let a and b be real
constants, and f : R ! R be defined as
8 p
<2 + a 1 x
if x < 0
f (x) = x .
:
1 + b tan x8 if x 0

It is given that f (x) is differentiable at x = 0. Find a and b.

⌅ Exercise 3.8 — Source: HKALE Pure Math 2004, Paper 2, Q2. Let a and b be real constants, and
f : R ! R be defined as (
x2 + ax + b if x  1
f (x) = .
sin ⇡x
⇡ if x > 1
Given that f is differentiable at x = 1, find a and b.

⌅ Exercise 3.9 — Source: HKALE Pure Math 1999, Paper 2, Q5. Let a and b be real constants and
f : R ! R be defined as (
x2 cos x1 if x > 0
f (x) = .
ax + b if x  0
Given that f is differentiable at x = 0, find a and b.
Eracia 3

If f[ a) =

gx) on Ia b ]
,

then f' x = '( )

g
(x ) on ( a
,
b)
3.2 Differentiability 93

⌅ Example 3.5 — Source: Extracted from HKALE Pure Math 2003, Paper 2, Q8. Let f : R ! R be
a non-constant function satisfying two conditions:
(1) f (x + y) = f (x) + f (y) + f (x)f (y) for all x, y 2 R; and
f (h)
(2) lim = a, where a 2 R is a constant.
h!0 h
Show that f is differentiable everywhere.

⌅ Solution For any x 2 R, we consider

f (x + h) f (x)
= lim
h!0 h
f (x) + f (h) + f (x)f (h) f (x)
= lim (by (1))
h!0 h
f (h) 1 + f (x)
= lim
h!0 h
f (h)
= lim · (1 + f (x))
h!0 h
= a(1 + f (x)),

where the last step follows from (2), and that x is regarded as a constant when h ! 0.
Therefore f (x) is differentiable at any x 2 R, with f 0 (x) = a(1 + f (x)).

⌅ Exercise 3.10 — Source: Extracted/Modified from HKALE Pure Math 2012, Paper 2, Q8. Let
f : R ! R be a function satisfying the following conditions:
(1) f (x + y) = f (x)f (y) f (x) f (y) + 2 for all x, y 2 R; and
(2) there exists a unique real number r such that f (r) = 2.
Answer the following questions:
(a) Show that if there exists a 2 R such that f (a) = 1, then f is a constant function.
(b) Show that f (0) = 2.
(c) Show that f is injective. [Hint: suppose f (x) = f (y) for some x, y 2 R, then consider
f (x y) + y .]
(d) Given that f is differentiable at x = 0. Show that f is differentiable everywhere, and
f 0 (x) = f 0 (0)(f (x) 1)

⌅ Exercise 3.11 — Source: Modified from HKALE Pure Math 1992, Paper 2, Q7. Let f be a
differentiable function such that

f (x + y) = f (x) + f (y) + 3xy(x + y) 8x, y 2 R.

(a) Show that f (0) = 0.


(b) Show that for any x 2 R, we have f 0 (x) = f 0 (0) + 3x2 .
94 Differentiation (Part I)

3.3 Differentiation Rules


So far we have been doing differentiation from the definition of derivatives (aka first principles in
DSE M2). That may be necessary for those piecewise defined functions, but for most elementary
functions, it could be very time consuming. To get a taste of how tedious it could be, try to find
f 0 for the function (just for example):

x2 + 1
f (x) = .
x3+x+1
In this section, we will discuss several rules that allow us to differentiate a function in a more
efficient way. These rules are listed below:
Theorem 3.9 — Rules for Differentiation. Given two functions f and g, then at a point x where
they are both differentiable, we have:

d d d
(f (x) + g(x)) = f (x) + g(x)
dx dx dx
d d d
(f (x) g(x)) = f (x) g(x)
dx dx dx
d d
(cf (x)) = c f (x) where c is any real constant
dx dx
d
f (x)g(x) = f 0 (x)g(x) + f (x)g 0 (x) (Product Rule)
dx ✓ ◆
d f (x) g(x)f 0 (x) f (x)g 0 (x)
= if g(x) 6= 0 (Quotient Rule)
dx g(x) g(x)2

Proof. The proof is basically by rearranging the terms in the limit definition of derivatives (first
principles).

d f (x + h) + g(x + h) f (x) + g(x)


(f (x) + g(x)) = lim
dx h!0 h
✓ ◆
f (x + h) f (x) g(x + h) g(x)
= lim +
h!0 h h
f (x + h) f (x) g(x + h) g(x)
= lim + lim
h!0 h h!0 h
= f 0 (x) + g 0 (x).

The last step follows from the fact that f and g are differentiable at x.
The rules
d d d d d
(f (x) g(x)) = f (x) g(x) and (cf (x)) = c f (x)
dx dx dx dx dx
can be proved in similar ways.
For the product rule, we consider:

d f (x + h)g(x + h) f (x)g(x)
f (x)g(x) = lim
dx h!0 h
f (x + h)g(x + h) f (x)g(x + h) + f (x)g(x + h) f (x)g(x)
= lim
h!0 h
✓ ◆
f (x + h) f (x) g(x + h) g(x)
= lim · g(x + h) + f (x) · .
h!0 h h

Since g is differentiable at x, it is also continuous at x. Therefore

lim g(x + h) = g(x + 0) = g(x).


h!0
3.3 Differentiation Rules 95

Combining with the fact that

f (x + h) f (x) g(x + h) g(x)


lim = f 0 (x) and lim = g 0 (x),
h!0 h h!0 h
we conclude that
d
f (x)g(x) = f 0 (x)g(x) + f (x)g 0 (x),
dx
which is exactly the product rule.
Finally, for the quotient rule, since fg(x)
(x) 1
= f (x) · g(x) , we will first derive the rule for dx g(x) ,
d 1

and then apply the product rule to derive the quotient rule.

1 1
d 1 g(x+h) g(x)
= lim
dx g(x) h!0 h
1 g(x) g(x + h)
= lim ·
h!0 h g(x)g(x + h)
g(x + h) g(x) 1 1
= lim · ·
h!0 h g(x) g(x + h)

Again as g is continuous at x, we have lim g(x + h) = g(x). Therefore, we conclude that


h!0

d 1 1 1 g 0 (x)
= g 0 (x) · · = .
dx g(x) g(x) g(x) g(x)2

Now, combining with the product rule, we can derive that

d f (x) d 1
= f (x) ·
dx g(x) dx g(x)
1 d 1
= f 0 (x) · + f (x)
g(x) dx g(x)
f 0 (x) g 0 (x)
= f (x) ·
g(x) g(x)2
f (x)g(x) f (x)g 0 (x)
0
=
g(x)2

as desired. ⌅

⌅ Exercise 3.12 Derive, from the definition of derivative, that for a differentiable function f ,
we have
d 1 2f 0 (x)
= .
dx f (x)2 f (x)3

⌅ Exercise 3.13 Using the product rule and induction, show that if f is differentiable, then

d n 1 0
f (x)n = n f (x) f (x)
dx
for any n 2 N.
d n 1 0
Hence, prove also that f (x) n = ( n) f (x) f (x) for any n 2 N.
dx
d n 1 0
[Remark: Combining the results, this show the rule f (x)n = n f (x) f (x) for any
dx
n 2 Z. Note that the result is trivial when n = 0.]
96 Differentiation (Part I)

⌅ Example 3.6 Differentiate each of the following functions:


x2 + 1
1. f (x) =
x3 +x+1
2. g(x) = xe x

ln x
3. h(x) = p
x

⌅ Solution
d d
(x3 + x + 1) dx (x2 + 1) (x2 + 1) dx (x3 + x + 1)
f 0 (x) =
(x3 + x + 1)2
(x + x + 1)(2x) (x2 + 1)(3x2 + 1)
3
=
(x3 + x + 1)2
2x + 2x + 2x 3x4 x2 3x2 1
4 2
=
(x3 + x + 1)2
4 2
x 2x + 2x 1
=
(x + x + 1)2
3

d x d
g 0 (x) = x e + ex x
dx dx
= xex + ex · 1
= (x + 1)ex

p d d p
x dx ln x ln x · dx x
h0 (x) = p 2
( x)
p 1 1
x · x ln x · 2p x
=
x
p1 ln x
· p1
x 2 x
=
x
p1 1 ln x
x 2
=
x
ln x
1 2
= .
x3/2

⌅ Example 3.7 Suppose f and g are two functions which are differentiable everywhere. Using
the information below:

f (1) = 8, f 0 (1) = 1, g(1) = 3, g 0 (1) = 2

find the value of: ✓ ◆


d x2 f (x)
.
dx g(x) x=1

x2 f (x)
⌅ Solution Be careful that we have to substitute x = 1 after we differentiate the fraction g(x) .
3.3 Differentiation Rules 97

If you substitute then differentiate, you will get a constant and so the derivative would be zero!
✓ ◆ d 2 d
d x2 f (x) g(x) dx x f (x) x2 f (x) dx g(x)
= 2
dx g(x) g(x)
g(x)(2xf (x) + x2 f 0 (x)) x2 f (x)g 0 (x)
=
g(x)2

Substitute x = 1, we get:
✓ 2 ◆
d x f (x) g(1)(2f (1) + f 0 (1)) f (1)g 0 (1)
=
dx g(x) x=1 g(1)2
3 ⇥ (2 ⇥ 8 + 1) 8 ⇥ 2
=
32
35
=
9

⌅ Exercise 3.14 Find f 0 (x) and f 0 (1) of the following function:


(a) f (x) = ln(2x)
(b) f (x) = x ln x
(c) f (x) = ex (1 x3 )
(d) f (x) = 2x log2 x
(e) f (x) = x sin x cos x
1 ex
(f) f (x) =
1 + ex
sin x
(g) f (x) =
cos x

3.3.1 Derivatives of Trigonometric Functions


Now using the product and quotient rules, we are able to derive the differentiation rules for all
six trigonometric functions:
Theorem 3.10 — Derivatives of Trigonometric Functions.

d d
sin x = cos x csc x = csc x cot x
dx dx
d d
cos x = sin x sec x = sec x tan x
dx dx
d d
tan x = sec2 x cot x = csc2 x
dx dx

Proof. We have already proved before that


d d
sin x = cos x cos x = sin x.
dx dx
The other rules follow from the derivatives of sin x and cos x, and the quotient rule. For
instance, the rule for tan x can be derived by considering:
✓ ◆
d d sin x
tan x =
dx dx cos x
d d
cos x · sin x sin x · dx
dx cos x
= 2
cos x
cos x · cos x sin x · ( sin x)
=
cos2 x
cos x + sin2 x
2
1
= = = sec2 x.
cos2 x cos2 x
98 Differentiation (Part I)
g 0 (x)
For csc x, we use the rule that d 1
dx g(x) = g(x)2 :

d d 1
csc x =
dx dx sin x
d
sin x
= dx
(sin x)2
cos x
=
sin2 x
cos x 1
= ·
sin x sin x
= cot x csc x
The proofs of the remaining two are left as exercises. ⌅

⌅ Exercise 3.15 Prove the differentiation rules for d


dx sec x and d
dx cot x.

⌅ Example 3.8 Let


sec x
f (x) = .
1 + tan x
Find all value(s) of a such that the tangent to the graph of f at (a, f (a)) is horizontal.

⌅ Solution Since f 0 (a) is the slope of tangent at (a, f (a)), we need to find all a’s such that
f (a) = 0. First we derive the formula for f 0 (x):
0

✓ ◆
0 d sec x
f (x) =
dx 1 + tan x
d d
(1 + tan x) · sec x sec x · dx
dx (1 + tan x)
= 2
(1 + tan x)
(1 + tan x) sec x tan x sec x · sec2 x
=
(1 + tan x)2
sec x · (tan x + tan2 x sec2 x)
=
(1 + tan x)2
sec x · (tan x + sec2 x 1 sec2 x)
=
(1 + tan x)2
sec x · (tan x 1)
=
(1 + tan x)2

Therefore, f 0 (a) = 0 if and only if:

sec a · (tan a 1) = 0

We get: tan a = 1 (since sec a = 1


cos a 6= 0 for any a), and so a = ⇡
4 + k⇡ for any integer k.

⌅ Exercise 3.16 Find f 0 (x) and f 0 (⇡/4) of the following functions:


(a) f (x) = sec2 x
(b) f (x) = sec2 x tan3 x
(c) f (x) = sec2 x tan3 x csc4 x
(d) f (x) = sec2 x tan3 x csc4 x cot5 x

3.3.2 Chain Rule


Many functions can be written as a composition of some elementary functions. For instance,
f = sin(x2 + 1) can be regarded as: f = sin u where u is a function of x defined as u = x2 + 1.
3.3 Differentiation Rules 99

We have already learned how to differentiate sin u and x2 + 1. The chain rule, stated below, tells
us how to deal with this f :
Theorem 3.11 — Chain Rule. Let f be a differentiable function of u, and u is a differentiable
function of x (so f is ultimately a function of x). Then, f is a differentiable function of x, and
we have:
df df du
= ·
dx du dx

i Although symbolically the chain rule is just like cancelling out du, conceptually we cannot
think it this way. The proof of the chain rule is quite technical (hence omitted here).

Using the chain rule, we can differentiate sin(x2 + 1):

d d
sin(x2 + 1) = sin u (Let u = x2 + 1)
|dx {z } dx
df
dx

d du
= sin u ·
| {z } dx
du
df
du

d d 2
= sin u · (x + 1)
du dx
= cos u · 2x
= 2x cos(x2 + 1)

Let’s see a few more examples:

⌅ Example 3.9 Find the derivative of f = (x3 + 2x2 + 1)5 .

⌅ Solution First think of a function u(x) so that f can be regarded as a function of u and that
df
both du and du
dx are easy to find. One suitable choice here is:

u = x3 + 2x2 + 1.

Then f = u5 . Then by the chain rule, we have:

df df du
= ·
dx du dx
d 5 d 3
= u · (x + 2x2 + 1)
du dx
= 5u4 · (3x2 + 4x)
= 5(3x2 + 4x) (x3 + 2x2 + 1)4
| {z }
u4

⌅ Example 3.10 Differentiate f = ea ln x where a is a positive constant.

⌅ Solution A natural choice of the function u is u = a ln x, since then f = eu which is easy to


100 Differentiation (Part I)

differentiate. By the chain rule:

df df du
= ·
dx du dx
a
= eu ·
x
aea ln x
= .
x

i The above example actually gives a proof of the Power Rule:


d a
x = axa 1
.
dx
a
Since f = ea ln x = eln x = xa , what we did in the example was:
a
d a aea ln x aeln x axa
x = = = = axa 1
.
dx x x x

After getting familiar with the chain rule, you may skip writing “Let u = . . .” and simply write:
d 3 d d 3
(x + 2x2 + 1)5 = (x3 + 2x2 + 1)5 · (x + 2x2 + 1)
dx d(x3 + 2x2 + 1) dx
= 5(x3 + 2x2 + 1)4 (3x2 + 4x)
Likewise, we may apply the chain rule for following functions without explicitly writing the
function u:
d d d 2
sin(x2 + 1) = 2
sin(x2 + 1) · (x + 1)
dx d(x + 1) dx
= cos(x2 + 1) · 2x
d a ln x d d
e = ea ln x · a ln x
dx d(a ln x) dx
a
= ea ln x ·
x
We can also apply the chain rule when the “chain” of variables is longer. For instance, the
function
f = sin(cos(tan x))
df
can be regarded as f = sin u, where u = cos v and v = tan x. To find dx , we can do:
df df du dv
= · ·
dx du dv dx
= cos u · ( sin v) · sec2 x
= cos(cos(tan x)) · sin(tan x) · sec2 x
Equivalently, we can also apply the chain rule without writing down the u and v explicitly:
d d d d
sin(cos(tan x)) = sin(cos(tan x)) · cos(tan x) · tan x
dx d(cos(tan x)) d(tan x) dx
= cos(cos(tan x)) · ( sin(tan x)) · sec2 x
which gives the same answer as the above.

⌅ Exercise 3.17 Find f 0 (x) and f 0 (0) of the following functions:


ex e x
(a) f (x) =
ex + e x
(b) f (x) = ln(ex e x )
(c) f (x) = ln ln(x2 + 3)
p p
(d) f (x) = ln 1 + x2 + 1 x2
3.3 Differentiation Rules 101
p p
2 2
(e) f (x) = e 1+x + 1 x
(f) f (x) = sin(cos(x2 + 2x))
(g) f (x) = cos(sin(x2 + 2x))

⌅ Exercise 3.18 Let a > 0 be a constant, and u(x) be a differentiable function of x. Show that

d u(x) du
a = au(x) ln a .
dx dx
Suppose further that a 6= 1 and u(x) > 0 for all x, show that

d 1 du
loga u = .
dx u(x) ln a dx

3.3.3 Chain rule: an equivalent form


Given a function f (u) of u where u(x) is in turn a function of x, then f is ultimately a function of
x, i.e. f (u(x)). In Chapter 1 we know that a composite function can be written as:

f (u(x)) = (f u)(x).

For instance, the function sin(x2 + 1) can be regarded (f u)(x) by letting f (u) = sin u and
u(x) = x2 + 1.
Many textbooks also include the following form for the chain rule (which is equivalent to the
one we discussed):
(f u)0 (x) = f 0 (u) · u0 (x) .
| {z } | {z } | {z }
df df du
dx du dx

⌅ Example 3.11 Given f and g are two differentiable functions, and that:

f (1) = 5, f (2) = 4, f 0 (1) = 8, f 0 (2) = 10

g(1) = 2, g(2) = 7, g 0 (1) = 9, g 0 (2) = 3


Determine the value of
(f g)0 (1)

⌅ Solution Apply the chain rule (in composition form), we get:

(f g)0 (x) = f 0 (g) · g 0 (x)

Substitute x = 1, we have g 0 (x) = g 0 (1) = 9. However, what is f 0 (g)? From the given fact that
g(1) = 2, we know that g = 2 when x = 1, and so f 0 (g) = f 0 (2) = 10. Therefore,

(f g)0 (1) = f 0 (2) · g 0 (1) = 10 ⇥ 9 = 90.

i Be careful when you substitute. The most common mistake is that some students substitute
the same value (like 1 in the above example) into both f 0 and g 0 :
(f g)0 (1) = f 0 (1) · g 0 (1) INCORRECT!
To remind yourself not making this kind o mistakes, write the chain rule as:
(f g)0 (x) = f 0 (g(x)) · g 0 (x),
so that in this example, we have:
(f g)0 (1) = f 0 (g(1)) · g 0 (1) = f 0 (2) · g 0 (1).
102 Differentiation (Part I)

3.3.4 Idea of proof of chain rule using linear approximations


The rigorous proof of the chain rule is not as straight-forward as other rules like product
and quotient rules. It requires another point of view about differentiations, namely linear
approximations.
Consider a function f which is differentiable at x = a, then the following limit exist:

f (x) f (a)
f 0 (a) = lim .
x!a x a
By rearrangement, and noting that f (a) is just a constant, we get
✓ ◆
f (x) f (a) 0 f (x) f (a) f 0 (a)(x a)
0 = lim f (a) = lim .
x!a x a x!a x a

We could interpret the above limit as saying “as x ! a, the denominator f (x) f (a) f 0 (a)(x a)
is very small when compared to x a”, and we write:

f (x) ⇠ f (a) + f 0 (a)(x a) when x ⇠ a.

For example, if we take f (x) = sin x, then f 0 (x) = cos x and so f 0 (0) = 1, then one can interpret
the above as saying sin x is approximately equal to the linear graph:

sin x ⇠ 0 + 1 · (x 0) = x when x ⇠ 0.

Since y = f (a) + f 0 (a)(x a) is a straight line (noting that a is a constant), and in fact it is the
tangent line to y = f (x) at the point (a, f (a)), we call f (a)+f 0 (a)(x a) the linear approximation
of f near a.
Note that given two differentiable functions f (x) and g(u). Then consider that f can be
linearly approximated by:

f (x) ⇠ f (a) + f 0 (a)(x a) when x ⇠ a.

Similarly, g(u) can be linearly approximated near u = f (a) by

g(u) ⇠ g f (a) + g 0 f (a) (u f (a)) when u ⇠ f (a).

Since when x ⇠ a, by continuity of f , we have f (x) ⇠ f (a). Then substituting u = f (x), we


conclude that when x ⇠ a, we have:

g(f (x)) ⇠ g f (a) + g 0 f (a) (f (x) f (a))


⇠ g f (a) + g f (a) f (a) + f 0 (a)(x
0
a) f (a)
0 0
= g f (a) + g f (a) f (a)(x a)

Therefore, the composite function g f (x) can be linearly approximated by a straight line with
slope g 0 (f (a))f 0 (a) when x ⇠ a.
This suggests that the slope of tangent of the graph y = g(f (x)) at x = a should be equal to
g 0 (f (a))f 0 (a). It casually (not rigorously) explains why we have

d
g(f (x)) = g 0 (f (a))f 0 (a),
dx x=a

which is exactly the chain rule. Surely, the above is not really a rigorous proof, but the formal
proof is roughly inline of the above thought.

⌅ Exercise 3.19 Given two functions f and g which are differentiable at x = a, write down the
linear approximations of f and g, and multiply them together. Try to explain the product rule
in this way.
3.4 Implicit Differentiation 103

3.4 Implicit Differentiation


3.4.1 Motivation
Consider the circle x2 + y 2 = 25, centered at the origin with radius 5. The point (3, 4) lies on the
circle. If we want to find the slope of tangent to the circle at (3, 4), then how can we do?
dy
One way of doing it is to first express y in terms of x, then compute dx and finally substitute
(x, y) = (3, 4). There is one subtle issue to do this, namely when we solve for y in terms of x, we
get: p p
y = 25 x2 , or y = 25 x2 .
p
However, since the point (3, 4) lies on the part y = 25 x2 , we can ignore the negative case.
Therefore, we have:
dy d p 1 d x
= 25 x2 = p (25 x2 ) = p .
dx dx 2 25 x2 dx 25 x2
Substitute x = 3, we get:
dy 3 3
= p = .
dx (x,y)=(3,4) 25 32 4

The method of implicit differentiation is another way of doing this kind of problems. Take
the above example: consider the circle x2 + y 2 = 25, we may first regard y as a function of x
without explicitly finding the function. Then, by differentiating both sides of x2 + y 2 = 25 with
respect to x, we get:
d d
x2 + y 2 = (25)
dx dx
d 2
2x + y =0
dx
d 2 dy
2x + y · =0 (chain rule)
dy dx
dy
2x + 2y =0
dx
dy 2x x
= =
dx 2y y

Therefore,
dy 3
= .
dx (x,y)=(3,4) 4

i You might think that it is problematic for regarding y as a function x, since the circle does
not pass the vertical line test. However, as we are trying to findp
the slope of tangent at (3, 4),
we can ignore the lower-half circle. Then y can be regarded as 25 x2 which is a function
of x.
104 Differentiation (Part I)

Likewise,
p if we want to find the slope of tangent at (3, 4), then it lies on the part of circle
y= 25 x2 so that y near the point (3, 4) can also be regarded as a function of x.
To conclude, unless we hit a bad point such as (5, 0) or ( 5, 0), one can often locally regard
y as a function of x around that point. The method of implicit differentiation will be fully
justified in MATH 3033 (Real Analysis). In this freshmen Calculus course, we may simply
assume that this method works.

The method of implicit differentiation can be extremely useful when dealing curves such as

x3 + y 3 = 6xy

where it is very difficult to solve y in terms x explicitly. Let’s consider this curve as an exam-
ple:

⌅ Example 3.12 Consider the curve x3 + y 3 = 6xy. Find all points at which the tangent to this
curve is horizontal.

dy
⌅ Solution We need to solve for all (x, y) on this curve such that = 0. Using implicit
dx
dy
differentiation to find dx , we differentiate both sides of x + y = 6xy with respect to x:
3 3

d d
x3 + y 3 = (6xy)
dx dx✓ ◆
dy dx dy
3x2 + 3y 2 =6 ·y+x· (chain rule on LHS, product rule on RHS)
dx dx dx
dy dy
x2 + y 2 = 2y + 2x
dx dx
dy dy
y2 2x = 2y x2
dx dx
dy
y 2 2x = 2y x2
dx
dy 2y x2
=
dx y2 2x

In order for the tangent to be horizontal, we need:

dy
(x, y) = 0 () 2y = x2 .
dx
Be careful that we also require (x, y) to be on the curve x3 + y 3 = 6xy, so both of the equations
3.4 Implicit Differentiation 105

below must simultaneously hold:


(
2y = x2
x3 + y 3 = 6xy

x2
The first equation implies y = 2 , and by substituting y into the second equation, we get:
✓ ◆3
3 x2 x2
x + = 6x ·
2 2
x6
x3 + = 3x3
8
x6 16x3 = 0
x3 (x3 16) = 0
p x2
Therefore, we get x = 0 or x = 3
16. Using y = 2 , we get:
✓ ◆
162/3
(x, y) = (0, 0) or 161/3 , .
2

3.4.2 Derivative of Inverse Trigonometric Functions


Using implicit differentiation, we can find the derivative of inverse trigonometric functions (and
inverse functions in general). Take y = sin 1 x as an example:

sin y =x
d dx
sin y =
dx dx
dy
cos y · =1
dx
dy 1
=
dx cos y
1
= 1
cos(sin x)
p
By standard trigonmetry (sketch a right-angled triangle to see it) that cos(sin 1 (x)) = 1 x2 .
d 1 d 1
Therefore, we have: sin 1 x = p . Likewise, we can also show: cos 1 x = p .
dx 1 x2 dx 1 x2
Let’s look at y = tan 1 x:
1

tan y = x
x
d dx
tan y = xin ( x)
dx dx )
2
sec y ·
dy
=1 -
1
dx
dy 1 1
= =
dx 2
sec y 1 + tan2 y
1 1
= =
1 + tan2 (tan 1 x) 1 + x2

Therefore, we have:
d 1 1
tan x= .
dx 1 + x2
106 Differentiation (Part I)

To summarize, we have:

d 1 1
sin x= p
dx x2
1
d 1 1
cos x= p
dx 1 x2
d 1 1
tan x=
dx 1 + x2

For a general function f that has an inverse f 1


, we can find d
dx f
1
(x) by first setting
dy
y = f 1 (x), then to dx , we consider:
f (y) = x
d dx
f (y) =
dx dx
d dy
f (y) · =1
dy dx
dy
f 0 (y) · =1
dx
dy 1
= 0
dx f (y)
Since y = f 1
(x) and so x = f (y), one can also write f 0 (y) = dx
dy and so:
dy 1
= dx .
dx dy

Although this formula looks like taking reciprocal, it is conceptually incorrect to say so because
dy
dx and dy are not fractions.
dx

⌅ Exercise 3.20 Derive the following derivative rules:

d 1 1 d 1 1 d 1 1
sec x= p csc x= p cot x=
dx |x| x2 1 dx |x| x2 1 dx 1 + x2

3.4.3 Logarithmic Differentiation


We have proved in Theorem 3.6 that:
d 1
ln x = for any x > 0.
dx x
We require x > 0 in this rule because ln is not defined on zero or negative numbers. However,
ln |x| is defined for all x 6= 0. When x < 0, we have ln |x| = ln ( x), and using the chain rule, we
can get:
d d d
ln ( x) = ln ( x) · ( x)
dx d( x) dx
1
= · ( 1)
x
1
=
x
for any x < 0.
To summarize, we have:
d d 1
For x > 0: ln |x| = ln x =
dx dx x
d d 1
For x < 0: ln |x| = ln ( x) =
dx dx x
3.4 Implicit Differentiation 107

and we can simply say:

d 1
For any x 6= 0, we have: ln |x| = .
dx x
Using the chain rule, we can further generalize the above rule to the following proposition
(which will be extremely useful later on when dealing with tedious differentiation).
Proposition 3.12 Given any differentiable function f (x), then at any point x such that f (x) 6= 0,
we have:
d f 0 (x)
ln |f (x)| = .
dx f (x)

Proof. Let g : ( 1, 0) [ (0, 1) ! R denote the function:

g(x) = ln |x| ,

then ln |f (x)| = g(f (x)). By the chain rule, we have:

d d d
g(f (x)) = g(f ) · f (x)
dx df dx
d
= ln |f | · f 0 (x)
df
1
= · f 0 (x)
f (x)

⌅ Example 3.13 Find the derivative of the function:


p
x1/3 x2 + 1
f (x) = .
(3x + 2)3

⌅Solution It would be laborious to differentiate f directly. However, it can be done much


more effectively using the logarithmic rule! Consider
p 1/3 p 2
x1/3 x2 + 1 |x| x +1
ln |f (x)| = ln 3
= ln 3
(3x + 2) |3x + 2|
1/3
p 3
= ln |x| + ln x2 + 1 ln |3x + 2|
1 1
= ln |x| + ln(x2 + 1) 3 ln |3x + 2|
3 2
Differentiate both sides with respect to x, we get:

f 0 (x) 1 1 d (x2 + 1) d
dx (3x+ 2)
= + · dx 2 3·
f (x) 3x 2 x +1 3x + 2
1 x 9
= + 2
3x x + 1 3x + 2
Therefore,
✓ ◆
1 x 9
f 0 (x) = f (x) + 2
3x x + 1 3x + 2
1/3
p ✓ ◆
x x2 + 1 1 x 9
= +
(3x + 2)3 3x x2 + 1 3x + 2
108 Differentiation (Part I)

⌅ Example 3.14 Find the derivative of f (x) = xx for x > 0.

⌅ Solution Consider:
ln f (x) = ln xx = x ln x.
Differentiate both sides, we get:

f 0 (x) 1
= 1 · ln x + x ·
f (x) x
f 0 (x) = f (x) (ln x + 1)
= xx (ln x + 1)

(x + 4)3
⌅ Exercise 3.21 — Source: Extracted from HKDSE M2 2020, Q9. Let f (x) = , where x 6= 4.
(x 4)2
d 0
Try using logarithmic differentiation to find f 0 (x) and f 00 (x). Recall that f 00 (x) = f (x).
dx
[Caution: Not sure if logarithmic differentiation is allowed in DSE M1/M2. Be warned if you
use it to tutor DSE kids or use it to retake DSE again.]

⌅ Exercise 3.22 Let f (x) = x2/3 (6 x)1/3 . Find f 0 (x) and f 00 (x) where x 6= 0, 6.

⌅ Exercise 3.23 Find the derivatives of the following functions below:


p 1
x
f (x) = (sin x) , g(x) = (ln x) ln x .

⌅ Exercise 3.24 Find the derivative of each function below (for x > 0):
x x x x e e x e
xx , ex , xe , xe , xe , ex , ee , ee .

⌅ Exercise 3.25 Derive a general differentiation rule for f (x)g(x) where f and g are differen-
tiable functions, and f (x) > 0 for all x 2 R.

f ( ) xxx
x
=

λ70
lulfix ) 1
: xu 1 x 1

( * ) ulxl x +

* -

X
(luxt ) ux
*
1 +
= x

啦了
IlxPeunt *
= x

( lnx ) ' luxt 它 ]


1 )I
+ +

x"
f
(
(
x)xx=
3.5 Higher-Order Differentiations 109

3.5 Higher-Order Differentiations


3.5.1 Higher-order derivatives
After taking the derivative of f (x), we get a new function f 0 (x). We may continue taking the
derivative of f 0 (x), and obtain the second-order derivative, which is denoted and defined as:

d 0 d2 f
f 00 (x) := f (x) alternative notation: .
dx dx2
For example:

f (x) = sin x
d
f 0 (x) = sin x = cos x
dx
d 0 d
f 00 (x) = f (x) = cos x = sin x
dx dx

⌅ Exercise 3.26 Find f 00 (x) of each function below:


(a) f (x) = x4
(b) f (x) = tan x
(c) f (x) = ln x
(d) f (x) = e2x

Certainly, one may continue differentiating f 00 (x) and obtain the third-order, fourth-order, and
more generally n-th order derivatives:

d 00 d 000 d (n
f 000 (x) := f (x), f (4) (x) := f (x), f (n) (x) := f 1)
(x), 8n 2.
dx dx dx
By convention, we often denote f (0) (x) := f (x). Alternatively, we can also denote these higher-
order derivatives by
dn f
:= f (n) (x).
dxn

⌅ Example 3.15 Find the n-th derivative of the function f (x) = eax where a 2 R is a constant.

⌅ Solution

d ax
f 0 (x) = e = aeax
dx
d 0 d ax
f 00 (x) = f (x) = ae = a · aeax = a2 eax
dx dx
d 00 d 2 ax
f 000 (x) = f (x) = a e = a3 eax .
dx dx
One would be able to guess that f (n) (x) = an eax . It can be further verified by induction:
Let P (n) : f (n) (x) = an eax . Certainly P (1) is true. Now assume P (n) is true for some
n 2 N, then we have
f (n) (x) = an eax .
Consider the (n + 1)-th derivative:

d (n) d n ax
f (n+1) (x) = f (x) = a e = an · aeax = an+1 eax .
dx dx
This shows P (n + 1) is true. By induction, we conclude that f (n) (x) = an eax for any n 2 N.
110 Differentiation (Part I)

1
⌅ Example 3.16 Let f (x) = where a, b are constants, and a 6= 0. Find f (n) (x) for any
ax + b
n 2 N.

⌅ Solution
1
f (x) =
ax + b
a
f 0 (x) =
(ax + b)2
2a2
f 00 (x) =
(ax + b)3
(3)(2)a3
f 000 (x) =
(ax + b)4
(4)(3)(2)a4
f (4) (x) =
(ax + b)5

According to the above pattern, we could guess that

( 1)n n!an
f (n) (x) = .
(ax + b)n+1

Exercise: verify this guess by induction.

⌅ Exercise 3.27 Prove by induction that

dn 1 ( 1)n n!an
= 8n 2 N.
dxn ax + b (ax + b)n+1

⌅ Exercise 3.28 Prove by induction that

dn ⇣ n⇡ ⌘
sin x = sin + x 8n 2 N.
dxn 2

dn k
⌅ Example 3.17 Let k 2 N, find x where n 2 N.
dxn

⌅ Solution

d k
x = kxk 1
dx
d2 k
x = k(k 1)xk 2
dx2
d3 k
x = k(k 1)(k 2)xk 3
dx3
..
.
dk 1 k
x = k(k 1)(k 2) · · · (3)(2)xk (k 1)
= k(k 1)(k 2) · · · (3)(2)x
dxk 1
dk k
x = k(k 1)(k 2) · · · (3)(2)(1) = k!
dxk
3.5 Higher-Order Differentiations 111
k+1
Note that k! is a constant, so dx
d
k+1 x
k
= 0. To summarize, we have
(
dn k k(k 1)(k 2) · · · (k (n 1))xk n if n = 1, 2, · · · , k
x = .
dxn 0 if n k + 1

k!
Note that the coefficient k(k 1)(k 2) · · · (k (n 1)) can be rewritten as , if you
(k n)!
prefer.

⌅ Exercise 3.29 Let f (x) = (2x + 3)k where k 2 N. Find f (n) (x) for any n 2 N.

⌅ Exercise 3.30 Let f (x) = (x 1)k where k 2 N. Show that for any n 2 N, we have
(
(n) k! if n = k
f (1) =
0 if n 6= k

Functions whose n-th derivative f (n) (x) exist are called n-times differentiable functions
(and when n = 2 we often call them twice differentiable functions). Note that a function
f (x) which is differentiable, i.e. f 0 (x) exists, does not always imply f 00 (x) exist, and so on. We
will see later in this section that some functions are, for instance, differentiable but not twice
differentiable.
⌅ Exercise 3.31 — Source: Extracted from HKALE Pure Math 2003, Paper 2, Q9. Let u : R ! R be
a twice differentiable function satisfying the following conditions
(1) u00 (x) = u(x) for any x 2 R,
(2) u(0) = 0, and
(3) u0 (0) = 1.
Define v(x) = u(x) sin x for all x 2 R. By considering the derivative of

w(x) = v(x)2 + v 0 (x)2 ,

prove that u(x) = sin x for all x 2 R.

3.5.2 Higher-order product rule


To find the higher-order derivative of the product of two functions, there is a formula which looks
a bit like the binomial theorem:
Theorem 3.13 — Higher-order product rule. Let f (x) and g(x) be n-times differentiable func-
tions, then we have
X n
dn
f (x)g(x) = Ckn f (n k)
(x)g (k) (x). (3.11)
dxn
k=0

Proof. The proof is by induction. When n = 1, LHS of (3.11) is

d
f (x)g(x) = f 0 (x)g(x) + f (x)g 0 (x),
dx

and RHS of (3.11) equals

1
X
Ck1 f (1 k)
(x)g (k) (x) = C01 f 0 (x)g(x) + C11 f (x)g 0 (x) = f 0 (x)g(x) + f (x)g 0 (x).
k=0

LHS is equal to the RHS of (3.11), hence (3.11) holds when n = 1.


112 Differentiation (Part I)

Suppose (3.11) holds for some n 2 N, then for this n we have

X n
dn
n
f (x)g(x) = Ckn f (n k)
(x)g (k) (x).
dx
k=0

Consider the (n + 1)-th derivative:

dn+1
f (x)g(x)
dxn+1
✓ n ◆ n
d d d X n (n k)
= f (x)g(x) = Ck f (x)g (k) (x)
dx dxn dx
k=0
n
X d n (n k)
= C f (x)g (k) (x)
dx k
k=0
Xn
= Ckn f (n k+1)
(x)g (k) (x) + f (n k)
(x)g (k+1) (x)
k=0
n
X n+1
X
= Ckn f (n+1 k)
(x)g (k) (x) + Ckn 1 f (n k+1)
(x)g (k) (x) (change of index)
k=0 k=1
n
X
= C0n f (n+1) (x)g(x) + Ckn f (n+1 k)
(x)g (k) (x)
k=1
n
X
+ Ckn 1 f (n k+1)
(x)g (k) (x) + Cnn f (n (n+1)+1)
(x)g (n+1) (x)
k=1
n
X
= f (n+1) (x)g(x) + (Ckn + Ckn 1 )f (n k+1)
(x)g (k) (x)
k=1
(n+1)
+ f (x)g (x)
n
X
= C0n+1 f (n+1) (x)g(x) + Ckn+1 f (n k+1)
(x)g (k) (x)
k=1
n+1 (n+1)
+ Cn+1 f (x)g (x)
n+1
X
= Ckn+1 f (n k+1)
(x)g (k) (x),
k=0

which is exactly the RHS of (3.11) for n + 1 is in place of n. By induction, (3.11) is proved for
any n 2 N. ⌅

⌅ Example 3.18 — Source: Extracted from HKALE Pure Math 2012, Paper 2, Q2. Consider the
function f : R ! R defined by
sin x
f (x) = .
1 + 4x2
n⇡
Show that f (n+2) (0) = 4(n + 2)(n + 1)f (n) (0) sin for any n 2 N.
2

⌅ Solution The first guess may be to apply (3.11) on the functions sin x and However, 1+4x2 .
1

the k-th derivative of is very difficult to obtain. However, the k-th derivative of 1 + 4x2
1
1+4x2
is much easier. Therefore, we consider:

(1 + 4x2 )f (x) = sin x


3.5 Higher-Order Differentiations 113

Differentiate both sides (n + 2) times, the LHS becomes:

dn+2
f (x)(1 + 4x2 )
dxn+2
n+2
X
= Ckn+2 f (n+2 k) (x)(1 + 4x2 )(k)
k=0

=f (n+2)
(x)(1 + 4x2 ) + (n + 2)f (n+1) (x) · 8x + C3n+2 f (n) (x) · 8 + 0 + 0 + · · · + 0
= (1 + 4x2 )f (n+2) (x) + 8(n + 2)xf (n+1) (x) + 8C2n+2 f (n) (x).

On the other hand, recall that f (x)(1 + 4x2 ) = sin x, hence we also have
✓ ◆
dn+2 2 dn+2 (n + 2)⇡
f (x)(1 + 4x ) = sin x = sin x + .
dxn+2 dxn+2 2

We conclude that
✓ ◆
(n + 2)⇡
(1 + 4x )f 2 (n+2)
(x) + 8(n + 2)xf (n+1)
(x) + 8C2n+2 f (n) (x) = sin x + .
2

Put x = 0, we get:

(n + 2)(n + 1) (n) (n + 2)⇡


f (n+2) (0) + 0 + 8 · f (0) = sin .
(2)(1) 2

By rearranging the terms, we get


⇣ n⇡ ⇡⌘ n⇡
f (n+2) (0) = 4(n + 2)(n + 1)f (n) (0) + sin + = 4(n + 2)(n + 1)f (n) (0) sin .
2 2 2

⌅ Exercise 3.32 — Source: Modified from HKALE Pure Math 2011, Paper 2, Q3. Let f : R ! R be
defined by
1
f (x) = p .
x2 + 2x + 5
(a) Prove that (x2 + 2x + 5)f 0 (x) + (x + 1)f (x) = 0 for any x 2 R.
(b) Hence, prove that

(x2 + 2x + 5)f (n+1) (x) + (2n + 1)(x + 1)f (n) (x) + n2 f (n 1)


(x) = 0

for any x 2 R, n 2 N.

⌅ Exercise 3.33 — Source: Extracted from HKALE Pure Math 2009, Paper 2, Q3. Let f : R ! R be
defined by
3
f (x) = (25 + x2 ) 2 .
(a) Prove that (25 + x )f (x) =2 0
3xf (x) for any x 2 R.
(b) Hence, prove that

(25 + x2 )f (n+1) (x) + (2n + 3)xf (n) (x) + n(n + 2)f (n 1)


(x) = 0

for any x 2 R, n 2 N.

3.5.3 Higher-order differentiability


Some function such as f (x) = |x| is not differentiable at a certain point. Likewise, even if a
function g(x) is differentiable everywhere so that g 0 (x) exists, its second derivative g 00 (x) may
not always exist.
114 Differentiation (Part I)

⌅ Example 3.19 Consider the function f : R ! R defined by


(
x3 sin x1 if x 6= 0
f (x) =
0 if x = 0

Show that f 0 (x) exists for any x 2 R, but f 00 (0) does not exist.

⌅ Solution For any x 6= 0, we can simply calculate f 0 (x) by differentiating x3 sin 1


x because
f (x) is defined using limit:
0

f (x + h) f (x)
f 0 (x) = lim .
h!0 h
When x 6= 0, and when h is very close to 0, we have x + h 6= 0 too, so we have both
1
f (x + h) = (x + h)3 sin x+h and f (x) = x3 sin x1 when h ! 0 and x 6= 0. Therefore, we have
1
(x + h)3 sin x+h x3 sin x1
f 0 (x) = lim (when x 6= 0),
h!0 h

which is no different from sin x1 . Therefore, we can compute directly that when x 6= 0:
d 3
dx x
✓ ◆
0 d 3 1 2 1 3 1 1 1 1
f (x) = x sin = 3x sin + x cos = 3x2 sin x cos .
dx x x x2 x x x

However, one should find f 0 (0) from the definition since f (0 + h) and f (0) are defined
differently as h ! 0 (recall that h ! 0 infers that h 6= 0):

f (0 + h) f (0)
f 0 (0) = lim
h!0 h
h3 sin h1 0
= lim
h!0 h
2 1
= lim h sin .
h!0 h

Since 1  sin h1  1, we have


1
h2  h2 sin  h2 .
h
As h ! 0, we have both h2 ! 0 and h2 ! 0. Squeeze theorem hence shows
1
lim h2 sin = 0.
h!0 h
This concludes f 0 (0) = 0. To summarize, we get
(
3x2 sin x1 x cos x1 if x 6= 0
f 0 (x) = .
0 if x = 0

Next, we discuss whether f 00 (0) exists or not. Recall that


✓ ◆
00 f 0 (0 + h) f 0 (0) 3h2 sin h1 h cos h1 0 1 1
f (0) = lim = lim = lim 3h sin cos .
h!0 h h!0 h h!0 h h
3.5 Higher-Order Differentiations 115

1 1
By squeeze theorem, lim 3h sin = 0, but lim cos does not exist because 1
h ! 1 and cos x
h!0 h h!0 h
oscillates between 1 and 1 when x ! 1. Therefore, the limit
✓ ◆
1 1
lim 3h sin cos
h!0 h h

does not exist, and neither does f 00 (0). In other words, f is not twice differentiable at x = 0.

⌅ Example 3.20 — Source: Modified from HKALE Pure Math 1997, Paper 2, Q6. Consider the
function f : R ! R defined by f (x) = x |x|.
(a) Find f 0 (x) for any x 2 R.
(b) Determine whether or not f 0 : R ! R is continuous at x = 0.
(c) Determine whether or not f 00 (0) exists.

⌅ Solution (a) When x > 0 and h ! 0 (hence h 6= 0), x + h is still positive so f (x + h) =


(x + h)(x + h) = (x + h)2 , and f (x) = x2 . Therefore,

(x + h)2 x2 d 2
f 0 (x) = lim = x = 2x.
h!0 h dx
Similarly, when x < 0 and h ! 0, x + h is negative so f (x + h) = (x + h)2 and f (x) = x2 .
Therefore,
(x + h)2 ( x2 ) d
f 0 (x) = lim = ( x2 ) = 2x.
h!0 h dx
When x = 0 and h ! 0, x + h could be positive or negative depending on whether h ! 0+ and
h ! 0 . That gives us a hint that we should consider f+
0
(0) and f 0 (0):

0 f (0 + h) f (0) h |h| 0
f+ (0) = lim+ = lim+
h!0 h h!0 h
2
h
= lim+ = lim+ h = 0
h!0 h h!0
f (0 + h) f (0) h( h) 0
f 0 (0) = lim = lim
h!0 h h!0 h
= lim ( h) = 0.
h!0

As f+
0
(0) = f 0 (0) = 0, we conclude that f 0 (0) exists and f 0 (0) = 0.
To summarize, we have
8
< 2x if x 2 ( 1, 0)
>
0
f (x) = 0 if x = 0 .
>
:
2x if x 2 (0, 1)

(b) We need to determine whether or not lim f 0 (x) = f 0 (0). Note that
x!0

lim f 0 (x) = lim+ (2x) = 0


x!0+ x!0
0
lim f (x) = lim ( 2x) = 0
x!0 x!0

Hence, lim f 0 (x) exists, and that


x!0

lim f 0 (x) = 0 = f 0 (0).


x!0
116 Differentiation (Part I)

Therefore, f 0 (x) is continuous at x = 0.


(c) We need to see if the following limit exists:

f 0 (0 + h) f 0 (0)
f 00 (0) = lim .
h!0 h
Again, how is f 0 (0 + h) defined depends on whether h is positive or negative. We need to work
with its left- and right-limits again:

f 0 (0 + h) f 0 (0) 2h 0
lim+ = lim+ =2
h!0 h h!0 h
f 0 (0 + h) f 0 (0) 2h 0
lim = lim = 2
h!0 h h!0 h
f 0 (0 + h) f 0 (0)
Its left- and right-limits do not agree. Hence, lim does not exist. In other
h!0 h
words, f (0) does not exist (equivalently we may say f (x) is not differentiable at x = 0, or
00 0

say f (x) is not twice differentiable at x = 0).

⌅ Exercise 3.34 Consider the function f : R ! R defined by:


(
x4 sin x1 if x 6= 0
f (x) = .
0 if x = 0

Show that f 0 (x) and f 00 (x) exist for all x 2 R, but f 000 (x) does not exist for some x 2 R.


p Source: Modified from HKALE Pure Math 2004, Paper 2, Q7. Consider the
Exercise 3.35 —
function f : R\{ 3 2} ! R defined by

|x| x3
f (x) = .
x3 2
p
(a) Find f 0 (x) for any x 6= 3 2.
(b) Determine whether or not f 00 (0) exists.

⌅ Exercise 3.36 — Source: Modified from HKALE PUre Math 2003, Paper 2, Q7. Consider the
function f : R\{ 2} ! R defined by

x |x + 1|
f (x) = .
x+2
(a) Find f 0 (x) for any x 6= 1, 2.
(b) Determine whether or not f 0 ( 1) exists.
(c) Do you agree with the following statement? “f 00 (x) does not exist for any x 2 R.”

⌅ Exercise 3.37 Consider the function f : R ! R defined by


(
sin x if x 6= 0
f (x) = .
cos x if x = 0

Find f 0 (0), or show that it does not exist.


3.5 Higher-Order Differentiations 117

In many of the above examples and exercises, the functions are piecewise defined in the form
of: 8
<g(x) if x < 0
>
f (x) = a if x = 0 .
>
:
k(x) if x > 0
We explained that if g and h are differentiable functions, then one can find f 0 (x) for x < 0
or x > 0 by computing the derivatives of g and k respectively. However, we always find f 0 (0)
from the definition of derivative since f (0 + h) can be either g(h) or k(h) depending on whether
h ! 0+ or h ! 0 .
It is not correct to find f 0 (0) by simply “plugging in x = 0” into g 0 (x) or k 0 (x), or letting
x ! 0 for g 0 (x) and k 0 (x). By doing so, you are attempting to find lim f 0 (x) instead, not f 0 (0).
x!0
The following example shows lim f 0 (x) and f 0 (0) could be different!
x!0

⌅ Example 3.21 Let f : R ! R be defined as:


(
x2 sin x1 if x 6= 0
f (x) = .
0 if x = 0

Show that lim f 0 (x) 6= f 0 (0).


x!0

⌅ Solution As before, we can compute f 0 (x) directly when x 6= 0:


✓ ◆
0 1 1 1 1 1
f (x) = 2x sin + x2 cos = 2x sin cos .
x x2 x x x
✓ ◆
1 1
To find lim f 0 (x), we consider lim f 0 (x) = lim 2x sin cos . Similar to an earlier
x!0 x!0 x!0 x x
1 1
example, we can use squeeze theorem can conclude that lim 2x sin = 0. However, lim cos
x!0 x x!0 x
does not exist (recall that it is because when x ! 0, x1 ! 1 and so cos x1 fluctuates between
1 and 1 as x1 ! 1. It concludes that lim f 0 (x) does not exist.
x!0
However, when x = 0, we compute f 0 (0) from the definition of derivative:

f (x) f (0)
f 0 (0) = lim
x!0 x 0
x2 sin x1 0
= lim
x!0 x
1
= lim x sin
x!0 x
=0

which we used the squeeze theorem again.


In this example, you see that it could happen that lim f 0 (x) and f 0 (0) are different! The
x!0
former does not exist, whereas the latter exists.

⌅ Exercise 3.38 Do you agree with the following argument?

“Let f (x) = x1/3 . Since f 0 (x) = 3x12/3 for any x 6= 0, and f 0 (x) tends to 1 when
x ! 0, therefore f 0 (0) does not exist.”

You might also like