Aim: Get accustomed to basic one-dimensional methods for solving a
I f (x) ≡ exp((x − 2)
) − 2 − x
g(x) ≡ exp((x − 2)
) − 2
1. Solve f (x) = 0 by the bisection method with initial x
L = 0.5 &
R = 1.5. You can use the SciPy root-finding package.
2.1. Solve x = g(x) by the fixed-point iteration with the updating rule
xk+1 = g(xk ). Code the algorithm by yourself.
Does this work? Explain why or why not.
2.2. Solve x = g(x) by the fixed-point iteration with the updating rule
xk+1 = λk xk + (1 − λk )g(xk ) where λ0 = 1 & λk = 0.99λk−1
I Using matplotlib.pyplot, plot the convergent sequence (like
what we saw in the lecture).
(Adapted from Collard, Lecture Notes 5. )
Assignment: Cournot Duopoly Model
Aim: Get accustomed to basic multi-dimensional methods for solving a
system of non-linear equations. Vectorize the system.
I Quantity competition by 2 firms i = 1, 2
I Inverse demand of a good: P(q) = q
I Cost function: Ci(qi) =
I Profit for each firm i: πi(q1, q2) = P(q1 + q2)qi − Ci(qi)
I Assume c1 = 0.6 & c2 = 0.8
Task 1. Solve for equilibrium q
for i = 1, 2 and P(q
) with α = 1.5 by
(1) Newton’s method: Code the algorithm by yourself. That is,
analytically derive the Jacobian of the set of FOCs.
(2) Broyden’s method: You can use the
SciPy root-finding package.
(3) Fixed-point iteration: Code the algorithm by yourself.
Task 2. Solve the model for all α ∈ [1, 3] (construct grids) by Broyden’s
method. Using matplotlib.pyplot, produce two plots with
x-axis α & y-axes (i) q
These solutions may offer step-by-step problem-solving explanations or good writing examples that include modern styles of formatting and construction
of bibliographies out of text citations and references. Students may use these solutions for personal skill-building and practice.
Unethical use is strictly forbidden.
from numpy.linalg import norm # matrix / vector norm
from numpy.linalg import inv # inverse matrix
from numpy import matmul, array, linspace # matrix multiplication
from scipy.optimize import broyden1 # broyden method
import matplotlib.pyplot as pp
# Task 1:
# converts numpy column to list
# analytical jacobian
global c1, c2
q1, q2 = tuple(col2list(qq))
-c1 + ((q1 + q2) ** (-2 - 1 / a) * (q1 - a * q1 - 2 * a * q2)) / a ** 2,
((q1 + q2) ** (-2 - 1 / a) * (q1 - a * q2)) / a ** 2],
[((q1 + q2)**(-2 - 1/a)*(-(a*q1) + q2))/a**2,
-c2 + ((q1...