# Exports and Imports

An important application of general equilibrium models to to analyzing the
implications of international trade. This exercise set does not involve
general equilibrium, but it does focus on the issue of gains from exchange,
which the general equilibrium models also address.

To simplify the analysis, the demand and supply curves are linear (shape
does not affect the qualitative results) and they do not shift. 

The exercises are built on the inverse demand and supply curves in the 
home country, pdh( ) and psh( ) respectively. 

kill(all)$ ratprint:false$ fpprintprec:7$
pdh(x,a):= a - 2.5*x;
psh(x,b):= b + 1.5*x;

Apply solve( ) to determine an expression for the equilibrium quantity
in the home country, xh(a,b) and the equilibrium home price ph(a, b).

/*Input. Execute (ctrl-enter) for results */
solve(pdh(x,a)=psh(x,b),x);
xh(a,b):= ''(rhs(%[1]));
/* The demand curve yields an expression for the home price */
radcan(pdh(xh(a,b),a));
/* So does the supply curve. We use this one to create ph(a,b).*/ 
ph(a,b) := ''(radcan(psh(xh(a,b),b)));

Graph the demand and supply curve and indicate the price and quantity that 
tend to occur under conditions of autarky (no trade)

/*Input. Execute (ctrl-enter) for results */
[a0,b0]:[500,100]$    wxdraw2d(
 xlabel="x, units per period",ylabel="$ per unit",
 line_width=2,
 key="Home Demand",explicit(pdh(x,a0),x,0,a0/2.5),
 color=black,key="Home Supply",
 explicit(psh(x,b0),x,0,a0/2.5),line_type=dots,
 points_joined=true , line_width=1,
points([ [0,ph(a0,b0)],[xh(a0,b0),ph(a0,b0)],[xh(a0,b0),0] ]) )$

Apply integrate to determine Consumer Surplus and Producer Surplus,
assuming that the supply curve is the marginal cost curve and that 
no fixed costs occur. (Fixed costs would not affect any of the 
following analysis except for reducing the values of Producer Surplus.)

/*Input. Execute (ctrl-enter) for results */
integrate(pdh(x,a0)-ph(a0,b0),x,0,xh(a0,b0) );
integrate(ph(a0,b0)-psh(x,b0),x,0,xh(a0,b0) );
integrate(pdh(x,a0)-psh(x,b0),x,0, xh(a0,b0));

The parameters a and b are the price-axis intercepts. The exercises
below identify the effect of world prices between b and a. Create an
expression that states pw(a, b, k), where k is a constant between 0
and 1, such that pw(a,b,k):= k*(a-b) + b. 

If k = 1, then pw >= a, no domestic consumption occurs. If k <= 0, no
domestic production occurs.

Confirm that k = 3/8 generate a price of 250, the same as the autarkic
price.

/*Input. Execute (ctrl-enter) for results */
pw(a,b,k):= k*(a-b) + b;
float(solve(pw(a0,b0,k)=ph(a0,b0),k));
pw(a0,b0,3/8);

Select any k > 0.375. Let the resulting price be the world price, and label it pw1.

/*Input. Execute (ctrl-enter) for results */
pw1: pw(a0,b0,0.6);

Determine the quantity demanded at this price and the quantity supplied. How many
units of this product do home producers export?

/*Input. Execute (ctrl-enter) for results */
[solve(pw1-pdh(x,a0),x),solve(pw1=psh(x,b0),x)];
exports=rhs(%[2][1]) - rhs(%[1][1]);

Determine the consumer surplus, the producer surplus, and the total surplus
given this price.

/*Input. Execute (ctrl-enter) for results */
cs2: integrate(pdh(x,a0)-pw1,x,0,64);
ps2: integrate(pw1-psh(x,b0),x,0,160);
cs2+ps2;

Repeat the previous three cells with k < 0.375.

/*Input. Execute (ctrl-enter) for results */
pw2: pw(a0,b0,0.25);

Determine the quantity demanded at this price and the quantity supplied. How many
units of this product do home producers export?

/*Input. Execute (ctrl-enter) for results */
[solve(pw2-pdh(x,a0),x),solve(pw2=psh(x,b0),x)];
imports=rhs(%[1][1]) - rhs(%[2][1]);

Determine the consumer surplus, the producer surplus, and the total surplus
given this price.

/*Input. Execute (ctrl-enter) for results */
cs3: integrate(pdh(x,a0)-pw2,x,0,120);
ps3: float(integrate(pw2 - psh(x,b0),x,0,200/3));
cs3+ps3;

What general conclusions about gains and losses from international trade do the
results to this point suggest?

/*Input. Execute (ctrl-enter) for results */
[solve(pdh(x,a0)-price,x), solve(psh(x,b0)=price,x)];
[integrate(pdh(x,a0) - p0,x,0,xd ),
integrate(psh(x,b0) - p0,x,0,xs )];

Create list of values for k as follows: makelist(i/8.0,i,0,8).
Name it kList. Then create list of world prices by inserting kList
into pw(a,b,k). Name it pwList.

Then create lists of quantities demanded (xdList) and supplied (xsList),
Consumer Surplus (csList), Producer Surplus (psList), and total surplus
(tsList). 

Confirm that at all values of pw except 250, ts is greater than when
pw = 250, but that one of the compones of ts falls. Also, note that at
either of the extreme values of pw, either cs = 0 or ps = 0.

/*Input. Execute (ctrl-enter) for results */
kList: makelist(i/8.0,i,0,8)$  
pwList: pw(a0,b0,kList)$
xdList: 200-(2/5)*pwList$
xsList: (-200+2*pwList)/3$
csList: -(5*xdList^2 + (4*pwList-2000)*xdList)/4.0$
psList: -(3*xsList^2 + (400-4*pwList)*xsList)/4.0$
tsList: csList+psList$
matrix(pwList,xdList,xsList,csList,psList,tsList)$
addrow(matrix(["pw","xdhome","xshome","cs","ps","ts"]),%);

Graph the values of the surpluses against the values of pw.

/*Input. Execute (ctrl-enter) for results */
wxdraw2d(user_preamble="set key left",
 xtics={["Lower",150],["Autarkic Price",250],["Higher",400]},
 xlabel="World price, $/unit",
 ylabel="Surpluses, $", line_type=dots, points_joined=true,
 points([ [250,0],[250,20000] ]),
 line_type=solid,line_width=2,
 key = "Consumer Surplus",
 points(pwList,csList), color=black,
 key = "Producer Surplus",points(pwList,psList),
 color=red, key = "Total Surplus", points(pwList,tsList)
 )$

Refer to the table (or lists, depending on your output) above to anwer
the following questions. Assume that pw = 150 and a tariff of 50 is 
imposed on imports, so that the home price is 200.
1. How much is imported given the tariff?
2. How much tariff revenue does the government receive?
3. How much does consumer surplus (cs) decrease?
4. How much does producer surplus (ps) increase?
5. How much deadweight loss is incurred?

/*Input. Execute (ctrl-enter) for results */
imports: xdList[3] - xsList[3]$
revenue: imports*50$
chg_cs: 18000 - 24500$
chg_ps: 3333.333-833.333$
dwl : (chg_ps + revenue) + chg_cs$
matrix(["imports","revenue","cs change","ps change","Deadweight Loss"],
 ["(units/period)","($/period)","($/period)","($/period)","($/period)"],
[imports,revenue,chg_cs,chg_ps,dwl]);

Refer to the graph below. Refer to the components of the trapezoid
between pw = 150 and p = 200 as a, b, c, and d.

Explain the following:
1. The sum of the four areas is the reduction in consumer surplus.
2. Area a is the gain in producer surplus.
3. Area b is deadweight loss due to excessive (define excessive)
    home production.
4. Area c is tariff revenue.
5. Area d is deadweight loss due to an inefficiently low import level.

Confirm that the areas defined in this cell sum to the values 
generated above.

/*Input. Execute (ctrl-enter) for results */
[a0,b0]:[500,100]$    wxdraw2d(
xlabel="x, units per period",ylabel="$ per unit",
line_width=2,
key="Home Demand",explicit(pdh(x,a0),x,0,a0/2.5),
color=black,key="Home Supply",
explicit(psh(x,b0),x,0,a0/2.5),line_type=dots,
points_joined=true ,key="", line_width=1,
points([ [0,150],[xdList[2],150],[xdList[2],0 ] ]),
points([ [0,200],[xdList[3],200],[xdList[3],0 ] ]),
points([ [xsList[3],0],[xsList[3],200] ]))$