Problem set 6: Solving the Solow model

[1]
import numpy as np
from scipy import linalg
from scipy import optimize
import sympy as sm

Tasks

Solving matrix equations I

[2]
np.random.seed(1900)
n = 5
A = np.random.uniform(size=(n,n))
b = np.random.uniform(size=n)
c = np.random.uniform(size=n)
d = np.random.uniform(size=n)

Question A: Find the determinant of [AA]1[A \cdot A]^{-1}

[3]
# write your code here

Answer: see A1.py

Question B: Solve the following equation systems directly using scipy.

Ax=bAx=cAx=d\begin{aligned} Ax &= b \\ Ax &= c \\ Ax &= d \end{aligned}

Answer: A2.py

Question C: Solve the same equation systems as above using linalg.lu_factor() and linalg.lu_solve(). What is the benefit of this approach?

Answer: A3.py

Solving matrix equations II

[7]
F = np.array([[2.0, 1.0, -1.0], [-3.0, -1.0, 2], [-2.0, 1.0, 2.0]])
e = np.array([8.0, -11.0, -3.0])

Question: Use the function gauss_jordan() in the numecon_linalg module located in this folder to solve

Fx=eFx = e
[8]
# write your code here

Answer: see A4.py

Symbolic

Question A: Find

limx0sin(x)x\lim_{x \rightarrow 0} \frac{\sin(x)}{x}

and

sin(2x)x\frac{\partial\sin(2x)}{\partial x}
[10]
# write your code here

Answer: A5.py

Question B: Solve the equation

sin(x)x=0\frac{\sin(x)}{x} = 0
[13]
# write your code here

Answer: A6.py

Problem: Solve the Solow model

Introduction

Consider the standard Solow-model where:

  1. KtK_t is capital2
  2. LtL_t is labor (growing with a constant rate of nn)
  3. AtA_t is technology (growing with a constant rate of gg)
  4. Yt=F(Kt,AtLt)Y_t = F(K_t,A_tL_t) is GDP

Saving is a constant fraction of GDP

St=sYt,s(0,1)S_t = sY_t,\,s\in(0,1)

such that capital accumulates according to

Kt+1=St+(1δ)Kt=sF(Kt,AtLt)+(1δ)Kt,δ(0,1)K_{t+1}=S_{t}+(1-\delta)K_{t}=sF(K_{t},A_{t}L_{t})+(1-\delta)K_{t}, \delta \in (0,1)

The production function has constant-return to scale such that

YtAtLt=F(Kt,AtLt)AtLt=F(k~t,1)f(k~t)\frac{Y_{t}}{A_{t}L_{t}}=\frac{F(K_{t},A_{t}L_{t})}{A_{t}L_{t}}=F(\tilde{k}_{t},1)\equiv f(\tilde{k}_{t})

where k~t=KtAtLt\tilde{k}_t = \frac{K_t}{A_{t}L_{t}} is the technology adjusted capital-labor ratio.

The transition equation then becomes

k~t+1=1(1+n)(1+g)[sf(k~t)+(1δ)k~t]\tilde{k}_{t+1}= \frac{1}{(1+n)(1+g)}[sf(\tilde{k}_{t})+(1-\delta)\tilde{k}_{t}]

If the production function is Cobb-Douglas then

F(Kt,AtLt)=Ktα(AtLt)1αf(k~t)=k~tαF(K_{t},A_{t}L_{t})=K_{t}^{\alpha}(A_{t}L_{t})^{1-\alpha}\Rightarrow f(\tilde{k}_{t})=\tilde{k}_{t}^{\alpha}

If it is CES (with β<1,β0\beta < 1, \beta \neq 0) then

F(Kt,AtLt)=(αKtβ+(1α)(AtLt)β)1βf(k~t)=(αk~tβ+(1α))1βF(K_{t},A_{t}L_{t})=(\alpha K_{t}^{\beta}+(1-\alpha)(A_{t}L_{t})^{\beta})^{\frac{1}{\beta}}\Rightarrow f(\tilde{k}_{t})=(\alpha\tilde{k}_{t}^{\beta}+(1-\alpha))^{\frac{1}{\beta}}

Steady state

Assume the production function is Cobb-Douglas.

Question A: Use sympy to find an analytical expression for the steady state, i.e. solve

k~=1(1+n)(1+g)[sf(k~)+(1δ)k~]\tilde{k}^{\ast}= \frac{1}{(1+n)(1+g)}[sf(\tilde{k}^{\ast})+(1-\delta)\tilde{k}^{\ast}]
[15]
k = sm.symbols('k')
alpha = sm.symbols('alpha')
delta = sm.symbols('delta')
s = sm.symbols('s')
g = sm.symbols('g')
n = sm.symbols('n')
[16]
# write your code here

Answer: see A7.py

Question B: Turn you solution into a Python function called as ss_func(s,g,n,delta,alpha).

[18]
# write your code here

Answer: A8.py

Question C: Find the steady state numerically using root-finding with optimize.root_scalar.

[21]
s = 0.2
g = 0.02
n = 0.01
alpha = 1/3
delta = 0.1

# write your code here

Answer: A9.py

Question D: Now assume the production function is CES. Find the steady state for kk for the various values of β\beta shown below.

[23]
betas = [-0.5,-0.25,-0.1,-0.05,0.05,0.1,0.25,0.5]

# write your code here

Answer: A10.py