Equilibrium Price

Jan 2016


In [5]:
from numpy import exp

## Parameters
a = 1
b = 0.1
epsilon = 1

def supply(price):
    return exp(b*price) - 1

def demand(price):
    return a*(price**(-epsilon))

mxiter = 30
toler = 1.0e-6

plow = 0.1
phigh = 10.0

niter = mxiter

for i in range(mxiter):

    pcur = (plow + phigh)/2
    yd = demand(pcur)
    ys = supply(pcur)
    excesssupply = ys - yd

    if excesssupply > 0:
        phigh = pcur
    else:
        plow = pcur

    diff = abs(phigh - plow)

    if diff <= toler:
        niter = i
        break

pclear = (plow + phigh)/2
yd = demand(pcur)
ys = supply(pcur)
excesssupply = ys - yd

outputs = (niter, pclear, yd, ys, excesssupply)
for output in outputs:
    print(output)


23
2.9334108501672738
0.3409001165053871
0.340900033803
-8.27026802597e-08

In [ ]: