Docsity

Calculus and Optimization in Economics: Derivatives, Rules, and Partial Differentiation, Assignments of Calculus

Toggle sidebar
bg1
Economics 101A
Section Notes
GSI: David Albouy
Notes on Calculus and Optimization
1 Basic Calculus
1.1 Definition of a Derivative
Let f(x)be some function of x, then the derivative of f, if it exists, is given by the following limit
df (x)
dx = lim
h→0
f(x+h)−f(x)
h(Definition of Derivative)
although often this definition is hard to apply directly. It is common to write f0(x),or df
dx to be shorter, or
if y=f(x)then dy
dx for the derivative of ywith respect to x.
1.2 Calculus Rules
Here are some handy formulas which can be derived using the definitions, where f(x)and g(x)are functions
of xand kis a constant which does not depend on x.
d
dx [kf (x)] = kdf (x)
dx (Constant Rule)
d
dx [f(x)+g(x)] = df (x)
dx +df (x)
dy (Sum Rule)
d
dx [f(x)g(x)] = df (x)
dx g(x)+f(x)dg (x)
dx (Product Rule)
d
dx ·f(x)
g(x)¸=
df (x)
dx g(x)−dg(x)
dx f(x)
[g(x)]2(Quotient Rule)
d
dxf[g(x)] = f[g(x)]
dg
dg (x)
dx (Chain Rule)
For specific forms of fthe following rules are useful in economics
d
dxxk=kxk−1(Power Rule)
d
dxex=ex(Exponent Rule)
d
dx ln x=1
x(Logarithm Rule)
Finally assuming that we can invert y=f(x)by solving for xin terms of yso that x=f−1(y)then the
following rule applies
df −1(y)
dy =1
df (f−1(y))
dx
(Inverse Rule)
Example 1 Let y=f(x)=ex/2, then using the exponent rule and the chain rule, where g(x)=x/2,we
get df (x)
dx =d
dx ¡ex/2¢=d
d(x/2) ¡ex/2¢·d
dx ¡x
2¢=ex/2¡1
2¢=1
2ex/2. The inverse function of fcan be gotten
by solving for xin terms of y.y=ex/2⇒ln y=ln
¡ex/2¢=x
2ln (e)=x
2⇒x=2lnyusing the facts
from precalculus that ln eu=uln eand that ln e=1. The derivative of f−1(y)can be so lv ed directl y as
d
dy (2 ln y)=2d
dy (ln y)=2
³1
y´=2
yor indirectly through the Inverse Rule as df −1(y)
dy =1
1
2ex/2=1
1
2e2lny/2=
2
eln y=2
yusing the fact that eln y=y.1
pf3
pf4
pf5
pf8
pf9
pfa

Partial preview of the text

Download Calculus and Optimization in Economics: Derivatives, Rules, and Partial Differentiation and more Assignments Calculus in PDF only on Docsity!

Economics 101A Section Notes GSI: David Albouy

Notes on Calculus and Optimization

1 Basic Calculus

1.1 Definition of a Derivative

Let f (x) be some function of x, then the derivative of f , if it exists, is given by the following limit

df (x) dx = lim h→ 0

f (x + h) − f (x) h (Definition of Derivative)

although often this definition is hard to apply directly. It is common to write f 0 (x), or (^) dxdf to be shorter, or

if y = f (x) then dydx for the derivative of y with respect to x.

1.2 Calculus Rules

Here are some handy formulas which can be derived using the definitions, where f (x) and g (x) are functions of x and k is a constant which does not depend on x.

d dx

[kf (x)] = k df (x) dx

(Constant Rule)

d dx [f (x) + g (x)] =

df (x) dx

df (x) dy (Sum Rule)

d dx [f (x) g (x)] =

df (x) dx g (x) + f (x)

dg (x) dx (Product Rule)

d dx

f (x) g (x)

df(x) dx g^ (x)^ −^

dg(x) dx f^ (x) [g (x)]^2

(Quotient Rule)

d dx

f [g (x)] =

f [g (x)] dg

dg (x) dx

(Chain Rule)

For specific forms of f the following rules are useful in economics

d dx

xk^ = kxk−^1 (Power Rule) d dx

ex^ = ex^ (Exponent Rule) d dx

ln x =

x

(Logarithm Rule)

Finally assuming that we can invert y = f (x) by solving for x in terms of y so that x = f −^1 (y) then the following rule applies df −^1 (y) dy

df (f−^1 (y)) dx

(Inverse Rule)

Example 1 Let y = f (x) = ex/^2 , then using the exponent rule and the chain rule, where g (x) = x/ 2 , we get df dx^ (x )= (^) dxd

ex/^2

= (^) d(x/d2)

ex/^2

· (^) dxd

¡ (^) x 2

= ex/^2

2

= 12 ex/^2. The inverse function of f can be gotten

by solving for x in terms of y. y = ex/^2 ⇒ ln y = ln

ex/^2

= x 2 ln (e) = x 2 ⇒ x = 2 ln y using the facts from precalculus that ln eu^ = u ln e and that ln e = 1. The derivative of f −^1 (y) can be solved directly as d dy (2 ln^ y) = 2^

d dy (ln^ y) = 2

1 y

= (^2) y or indirectly through the Inverse Rule as df^

− (^1) (y) dy =^ 11 2 ex/^2

2 e2 ln^ y/^2

2 eln^ y^ =^

2 y using the fact that^ e

ln y (^) = y.

-5 -2.5 0 2.5 5

10

5

0

x

y

x

y

y = exp (x/2) dydx = 12 exp (x/2)

0 2.5 5 7.5 10

5

0

-2.

y

x

y

x

x = 2 ln y dxdy = (^2) y

1.3 Partial Differentiation

Taking derivatives of functions in several variables is very straightforward (at least with the functions used in economics). Say we have a function in two variables, x and y, which we can write as h (x, y). Partial differentiation, which uses a "∂" ("del") instead of a "d", can be done in either in x or in y, by writing either " (^) ∂x∂ " or " (^) ∂y∂ " in front of h (x, y), respectively, and then taking the derivative with respect to the variable chosen as we would in the single variable case, treating the other variable as a constant.

Example 2 Let h (x, y) = 3x^2 ln y, shown below in the graphs for ranges 0 ≤ x ≤ 2 and 0 ≤ y ≤ 10

0.25 0.5 0.75 1 1.25 1.5 1.75 2 2.5^5 7.5^10

20

0

x

y

h(x,y)

x

y

h(x,y)

3-D representation of 3 x^2 ln y

0.5 1 1.5 2

10

5

x

y

x

y

Level curves 3 x^2 ln y = k for k = 1, 2 , ..., 27

Note the second plot of the level curves are like what you would find in a topographic contour map. Applying the partial differentiation rules we get the partial derivatives

∂ ∂x

3 x^2 ln y

= 3 ln y

μ ∂ ∂x

x^2

= 3 ln y (2x) = 6x ln y

∂ ∂y

3 x^2 ln y

= 3x^2

μ ∂ ∂y

ln y

= 3x^2

μ 1 y

3 x^2 y

Example 4 Assume that our equation is h (x, y) = 3x^2 ln y = 3. Then using the derivative we took above

we have dH dx(x )= 6x ln y + 3 x

2 y

df(x) dx = 0.^ Solving for^

df(x) dx we get^

df(x) dx =^ −^ (6x^ ln^ y)^ /

3 x^2 y

. This expression

is in both x and y, but we could evaluate it meaningfully for any value of x and y satisfying 3 x^2 ln^ y^ = 3^ for instance x = 1 and y = e which means that df dx^ (1) = − (6 · 1) /

e

= − 2 e. Of course this derivative may be different for different values of x.

0.5 1 1.5 2

10

5

x

y

x

y

Implicit derivative at x = 1, y = e is − 2 e

2 Optimization

2.1 Increasing and Decreasing Functions

By looking at the definition of a derivative we can say "loosely speaking" that for h small h ≈ 0 and positive h > 0 that df (x) dx

f (x + h) − f (x) h or that df (x) dx

h = f (x + h) − f (x)

Now we say that a function f is increasing at x if we have f (x + h) > f (x) or f (x + h) − f (x) > 0. However since h > 0 this implies that df dx^ (x )> 0. Equivalently a function f is decreasing at x if we have

f (x + h) < f (x) which then implies that df dx^ (x )< 0. Therefore the sign of the derivative tells us whether or not a function is increasing (the derivative is positive) or decreasing (the derivative is negative).

2.2 Unconstrained Optimization

2.2.1 One Variable

Consider first the case with one variables x where x ∈ R, i.e. x can take on any real value. We wish to maximize the objective function f (x) and there are no constraints. Thus we solve

max x f (x)

Assuming f (x) has a maximum (for example f does not go to ∞)^1 and that it is differentiable everywhere, then any maximum (x∗) must solve the following first order necessary conditions (FOC)

df (x∗) dx

= 0 (FOC)

(^1) Weierstrauss’s Theorem say shat f (x, y) will be guaranteed to have a maximum if f is continuous and x and y are defined over a closed and bounded domain. See an analysis book for more.

This is a single equation in a single unknown and so it should be solvable for x∗. and y∗. Why does this make sense? Well say df(x

∗) dx 6 = 0^ then that means that either^

df (x∗) dx >^0 or^

df (x∗) dx <^0 , i.e. f is either increasing or decreasing. If f is increasing however we could increase the value of f by increasing x a "little bit" to x∗^ + h in which case x∗^ never gave us our maximum. Similarly if f is decreasing we could reduce x a little bit and increase the value of x. Either case is impossible at a maximum and therefore we must have that df^ (x

∗) dx = 0.^ Remeber that a^ necessary^ condition is different from a^ sufficient^ condition in that we could have dfdx (x) = 0 and not be at a maximum, but at a minimum or a "saddle point." 2 Also we have to be careful to check points where f is not differentiable. Third, there may be several points that satisfy the condition df dx^ (x )= 0 Typically we will try and avoid these situations and deal with points where x∗^ is uniquely determined by (FOC), but not always.

Example 5 f (x) = ln x + ln (1 − x) + 3. The FOC implies df(x

∗) dx∗^ =^

1 x∗^ −^

1 1 −x∗^ = 0^ ⇒^ x

∗ (^) = 1 − x∗ (^) ⇒ x∗ (^) =

1 / 2. The maximum value of f achieves is then f (1/2) = 2 ln (1/2) + 3 ∼= 1. 614

0.25 0.5 0.

0

-1.

-2.

x

y

x

y

Graphic Representation of FOC

2.2.2 Two Variables

Now consider the case with two variables x and y, where both x, y ∈ R. Here we wish to solve

max x,y f (x, y)

With similar conditions we can expect the maximum (x∗, y∗) must solve the following first order necessary conditions (FOC)

∂f (x∗, y∗) ∂x

= 0 (FOC1)

∂f (x∗, y∗) ∂y

= 0 (FOC2)

This is a system of two equations in two unknowns, and thus should usually be solvable for both x∗^ and y∗. The intuition for these conditions is similar to that above.

Example 6 Let f (x, y) = −x^2 + 9x + xy − y^2. The FOC are ∂f^ (x

∗) ∂x =^ −^2 x

∗ (^) + y∗ (^) + 9 = 0, ∂f^ (x∗) ∂y = − 2 y∗^ + x∗^ = 0. The second equation implies x∗^ = 2y∗^ which can be substituted into the first equation to yield − 4 y∗^ +y∗^ +9 = 0 ⇒ y∗^ = 3 and x∗^ = 6. The maximum value attained is f (6, 3) = − 62 +54+18− 32 =

(^2) The second order necessary condition (SOC) states that the derivate of f should be decreasing, which implies that

the second derivative be negative d (^2) f dx^2 (x ∗) = d dx

h (^) df dx (x ∗) i ≤ 0. This implies that f will be increasing, then flat (at the maximum) and then decreasing afterwards. If f were first decreasing, then flat, and then increasing, that would imply that x∗ was at a minimum.

x∗^ = √^12 and y∗^ = √^12 achieving f

√^1 2 ,^ √^1 2

2 Note that there is a second tangency at the minimum

x∗^ = − √^12 and y∗^ = − √^12.

-2 -1 0 1 2

2

1

0

x

y

x

y

Constraint and Level Curves

2.51.^

-1.25 0 -2. -2.5 -1.25 (^0) 1.25 2.

5

0 -2.

x y

z

x y

z

3-D Plot of Objective and Constraint

2.3.2 Lagrangean

An equivalent way of solving this problem which at first may seem more difficult, but which in fact can be very useful (and sometimes easier) is to maximize a Lagrangean

L (x, y, λ) = f (x, y) + λ [c − g (x, y)] (Lagrangean)

where λ is a Lagrange multiplier, which we maximize just as we would an unconstrained problem, taking into account the extra variable λ. The FOC are then

L (x∗, y∗, λ∗) ∂x

∂f ∂x

(x∗, y∗) − λ∗^ ∂g ∂x

(x∗, y∗) = 0 (Lagrange FOC1)

L (x∗, y∗, λ∗) ∂y

∂f ∂y

(x∗, y∗) − λ∗^ ∂g ∂y

(x∗, y∗) = 0 (Lagrange FOC 2)

L (x∗, y∗, λ∗) ∂λ

= c − g (x∗, y∗) = 0 (Lagrange FOC3)

This is a system of three equations with three unknowns, and therefore should be relatively straightforward to solve. Notice that third FOC is just the constraint restated. Solve (Lagrange FOC1) and (Lagrange FOC2) for λ and you will get

λ∗^ =

∂f ∂x (x

∗, y∗) ∂g ∂x (x ∗, y∗) =

∂f ∂y (x

∗, y∗) ∂g ∂y (x ∗, y∗) (Lambda)

The second equation eliminates λ for the purposes of problem solving, which combined with the constraint (Lagrange FOC3) gives a 2 equation system in two unknowns (x∗, y∗). λ∗^ can then be solved for by plugging back into (Lambda). Notice that the second part of (Lambda) can be rearranged to produce the same result as (Tangency), making the equivalence of the two approaches obvious.

2.3.3 Interpreting the Lagrange Multiplier

So why all the fuss about the Lagrange multiplier? One reason why is that the Lagrange multiplier has an interesting interpretation. If we were to increase c by one unit how much higher would f go? The answer is λ∗: it tells us the value of relaxing the constraint by one unit (e.g. one dollar). More formally, take c to be a parameter (like prices or income) that is fixed over the optimization. Then really all of our solutions x∗, y∗, λ∗^ are dependent on c. We can then write x∗^ (c) , y∗^ (c) , λ∗^ (c), as the parameter c changes, these solutions will change. Now plug x∗^ (c) , y∗^ (c) into f and we will get a new

function F (c) = f (x∗^ (c) , y∗^ (c)) which gives us the maximum value of f we can get for a given c. Now take the total derivative of F with respect to c:

dF (c) dc

∂f (x∗^ (c) , y∗^ (c)) ∂x

dx∗^ (c) dc

∂f (x∗^ (c) , y∗^ (c)) ∂y

dy∗^ (c) dc

= λ∗^ (c)

∂g (x∗^ (c) , y∗^ (c)) ∂x

dx∗^ (c) dc

  • λ∗^ (c)

∂g (x∗^ (c) , y∗^ (c)) ∂y

dy∗^ (c) dc

= λ∗^ (c)

∂g (x∗^ (c) , y∗^ (c)) ∂x

dx∗^ (c) dc

∂g (x∗^ (c) , y∗^ (c)) ∂y

dy∗^ (c) dc

where the second equality comes from using (Lagrange FOC1) and (Lagrange FOC2). The constraint implies that g (x∗^ (c) , y∗^ (c)) = c. Differentiating the constraint totally with respect to c gives us

∂g (x∗^ (c) , y∗^ (c)) ∂x

dx∗^ (c) dc

∂g (x∗^ (c) , y∗^ (c)) ∂y

dy∗^ (c) dc

so the entire term in brackets above equals one leaving us with

dF (c) dc = λ∗^ (c)^ (Lambda Interpretation)

which is what we wanted to show: an increase in one unit of c increases F (or f ) by λ∗.

Example 8 Let f (x, y) = x + y subject to g (x, y) = x^2 + y^2 = 1 = c. Then

L (x, y, λ) = x + y + λ

1 − x^2 − y^2

with the FOC

∂L ∂x

= 1 − λ 2 x = 0 ∂L ∂x = 1 − λ 2 y = 0 ∂L ∂x

= 1 − x^2 − y^2 = 0

Solving for λ we have λ = (^21) x = (^21) y ⇒ x = y Putting this into the third equation we have 1 − x^2 − x^2 = 0 ⇒

2 x^2 = 1 ⇒ x^2 = 12 ⇒ x∗^ = √^12 = y∗. Also λ∗^ = (^2) √^11 2

= √^12.

2.4 Optimization with Inequality Constraints

In economics it is much more common to start with inequality constraints of the form g (x, y) ≤ c. The constraint is said to be binding if at the optimum g (x∗, y∗) = c, and it is said to be slack if at the optimum g (x∗, y∗) < c, clearly it must be one or the other. In this case it is not clear whether or not we can use the substitution method, since that would be invalid if the constraint is slack. The Lagrangean used above is still useful however except that the FOC’s above are amended to yield the following "Kuhn-Tucker" first order conditions

∂f ∂x

(x∗, y∗) − λ∗^

∂g ∂x

(x∗, y∗) = 0 (KT1) ∂f ∂y

(x∗, y∗) − λ∗^

∂g ∂y

(x∗, y∗) = 0 (KT2)

c − g (x∗, y∗) ≥ 0 , λ∗^ ≥ 0 , λ∗^ [c − g (x∗, y∗)] = 0 (KT3, KT4, KT5)

The first two conditions are identical to the Lagrangean FOC’s. The third condition now has three parts. The first is just a restatement of the constraint. The second part says that λ∗^ is always non-negative.

2.5 More than One Constraint (Optional)

When there is more than one constraints say g (x, y) ≤ c and h (x, y) ≤ d we can just write a longer Lagrangean with two multipliers λ and μ

L (x, y, λ, μ) = f (x, y) + λ [c − g (x, y)] + μ [d − h (x, y)]

The FOC’s are derived in the same way by taking the derivatives with respect to each variable (including the multipliers) and setting each equal to zero. If the constraints are not known to be binding then conditions like KT3-KT5 need to be written for each constraint (see the example below). While this may get tedious it should eventually boil down to a system of 4 equations in 4 unknowns. Moreover, if both constraints bind and are independent, then (x∗, y∗) will simply be whatever satisfies both constraints g (x∗, y∗) = c, and h (x∗, y∗) = d, a system of two equations in two unknowns and the first two FOC equations are only useful for determining the multipliers. More control variables like x and y only implies more derivatives. More constraints simply imply adding more Lagrange multipliers with or without the Kuhn-Tucker subtleties. There are other issues related to optimization that are in fact quite interesting and worth learning more about, but we won’t go over them here.^3

Example 11 "Bang-Bang" Solution Consider the very straightforward problem of maximizing f (x) = ax + b a simple linear function where a ≷ 0 is a constant of indeterminate sign. Without a constraint there is no solution to this problem (infinity isn’t technically considered a "solution"). However consider the constraints × ≥ 0 and x ≤ 10. The Lagrangean will then be

L (x, λ, μ) = ax + b + λx + μ (10 − x)

with FOC

a + λ∗^ − μ∗^ = 0 x∗^ ≥ 0 , λ∗^ ≥ 0 , x∗λ∗^ = 0 x∗^ ≤ 10 , μ∗^ ≥ 0 , (10 − x)∗^ μ∗^ = 0

Realize that both constraints cannot be binding at the same time so either λ∗^ = 0 or μ∗^ = 0. Also the FOC implies a = μ∗^ − λ∗^ There are then 3 cases worth considering here (1) a > 0 then it must be that a = μ∗^ > 0 and λ∗^ = 0. Otherwise a = −λ∗^ > 0 contradicts λ∗^ ≥ 0. The complementary slackness μ constraint must be binding and so x∗^ = 10 (2) a < 0 where by similar reasoning a = λ∗^ and x∗^ = μ∗^ = 0 and (3) a = 0 in which case μ∗^ = λ∗^ = 0 and x∗^ can take any value between 0 and 100 as they all yield ax∗^ = 0x∗^ = 0. This kind of a solution is known as a "bang-bang" solution - either you "bang" x at the top or at the bottom. You go for the maximum or minimum possible value of x.

0 2.5 5 7.5 10

10

5

0

x

f(x)

x

f(x)

a = 1, b = 0, x∗^ = 10

0 2.5 5 7.5 10

40

30

20

10

0

x

f(x)

x

f(x)

a = − 2 , b = 30, x∗^ = 0

(^3) A typical multivariate calculus book should have a chapter on this subject for equality constraints. Simon and Blume (1994) offers a full treatment and is a good read and reference with many economic applications.