Homework 10: Optimization¶
Submit this homework via Dropbox. For the deadline please consult the schedule posted on Blackboard.
Python-scripts are submitted in one file called:
homework10.py
Exercise 1¶
Use the golden-section search algorithm to find all of the local maxima of the function. Do not use a built-in algorithm but the one we developed last time in class. I need to see whether you are able to process functions that are “handed into” other functions (or algorithms).
within the interval [-10, 10]. Hint: plotting the function first will give you a good idea where to look.
Exercise 2¶
Find the allocation of capital \(K\) and labor \(L\) that maximizes the following profit function of a representative firm:
where the wage rate is \(w = 1.84\) and the cost of capital is \(r=0.75\) and the total factor productivity (TFP) is \(A=4\).
In order to NOT have to maximize over two dimensions, I would like you to maximize this function w.r.t. capital \(K\) only. You would simply set labor \(L\) equal to specific values such as \(L=\{1,1.5,2,2.5,3,3.5,4,4.5,5\}\). An then for each one of these labor values you would search for the optimal level of capital \(K\) that maximizes profits. This results in nine separate optimizations. I suggest to do this from within a loop. The result should be nine optimal \(K^*\) values.
Hint: I would define \(L\) as a global variable so you can change its value outside of the function.
Harder: Exercise 3¶
Write a version of function golden section
from class that plots
intermediate results so the user can track visually how the algorithm gets
closer to the optimization point in each iteration.
More specifically, plot the function being optimized, then at each
step draw a vertical line at the positions xl
, xr
, xm
, and y
(with the line
at y
in a different colour). Apply this new golden section algorithm to the
function in exercise 1.
As you run this code you should visually see how the brackets move in at each iteration and get closer and closer to the maximum.