Lecture Note 6 - Princeton University

Lecture 6: Calculus
∗
In Song Kim†
September 7, 2011
1
Introduction to Differential Calculus
In our previous lecture we came up with several ways to analyze functions. We saw previously that
the slope of a linear function, y = ax + b at a point x is:
m=
y2 − y1
f (x2 ) − f (x1 )
∆y
=
=
∆x
x2 − x1
x2 − x1
Note that the slope–how the function changes as we move across values of x–does not change.
For a general curve, the slope varies from point to point.
Definition 1 A secant line of a curve is a line that intersects two or more points on the curve.
Example 1 f (x) = x2 .
f (x2 )−f (x1 )
= 11 =
x2 −x1
f (x2 )−f (x1 )
= 31 = 3.
x2 −x1
The slope of the secant between (0, 0) and (1, 1) is
1.
The slope of the secant between (1, 1) and (2, 4) is
How to calculate the slope of a curve at a certain point when this curve is not a straight line?
Notice that we can draw many secants...ones that are closer to our “point of interest” give us
a better approximation. Wouldn’t it be a reasonable idea to take a secant line and evaluate it at
two points very close to the point we want to obtain the slope at?
1.1
Limit Review
We have previously talked a little bit about limits. But lets do a little review and be a bit more
technical as they will be important for us in talking about derivatives.
• Does a function f approach some number L as its input variable x goes to some number c
(often 0 or ±∞)? If so f (x) approaches L as x approaches c. Formally we say limx→c f (x) =
L.
• Examples:
1. lim k = k
x→c
∗
†
Please do not distribute without permission.
Ph.D. candidate, Department of Politics, Princeton University, Princeton NJ 08544.Email: [email protected]
1
2. lim x = c
x→c
1
2
x→∞ x
3. lim
=0
4. lim 2x = 6
x→3
• Uniqueness: lim f (x) = L and lim f (x) = M ⇒ L = M
x→c
1.1.1
x→c
Properties of Limits
Let f and g be functions with lim f (x) = A and lim g(x) = B.
x→c
x→c
• lim [f (x) + g(x)] = lim f (x) + lim g(x) = A + B
x→c
x→c
x→c
What property does this look like that we saw before?
• lim αf (x) = α lim f (x) = αA
x→c
x→c
• lim f (x)g(x) = [lim f (x)][lim g(x)] = AB
x→c
f (x)
x→c g(x)
• lim
x→c
lim f (x)
=
x→c
lim g(x)
=
x→c
x→c
A
B,
provided B 6= 0
Example 2
lim (2x − 3) = 2 lim x − 3 lim 1 = 2 × 2 − 3 × 1 = 1
x→2
x→2
x→2
lim xn = [lim x] · · · [lim x] = c · · · c = cn
x→c
x→c
x→c
Example 3 Limit examples. Calculate the following limits at your desk.
limx→2 (x3 − 5x + 7) = 5
5
limx→2 ( 4x35+7 ) = 39
x2 −25
2 +x−30 (factor and
x√
√
x−3)( x+3)
√
limx→9 ((x−9)((
(1)
x+3)) 16
√
limx→5
reduce,
10
11 )
limx→1+ 3 x + 1 ln(x + 1) (get 0*∞ at first....what to do? We’ll have to use something called
L’Hopital’s Rule that we’ll learn in a bit)
1.2
Sequence Review
Another helpful concept that we have seen a little of previously is the sequence.
• A sequence {yn } = {y1 , y2 , y3 , . . . , yn } is an ordered set of real numbers, where y1 is the first
term in the sequence and yn is the nth term. Generally, a sequence extends to n = ∞. We
can also write the sequence as {yn }∞
n=1 .
• Sequences are similar to functions. Before, we had y = f (x) with x specified over some
domain. Now we have {yn } = {f (x)} with each value of x having its own index, n = 1, 2, 3, . . ..
Thus the first number we put into our function gives us y1 .
• Three kinds of sequences:
2
1. Sequences that converge to a limit.
2. Sequences that increase or decrease without bound.
3. Sequences like that neither converge nor increase without bound — alternating over the
number line.
*Board examples of all 3*
1.2.1
The Limit of a Sequence
• We’re often interested in whether a sequence converges to a limit. Limits of sequences are
conceptually similar to the limits of functions addressed in the previous lecture.
Definition 2 (Limit of a sequence). The sequence {yn } has the limit L, that is lim yn = L,
n→∞
if for any > 0 there is an integer N (which depends on ) with the property that |yn − L| < for each n > N . {yn } is said to converge to L. If the above does not hold, then {yn } diverges.
Example 4
1. lim 2 − n12 = 2
n→∞
• Uniqueness: If {yn } converges, then the limit L is unique.
• Properties: Let lim yn = A and lim zn = B. Then
n→∞
n→∞
1. lim [αyn + βzn ] = αA + βB
n→∞
2. lim yn zn = AB
n→∞
yn
n→∞ zn
3. lim
=
A
B,
provided B 6= 0
• Finding the limit of a sequence in Rn is similar to that in R1 .
2
The Derivative
Definition 3 The derivative of a function f (x) is simply the slope of the secant of f(x) at a pair
of points very close to (x, f (x)):
f (x) − f (a)
f (a + h) − f (a)
= lim
h→0
x−a
h
This looks very similar to how we calculated the slope of a linear function.
The derivative is “evaluated at a point” which converges to x (i.e., h → 0).
f 0 (a) = lim
x→a
Definition 4 A straight line is tangent to a curve, at some point, if both line and curve pass
through the point with the same direction; such a line is the best straight-line approximation to the
curve at that point.
Example 5 Graphical board examples
Notation 1 The slope of the tangent line of f (x) at any point x is called the derivative and we
(x)
denote it f 0 (x), or in “Leibniz notation”: dfdx
. Think of this as saying ”how is f (x) changing
“df (x)” with an infinitesimally small change in x “dx”.
3
3
Calculating Derivatives
3.1
Calculating Derivatives
Lets start with the simple case where we have a function f (x) = xk . Then the derivative is
f 0 (x) = kxk−1 . For example, f (x) = 2x, f 0 (x) = 2.
You’ll use this over and over, but lets prove that this is actually the case. Before proving this,
though, we need a “lemma”. A lemma is an additional statement (often proven elsewhere) that we
need in order to prove the thing we are interested in.
Lemma 3.1 (Binomial expansion): For any positive integer k, (x + h)k = xk + a1 xk−1 h1 +
k!
...ak−1 x1 hk−1 + ak hk , where aj = j!(k−j)!
, for j = 1, ...k
, ak = 1
Note a1 = k, a2 = k(k−1)
2
2
For example, (x + 3) = 2x2 + 6x + 9
With this in mind lets simply apply this lemma to our expression of the derivative. Instead of
using the notation f (x), lets just use the xk part:
Proposition 3.2
f (x) = xk ⇒ f 0 (x) = kxk−1
3.2
Rules for calculating derivatives
Theorem 3.3 (Algebraic Operations of Derivatives) Let f, g : X 7→ R be differentiable at
c ∈ X and X ⊂ R. Then,
1. (kf )0 (c) = kf 0 (c) for all k ∈ R,
2. (f + g)0 (c) = f 0 (c) + g 0 (c),
3. (f g)0 (c) = f 0 (c)g(c) + f (c)g 0 (c) (Product Rule),
0
0
(c)g 0 (c)
4. fg (c) = f (c)g(c)−f
for g(c) 6= 0 (Quotient Rule).
g(c)2
Exercise 1 Prove (f g)0 (c) = f 0 (c)g(c) + f (c)g 0 (c) (Product Rule)
0
0
(c)g 0 (c)
Exercise 2 Prove fg (c) = f (c)g(c)−f
for g(c) 6= 0 (Quotient Rule).
g(c)2
• Calculate the derivative of the following functions.
Example 6
• x4
• x3 − x
• 6x2 + 1
• (6x2 +
x
2
+ 1)2
• (3x + 2)( 21 x + 1)
4
3.3
Chain Rule
Reminder: A composite function is a function whose value depends on the output of another
function.
f (x) = x2 , g(x) = (2x + 1), hence f (g(x)) = (2x + 1)2
Definition 5 The Chain Rule is a formula for the derivative of the composite of two functions.
In intuitive terms, if a variable, y, depends on a second variable, u, which in turn depends on a
third variable, x, then the rate of change of y with respect to x can be computed as the product of
the rate of change of y with respect to u multiplied by the rate of change of u with respect to x.
The chain rule may be stated in any of several equivalent forms:
Theorem 3.4 Suppose h(x) = f ◦ g. Then h0 (x) = (f (g(x)))0 = f 0 (g(x))g 0 (x).
or in the Leibniz notation:
df
df du
=
·
.
dx
du dx
(Note: There should be some conditions for this theorem to work such as continuity of f and
the existence of f 0 . For now, let’s assume all the necessary conditions are met.)
4
Using Derivatives to Analyze Functions
Lemma 4.1 A function is strictly increasing at x if f is differentiable and its derivative is
positive at x. That is if f 0 (x) > 0
Lemma 4.2 A function is strictly decreasing at x if f is differentiable and its derivative is
negative at x. That is if f 0 (x) < 0
4.1
Steps for characterizing whether function is increasing or decreasing
1. Calculate derivative
2. Find where derivative is equal to 0 by solving f 0 (x) = 0.
3. Sub in values of x to the left and right of these points (or point) into the derivative f 0 (x) and
check sign
4. If positive then increasing in that region, if negative then decreasing in that region
Example 7
• f (x) = x2 − 2x + 1 ⇒ f 0 (x) = 2x − 2, since 2x − 2 > 0 whenever x > 1, f is increasing if
x > 1, and decreasing if x ≤ 1.
• f (x) = x−2 + 2x
• f (x) =
x2
2x+1
• f (x) =
x3
x3 +1
5
5
The Second Derivative
In several of the examples we did, we saw that the value of the derivative depended on the value
of x. Hence we also want to ask questions about how the derivative itself changes as a function of
x. I.e., we want to take the derivative of the derivative.
Definition 6 The derivative of the first derivative is the second derivative. We often use the
d2 y
notation f 00 (x) or dx
2 . The second derivative is the slope of the line tangent to the first derivative
at the point x. We can think of this as the “change in change” of the function. In physics, the first
derivative is the speed of an object while the second derivative is the acceleration of an object.
5.1
Calculating the 2nd Derivative
Simply take the derivative of the first derivative. All rule for differentiation continue to apply.
Write neatly, things can get messy and complicated.
5.2
Using the 2nd Derivative
The second derivative allows us to more completely characterize the behavior of a function. While
the first derivative tells us whether a function is increasing or decreasing at some point, it doesn’t
tell us whether the pace of increase/decrease is changing.
Two important properties of a function can be checked with the second derivative.
Definition 7 A function is convex (or concave up) in a region if a secant line in any two points
of the region is above f . Formally, the function f : A → R, defined on the convex set A ⊂ Rn is
convex if f (αx0 + (1 − α)x) ≤ αf (x0 ) + (1 − α)f (x) ∀ x and x0 ∈ A and all α ∈ [0, 1].
Definition 8 A function is concave in a region if a secant line in any two points of the region
is below f . Formally, the function f : A → R, defined on the convex set A ⊂ Rn is concave if
f (αx0 + (1 − α)x) ≥ αf (x0 ) + (1 − α)f (x) ∀ x and x0 ∈ A and all αin[0, 1].
Example 8 board example
To know if a function is convex, we do not need to graph it or figure out the slope of all secant
lines through any two of its points. We just check if the second derivative is positive.
Definition 9 A function is convex in a region if f 00 (x) > 0 in that region.
Definition 10 A function is concave in a region if f 00 (x) < 0 in that region.
Example 9
• f (x) = x2 ⇒ f 0 (x) = 2x ⇒ f 00 (x) = 2 > 0. So this function is convex everywhere.
• f (x) = −x2 ⇒ f 0 (x) = −2x ⇒ f 00 (x) = −2 < 0. So this function is concave everywhere.
6
6
Graphing
Using the first and second derivatives we can sketch the graph of a function and identify several
important properties of the function.
Steps to graph a function:
1. First find the points at which f 0 (x) = 0 or f 0 is not defined. Such points are called critical
points of f .
2. Evaluate the function at each of these critical points and plot them in the graph.
3. Then, check the sign of f 0 for each of the intervals defined by these critical points.
4. If f 0 > 0 then draw the graph increasing over I, if f 0 < 0 then draw the graph decreasing
over I.
5. Find the points at which f 00 (x) = 0 or f 00 is not defined. Such points are called second order
critical points of f , or if the second derivative actually changes sign there, inflection points
of f .
6. Then, check the sign of f 00 for each of the intervals defined by these critical points.
7. If f 00 > 0 then draw the graph concave up (or convex) over I, if f 00 < 0 then draw the graph
concave down (or concave) over I.
Example 10
• f (x) = x3 + 3x
f 02 + 3 > 0 So the function is always increasing.
f 00 (x) = 6x So the function in concave for x < 0 and convex for x > 0.
f (0) = 0, f 0 (0) = 3 so slope 3 at the origin.
Note: Draw in class.
• f (x) = (1/3)x3 − 9x + 3
f 0 (x) − 9 = (x + 3)(x − 3) So increasing on (−∞, −3) and (3, ∞) and decreasing on (−3, 3).
Note: Draw in class.
Many times we will be interested in finding the first and second order critical points in order
to find maxima and minima of a function. However, before we move on to this we will now discuss
several additional rule of differentiation that will frequently arise.
6.1
Asymptotes
Vertical asymptotes occur at points where the function is not defined.
For example f (x) = x1 is not defined at x = 0.
7
7
Optimization
We can use calculus to easily find the minimums and maximums of a function.
Definition 11 Looking at the graph, we note that the maximum and minimums occur where the
function changes from being increasing to being decreasing and vice versa. Since the derivative
is positive when f is increasing, and negative when f is decreasing, these points of minimums or
maximums occur when the derivative is equal to 0. The points where f 0 = 0 are called Critical
Points.
Example 11 Find the critical points of f (x) = 2x6 − 3x4 + 2.
f 05 −12x3 = 12x3 (x2 −1) = 12x3 (x−1)(x+1). So the critical points are at x = 0, x = 1, x = −1.
All the (interior) maximums and minimums are found at critical points. The second derivative
helps determine if a critical point is a maximum, a minimum, or neither.
If f 0 (x0 ) = 0 and f 00 (x0 ) < 0 then x0 is a maximum of f .
If f 0 (x0 ) = 0 and f 00 (x0 ) > 0 then x0 is a minimum of f .
If f 0 (x0 ) = 0 and f 00 (x0 ) = 0 then we do not know, it might be a max, a min or neither (These are
called saddle points). See examples.
Example 12
f (x) = 2x6 − 3x4 + 2
− 12x3 ⇒ critical points at x = 0, x = 1, x = −1.
004
f − 36x2 ⇒
f 05
f 00 (0) = 0
f 00 (1) = 24
f 00 (−1) = 24
So local mins at x = −1 and x = 1. Note: Make a table and to study the sign of f 0 to make the
graph of this function.
Example 13
f (x) = x3
f 02 ⇒ Critical point at x = 0 everywhere else positive so f increasing
f 00 (x) = 6x so f 00 (0) = 0. Note: Draw graph.
7.1
Looking for Minimums and Maximums
Steps:
1. Take derivative
2. Find the x such that the derivative function= 0
8
3. Evaluate the second derivative at those “critical points” to determine if at that x there is a
minimum or a maximum.
Example 14
max x3 − 3x
x
f 02 − 3
f 0 (x) = 0 when x = ±1
f 00 (x) = 6x, so f 00 (1) = 6 > 0 and f 00 (−1) = −6 < 0
So there is a local max at x = −1 and a local min at x = 1.
Example 15
max
x
x2
x+1
2x(x+1)−x2
(x+1)2
f 0 (x) =
f 0 (x) = 0 when x = 0 and x = −2
2 −2(x2 +2x)(x+1)
f 00 (x) = (2x+2)(x+1)(x+1)
4
f 00 (0) = 2 > 0
So there is a local min at x = 0
f 00 (−2) = −2 < 0
So there is a local max at x = 2.
Example 16 Example from Economics: Profit Maximizing [skipped]
Let p denote the price the firm obtains for each of the units it produces.
Let c(q) denote the cost function of the firm. The cost function refers to the total cost of
producing q units.
The derivative of the cost function is called the Marginal Cost, it refers to the cost of producing
1 additional unit when q nunits have been produced.
Let q denote the quantity produced. This is the decision variable of the firm.
The problem of the firm can be denoted as:
max pq − c(q)
q
We solve it using calculus.We calculate the First Order Condition for optimization, namely the q ∗
such that the first derivative equals 0. Then we obtain the second derivative, evaluate it at q ∗ and
check that it is negative, that way we know we are at a maximum.
FOC: p = c0 (q) This is interpreted as Marginal revenue (p) equals Marginal Cost.
SOC: c00 (q) > 0 This is saying that we need to have increasing marginal costs at q for this to be
a maximum. This is the typical assumption of the perfect competition model you will see in the fall.
Note: Do the following numerical example: Obtain the profit maximizing production when
c(q) = q 2 + 5 and p=5.
9
8
Additional Differentiation Rules: Chain Rule and Exponential
8.1
Examples
• f (x) = x2 − 2x + 1 ⇒ f 0 (x) = 2x − 2
• f (x) = 6x5 − 3x3 − 4x2 + 7x − 11 ⇒
• f (x) = 2x2 ln(x) ⇒
• f (x) =
(x2 +8)
x−1
⇒
• f (x) =
(ex +x)
13x2
⇒
• f (x) = (x2 + 8x)3 ⇒
• f (x) = 3ln(16x3 − 7x) ⇒
• f (x) = g(3x2 − 7)
• f (x) = g(x)h(x) − g(6x)
8.2
Exponential and Log Derivatives
We will frequently encounter logs (ln x) and exponentials (ex ) in our studies. Derivatives of these
functions have special properties.
8.2.1
Derivatives of the natural log ln
1.
d
dx
ln x =
1
x
2.
d
dx
ln xk =
3.
d
dx
ln u(x) =
d
dx k ln x
u0 (x)
u(x)
=
k
x
(by the chain rule)
Lets prove property 1, as it is very important (S/B 94).
Start with the standard definition,
ln(x + h) − ln(x)
1
x+h
= ln(
)
h
h
x
= ln(1 +
h 1
) h = ln(1 +
x
1
1
x h
1)
h
Now we will use a common tactic to help simplify things, which is to define a new variable as a
more complicated function of something we already have. Let m = h1 . As h → 0, m → ∞. Hence
we have
lim (ln(1 +
m→∞
1
x m
m
) ) = ln( lim (1 +
m→∞
10
1
x m
m
) )
We can interchange the limit and ln only because ln is a continuous function. I.e., if xm → xo
1 m
then ln xm → ln xo . Furthermore, the definition of e was e = limm→∞ (1 + m
) . Further, we had
r m
the identity er = limm→∞ (1 + m
) . Thus we let r = x1 . We have
ln( lim (1 +
m→∞
1
x m
m
1
) ) = ln e x =
Proposition 8.1
f (x) = lnx ⇒ f 0 (x) =
1
x
Example 17
Show lim
x→0
8.2.2
ln(x + 1)
=1
x
Derivatives of the exponential function: ex
1.
d
x
dx αe
2.
d u(x)
dx e
= αex
= eu(x) u0 (x)
*graph examples on the board*
*how could we prove 1?*
Exercise 3 Suppose f (x) = loga x. Show f 0 (x) =
1
lna
·
1
x
• Examples: Find dy/dx for
1. y = ln(4x)
2. y = ln(e2x )
3. y = ln(ln x)
4. y =
ln 2x x
ln 4x e
Proposition 8.2
For any positive base b,
d x
dx a
= (ln a) (ax ).
Example 18 f (x) = 10x
Take natural log on both side.
ln(f (x)) = x ln 10
Taking the derivative of both sides we have
f 0 (x)
f (x) = ln 10
f 0 (x) = f (x) ln 10
Proposition 8.3
f (x) = ex ⇒ f 0 (x) = ex
11
1
x
8.3
L’Hospital’s Rule
• In studying limits, we saw that lim f (x)/g(x) =
x→c
lim f (x) / lim g(x) , provided that
x→c
x→c
lim g(x) 6= 0, which will cause the limit to be unbounded.
x→c
• If both lim f (x) = 0 and lim g(x) = 0, then we get an indeterminate form of the type 0/0
x→c
x→c
as x → c. However, we can still analyze such limits using L’Hospital’s rule.
Theorem 8.4 L’Hospital’s Rule: Suppose f and g are differentiable on a < x < b and that
either
1. lim f (x) = 0 and lim g(x) = 0, or
x→a+
x→a+
2. lim f (x) = ±∞ and lim g(x) = ±∞
x→a+
x→a+
Suppose further that g 0 (x) is never zero on a < x < b and that
lim
f 0 (x)
=L
g 0 (x)
lim
f (x)
=L
g(x)
x→a+
then
x→a+
Example 19 Use L’Hospital’s rule to find the following limits:
Suppose x > 0. limx→0
rx −1
x
take derivative of top and bottom wrt to x:
d x
r
dx
d
dx
We have from the power rule above that limx→0
9
d x
r
dx
d
dx
= limx→0
rx ln r
1
= ln r limx→0
Derivatives of Trigonometric Functions
d
(sinx) = cosx
dx
d
(cosx) = −sinx
dx
d
(tanx) = sec2 x
dx
d
(cscx) = −cscx · cotx
dx
d
(secx) = secx · tanx
dx
d
(cotx) = −csc2 x
dx
12
rx
1
= ln r