CoCalc
Shareddirected_search_2.ipynbOpen in CoCalc
Views : 1

This worksheet will illustrate all the calculations in the directed search reading for the case where there is complete information.  The first is the basic equation

$\pi w_1 /2+(1-\pi)w_1=\pi w_2+(1-\pi)w_2 /2$

The solution to this equation makes both workers indfferent about whether they apply to firm 1 or firm 2.

var('pi,w_1,w_2')
eq1 = pi*w_1/2+(1-pi)*w_1 == pi*w_2+(1-pi)*w_2/2
prob = solve(eq1,pi)
show(prob)

$\left[\pi = \frac{2 \, w_{1} - w_{2}}{w_{1} + w_{2}}\right]$

If your formula is right, then the solution should be $1/2$ when the wages are the same.

show(solve(eq1.substitute(w_1=w_2),pi))

$\left[\pi = \left(\frac{1}{2}\right)\right]$

We now need access to the first solution to $\pi$.  To find it, you treat the solution as if it were an array because most equations have more than one solution.  In this case, there is only one solution, so we use element $0$.  You can substitute this into other equations.

We'll do this by definining the profit function of firm 1.  This profit is given by

$(1-(1-\pi)^2)(y_1-w_1)$

as we discussed in class.

We can also take the derivative of this profit function to try to find the best reply function.

var('y_1,y_2')
Profit = ((1-(1-prob[0])^2))*(y_1-w_1)
show(Profit)
der = Profit.derivative(w_1)
show(der)

${\left({\left(\pi - 1\right)}^{2} - 1\right)} {\left(w_{1} - y_{1}\right)} = {\left({\left(\frac{2 \, w_{1} - w_{2}}{w_{1} + w_{2}} - 1\right)}^{2} - 1\right)} {\left(w_{1} - y_{1}\right)}$
${\left(\pi - 1\right)}^{2} - 1 = -2 \, {\left(w_{1} - y_{1}\right)} {\left(\frac{2 \, w_{1} - w_{2}}{w_{1} + w_{2}} - 1\right)} {\left(\frac{2 \, w_{1} - w_{2}}{{\left(w_{1} + w_{2}\right)}^{2}} - \frac{2}{w_{1} + w_{2}}\right)} + {\left(\frac{2 \, w_{1} - w_{2}}{w_{1} + w_{2}} - 1\right)}^{2} - 1$

Now use the right hand side of the derivative and set it to zero, then solve for $w_1$.

eq2 = der.rhs() == 0
show(eq2)
br = solve(eq2,w_1)
show(br)
show(br[0])

$-2 \, {\left(w_{1} - y_{1}\right)} {\left(\frac{2 \, w_{1} - w_{2}}{w_{1} + w_{2}} - 1\right)} {\left(\frac{2 \, w_{1} - w_{2}}{{\left(w_{1} + w_{2}\right)}^{2}} - \frac{2}{w_{1} + w_{2}}\right)} + {\left(\frac{2 \, w_{1} - w_{2}}{w_{1} + w_{2}} - 1\right)}^{2} - 1 = 0$
$\left[w_{1} = \frac{w_{2}^{2} + 4 \, w_{2} y_{1}}{5 \, w_{2} + 2 \, y_{1}}\right]$
$w_{1} = \frac{w_{2}^{2} + 4 \, w_{2} y_{1}}{5 \, w_{2} + 2 \, y_{1}}$

Now we can do a very similar thing for firm $2$.

Prof_2 = ((1-(prob[0])^2))*(y_2-w_2)
show(Prof_2)
der_2 = Prof_2.derivative(w_2)
show(der_2)

${\left(\pi^{2} - 1\right)} {\left(w_{2} - y_{2}\right)} = {\left(w_{2} - y_{2}\right)} {\left(\frac{{\left(2 \, w_{1} - w_{2}\right)}^{2}}{{\left(w_{1} + w_{2}\right)}^{2}} - 1\right)}$
$\pi^{2} - 1 = -2 \, {\left(w_{2} - y_{2}\right)} {\left(\frac{{\left(2 \, w_{1} - w_{2}\right)}^{2}}{{\left(w_{1} + w_{2}\right)}^{3}} + \frac{2 \, w_{1} - w_{2}}{{\left(w_{1} + w_{2}\right)}^{2}}\right)} + \frac{{\left(2 \, w_{1} - w_{2}\right)}^{2}}{{\left(w_{1} + w_{2}\right)}^{2}} - 1$

Again, we can find the best reply function for firm 2 by finding the value for $w_2$ for each value of $w_1$ that makes the derivative zero.

eq3 = der_2.rhs() == 0
show(eq3)
br_2 = solve(eq3,w_1)
show(br_2)
show(br_2[1])

$-2 \, {\left(w_{2} - y_{2}\right)} {\left(\frac{{\left(2 \, w_{1} - w_{2}\right)}^{2}}{{\left(w_{1} + w_{2}\right)}^{3}} + \frac{2 \, w_{1} - w_{2}}{{\left(w_{1} + w_{2}\right)}^{2}}\right)} + \frac{{\left(2 \, w_{1} - w_{2}\right)}^{2}}{{\left(w_{1} + w_{2}\right)}^{2}} - 1 = 0$
$\left[w_{1} = \frac{5}{2} \, w_{2} - 2 \, y_{2} - \frac{1}{2} \, \sqrt{25 \, w_{2}^{2} - 32 \, w_{2} y_{2} + 16 \, y_{2}^{2}}, w_{1} = \frac{5}{2} \, w_{2} - 2 \, y_{2} + \frac{1}{2} \, \sqrt{25 \, w_{2}^{2} - 32 \, w_{2} y_{2} + 16 \, y_{2}^{2}}, w_{1} = 0\right]$
$w_{1} = \frac{5}{2} \, w_{2} - 2 \, y_{2} + \frac{1}{2} \, \sqrt{25 \, w_{2}^{2} - 32 \, w_{2} y_{2} + 16 \, y_{2}^{2}}$

Notice that when I 'solved' the first order condition, instead of solving for $w_2$, which would tell us firm 2's best reply to each $w_1$, I solved for $w_1$. What that gives is the inverse of firm 2's best reply function (for each $w_2$, it gives the value for $w_1$ such that $w_2$ is a best reply.) This ensures that it provides the curve as the inverse image as we did for the picture we drew in class.

In the next step we'll just plot the two best reply functions to look for their intersection. To do this, I substitute the value $y_1 =1$ and $w_2 = \frac{3}{4}$, so that firm 2 is less productive. The equilibrium should then have the property that the equilibrium wage for firm 2 is less than it is for firm 1. To help show this, I also draw the $45^o$ line ($w_1 = w_2$). As you can see, the point where the lines cross has $w_1 > w_2$.

Notice that there were two solutions for the best reply function, and that I used the second one. Make sure you check what happens when you use the first solution instead.

plot(br[0].rhs().substitute(y_1=1),(w_2,0,1),color="red")+plot(br_2[1].rhs().substitute(y_2=3/4),(w_2,0,1),color="green")+plot(w_2,(w_2,0,1),color="black",linestyle='dashed')

WARNING: Some output was deleted.

As a last step, find the equilibrium by finding the wage that is a best reply to itself.  What that means is that both firms will be best replying to the other firm if they both use this wage.

The inverse function has a square root in it, which will make finding an algebraic solution difficult (if you try it, you'll get an implicit solution). So instead, we'll calculate the intersection point using numerical methods. Just to make sure, we can solve the numerical equation again for the case where $y_1 = y_2 = 1$ in which case we already know from previous calculations that $w_1$ and $w_2$ should both be equal to $\frac{1}{2}$. That will give a simple check that our coding is correct.

show(br[0].rhs().substitute(y_1=1))
show(br_2[1].rhs().substitute(y_2=(3/4)))
eq4 = br[0].rhs().substitute(y_1=1) == br_2[1].rhs().substitute(y_2=(3/4))
show(eq4.find_root(.2,1))
eq5 = br[0].rhs().substitute(y_1=1) == br_2[1].rhs().substitute(y_2=1)
show(eq5.find_root(.2,1))

$\frac{w_{2}^{2} + 4 \, w_{2}}{5 \, w_{2} + 2}$
$\frac{5}{2} \, w_{2} + \frac{1}{2} \, \sqrt{25 \, w_{2}^{2} - 24 \, w_{2} + 9} - \frac{3}{2}$
$0.41328575986610366$
$0.4999999999999976$

Notice that the root of the second equation is pretty close to .5.