Uploaded by Aiziya Yesbergen

Derivatives

advertisement
Cheat sheet on derivatives and optimization
September 11-15, 2023
The concept of the derivative
The meaning of the derivative
Imagine a graph of distance vs. time!
Now the distance over time (the slope of our function) is the velocity.
If we pick a point on the graph, and draw a ray from the origin to the graph
like this:
1
the slope will measure the average speed up till that moment. The average
speed is quite useful – e.g. when we want to estimate how much time we will
need to cover a similar distance.
In other cases, however we are more interested in our momentary speed – e.g
when we want to check whether we exceeded the speed limit at a certain point.
The graphical representation of this would be a tangent to our function:
2
The deraivative is nothing else but the slope of this tangent.
Why use derivatives in economics
We are going to use derivatives a lot, and I do mean a lot. the reasons for this
are twofold.
ˆ Economist heavily rely on marginal thinking. When you determine how
many workers to employ at your firm, you do not ask yourself the question:
”Should I employ 340 people?” Rather you ask: ”Should I hire one more
person?” The choices we make are more about small adjustments, then
all-out decisions.
ˆ Rationality was about finding what is the best of the available options.
Most of the cases we are trying to model behavior by striving to achieve a
maximum: people want to maximize their welfare, firms want to maximize
their profit, etc. That means that the mathematical form of many of
our exercises will be some kind of optimization problem. Optimization
methods – as we will soon see – rely on derivatives.
Calculating the derivative
Without going deeply into the math here, I am going to give you a handful of
rules. If you memorize these simple rules, you are going to be able to handle
the overwhelming majority of the functions that you encounter in this course.
The constant function
Rule:
f (x) = c ⇒ f ′ (x) = 0
Example:
f (x) = 4
f ′ (x) = 0
The linear function
Rule:
f (x) = k · x + c ⇒ f ′ (x) = k
Example:
f (x) = 2x + 5
f ′ (x) = 2
3
The generalized power function
Rule:
f (x) = k · xa ⇒ f ′ (x) = k · a · xa−1
Example:
f (x) = 2x5
f ′ (x) = 2 · 5 · x4 = 10 · x4
Rule for sums and differences
Rule:
f (x) ± g(x) ⇒ f ′ (x) ± g ′ (x)
Example:
f (x) = x3
g(x) = 2x − 3
h(x) = x3 + (2x − 3)
h′ (x) = 3 · x2 + 2
*Bonus material: the natural logarithm function
Rule:
f (x) = k · ln x ⇒ f ′ (x) =
k
x
Example:
f (x) = 3 · ln x
f ′ (x) =
3
x
*Bonus material: composite functions
Rule:
h(x) = f (g(x)) ⇒ h′ (x) = f ′ (g(x)) · g ′ (x)
Example:
f (x) = x3
g(x) = 5x − 3
h(x) = (5x − 3)3
h′ (x) = 3 · (5x − 3)2 · 5 = 15 · (5x − 3)2
4
More on derivatives
Higher-order derivatives
We get functions as results, so we can take their derivatives as well.
f (x) = x3 − 4x2 + 3x − 10
f ′ (x) = 3 · x2 − 8x + 3 (first-order derivative)
f ′′ (x) = 6x − 8 (second-order derivative)
f ′′′ (x) = 6 (third-order derivative)
and so on.
Increasing and decreasing functions
By calculating the value of the derivative at certain points we can learn more
about the shape of a function.
If the first-order derivative is positive, the function goes upwards, thus the
function at this point is increasing. If the first-order derivative is negative, the
function goes downwards, thus the function at this point is decreasing.
*Bonus material: Convex and concave functions
Some functions ”bend” upwards (convex functions), some ”bend” downwards
(concave functions).The second-order derivative indicates which is the case.
If the second-order derivative is positive, the function is convex at that point.
Let’s take the function f (x) = x2 as an example!
f ′ (x) = 2x
f ′′ (x) = 2
That is positive (everywhere), so this function ”bends” upward.
If the second-order derivative is√negative, the function is concave at that point.
Let’s take the function f (x) = x = x0.5 as an example!
f ′ (x) = 0.5 · x−0.5
1
4 · x1.5
That is negative (for every positive number), so this function ”bends” downward.
f ′′ (x) = −0.25 · x−1.5 = −
5
Optimization
Maxima and minima
If we are looking for the (local) maximum of a function, it cannot be on an
increasing part of a function, since then moving along the function would bring
us higher. It cannot be on a decreasing part either, because then moving back
would get us higher. Hence at the maximum, the first-order derivative can neither be positive, nor negative. This leaves us with one option: at the maximum,
the first-order derivative is zero. (This is often referred to as the first-order condition, abbreviated as FOC.)
We can use a similar reasoning for (local) minima as well. The minimum cannot be on a decreasing part of a function, since then moving along the function
would bring us lower. It cannot be on an increasing part either, because then
moving back would get us lower. Hence at the minimum, the first-order derivative can neither be positive, nor negative, only zero.
How to decide whether we have a minimum or a maximum? In most exercises in
this course, you’ll be told whether you should look for a maximum or a minimum.
Bonus material: However, if you want to check it for yourself, the secondorder derivative is going to be helpful. If it’s negative, we have a maximum.
Recall that a negative second-order derivative means that the first-order derivative is decreasing, thus turning from positive to zero to negative. We have an
increasing part, the maximum, then a decreasing part.
If the second-order derivative is positive, we have a minimum. (A decreasing
part, a minimum, then an increasing part.)
What happens if the second-order derivative is zero? Then it’s neither a minimum, nor a maximum: it is a point of inflection. Here the function turns from
convex to concave or vice versa.
Examples:
min f (x) = x2 − 4x + 10
F OC : f ′ (x) = 2x − 4 = 0
Solving that, we find that the minimum is at:
x=2
[Double-checking that we truly have a minimum:
f ′′ (x) = 2,
so we are good.]
max f (x) = −x2 + 10x + 2
F OC : f ′ (x) = −2x + 10 = 0
6
Solving that, we find that the maximum is at:
x=5
[Double-checking that we truly have a maximum:
f ′′ (x) = −2,
so everything is fine.]
Multivariate functions
Many functions have more than one variable, e.g. z(x, y) = 3x + 2xy + y 2 . How
can we handle functions like that?
We will introduce the concept of partial derivatives. I.e. we are going to pretend
that we have only one variable. So the partial derivative of z with respect to
dz
) is taking the derivative of z while pretending that y is a
x (denoted as dx
constant.
dz
= 3 + 2y + 0
dx
Similarly, when we calculate the partial derivative of z w.r.t. y, we pretend that
x is a constant.
dz
= 0 + 2x + 2y
dy
Optimization and multivariate functions
We are going to proceed like we did previously: we are going to use the first-order
condition to find the maximum (or minimum) point of a function. However, we
are going to use more than one FOC, one or each partial derivative.
Example:
max z(x, y) = 60x + 34y − 4xy − 6x2 − 3y 2 + 5
x,y
z
= 60 − 4y − 12x = 0
x
z
F OCy : = 34 − 4x − 6y = 0
y
F OCx :
x∗ = 4, y ∗ = 3
Note that this time again we could check whether we have found a maximum
or a minimum point. However, the methods are too advanced for our discussion,
so the interested reader is referred to any college textbook on calculus.
7
Optimization with a constraint
Many times, it is impossible to maximize (or minimize) a function without
constraint. (It is worth to also ponder the philosophical implications of the
above statement.) Would you be able to find an x and a y that maximizes
f (x, y) = x + y?
Also, in real life almost all of our choices are constrained one way or the other.
I cannot spend more than my budget, I cannot allocate more than 24 hours per
day for activities, etc.
Let us look at an example to deal with the mathematical formulation of this
problem:
max x · y
x,y
subject to the constraint:
x + y = 20.
Our first step is to use the constraint to express one of the variables:
y = 20 − x.
Secondly, we plug this back to our original function:
max x · (20 − x).
x
We killed two birds with one stone! We have only one variable and thus one
FOC, and more importantly, we don’t have to worry about the constraint: it’s
built into our new function!
The final steps of the solution:
max x · (20 − x) = 20x − x2
x
F OC : 20 − 2x = 0
x = 10, y = 20 − x = 10
Bonus material: The Lagrange method
An alternate way to optimize multivariate functions with a constraint is the
Lagrange method. Here we find a different way to work the constraint into our
function.
Let’s solve the previous problem again! Our first step is to rearrange the constraint to zero:
x + y − 20 = 0
We multiply the left-hand side by λ and subtract the result from our original
function, thereby obtaining our Lagrange function:
L = x · y − λ · (x + y − 20)
8
Wait, what? Now we have three variables! That means we need three FOCs to
solve this problem.
F OCx : y − λ = 0
F OCy : x − λ = 0
F OCλ : x + y − 20 = 0
Easy calculation yields:
x = 10, y = 10, λ = 10
We got the previous result back and also some extra info. What does it mean
that λ = 10? It roughly means that if we increase our constraint by 1 (x + y =
21), then our maximum value will increase (approximately) by 10. (You can
try to check this.) So while this method requires more work, it rewards as with
some built in sensitivity check.
Practice problems
a) Maximize
√
u(x, y) = 4 x + y
s.t. the constraint
x + 2y = 100
b) Minimize
T C(K, L) = 4K + 2L
s.t.
√
K · L = 10
Parting words
Even though this whole stuff might sound intimidating, don’t worry! Practice
makes perfect and you’ll get the hang of it soon. Moreover, next week you will
see, why this was so important...
9
Related documents
Download