load(draw)$ 
set_draw_defaults( draw_realpart=false,font_size=10)$
fpprintprec:5$ ratprint:false$  kill(all)$

# Nonlinear Pricing: 
    Capturing Consumer Surplus

The workbook deals with "nonlinear pricing" -- pricing when the firm
can either charge different prices for different units of a good or 
can charge a fee in addition to the per-unit price.

## Review and Introduction

## First-degree Price Discrimination

## Price Discrimination in Segmented Markets

Pricing discrimination in segmented markets can increase profits
only when the demand elasticity differs across markets. This 
illustration uses constant-elasticity demand curves with 
elasticity valuess of -1.5 and -2.5.

kill(all)$   pa:(xa/A)^(1/a)$  pb:(xb/B)^(1/b)$  
[A1,a1,B1,b1,C1,c1,d1]:[2000,-1.5,3000,-2.5,100,5,0.4]$  
params1 :[A = A1,a=a1,B=B1,b=b1,C=C1,c=c1,d=d1]$

A, a, B, and b define the demand curves. C, c, and d define the total cost 
curve. In the first case, TC = C + c*(xa = xb), so mc = c, a constant.  In the 
second case, Total cost = C + (d/2)*(xa + xb)^2, marginal cost increases with
xa + xb.

### Constant Marginal Cost

The case of constant-elasticities demand and constant mc is 
especially easy to analyze: A markup in each market is dicated
by the relationship p = mc/(E/(1+E)), where E is the demand
elasticity in any market and mc is a constant. 

In the next cell mc = c = 5. Therefore, the price is higher in the market that is 
characterized by relatively price-inelastic demand.

The CCD entry in the expressions' names denotes constant-cost discrimination.

[paCCD1, pbCCD1] : [c1/(1 + 1/a1), c1/(1 + 1/b1)]$
paCCD: subst(params1,pa)$  float(solve(%-paCCD1, xa))$
xaCCD1 : rhs(%[1])$  
pbCCD: subst(params1,pb)$  float(solve(%-pbCCD1, xb))$
xbCCD1 : rhs(%[1])$  XCCD1:xaCCD1+xbCCD1$
matrix(["paCCD1", "xaCCD1", "pbCCD1", "xbCCD1", "XCCD1"], 
          [paCCD1, xaCCD1, pbCCD1, xbCCD1, XCCD1]);

### Variable-cost Price Discrimination

When the marginal cost depends on the total quantity sold in the two markets, 
the firm allocates output between the two markets in quantities that yield equal
marginal revenue in the markets and determine the total quantity at which this 
joint marginal revenue equals marginal cost.

The next cell defines the firm's profit function PICD and the two relevant 
derivatives. mnewton( ) yields the requisite xa and xb values. These values 
generate pa, pb, and P.

ICD in the names below indicates increasing-cost discrimination.

/*Define the profit function */
PICD: subst(params1,pa*xa + pb*xb - (C + d*(xa + xb)^2/2));
diffPICDa : diff(PICD, xa)$   diffPICDb : diff(PICD, xb)$
[diffPICDa1,diffPICDb1]:subst(params1,
   [diffPICDa,diffPICDb])$
/*Find the profit-maximizing quantities */
load(mnewton)$
mnewton([diffPICDa1,diffPICDb1], [xa, xb], [5, 5])$
[xaICD1, xbICD1] : [rhs(%[1][1]), rhs(%[1][2])]$

/*Calculate the profit-maximizing prices and the profit level*/
[paICD1, pbICD1] : [pa,pb],params1,xa=xaICD1,xb=xbICD1$
PICD1: PICD, params1, xa=xaICD1, xb=xbICD1$

/*Report results */
matrix(["paICD1","xaICD1","pbICD1","xbICD1",
"Total output","PICD1"], [paICD1, xaICD1, pbICD1, xbICD1, 
  xaICD1+xbICD1, PICD1]);

The output below shows the expression for the marginal cost curve. X = xa + xb. It
confirms that marginal revenue is equal across the two markets and that this common
value equals marginal cost.

TC: C + (d/2)*X^2$
MC: diff(TC,X)$ print("MC = ",MC)$
matrix(["MC","MRa","MRb"], subst(cons(X=xaICD1+xbICD1,
  params1),  [MC, paICD1*(1+1/a), pbICD1*(1+1/b)]) );

The figure below shows these results graphically. The thin
dotted lines show the prices and quantities. 

[pa1,pb1];

/* These are expressions, not values. They are graphed */
[pa1, pb1] : subst(params1,[pa, pb])$ 

/* This is a value */
xmax : 1.1*(xaICD1+xbICD1)$

/* Draw the graph */
wxdraw2d( yrange = [0, 1.25*max(paICD1,  pbICD1)],
 xlabel="xa, xb, X = xa + xb", ylabel="$ per unit",
 user_preamble="set key center right",
 xtics={xaICD1,xbICD1,xaICD1+xbICD1},
 ytics={paICD1*(1+1/a1),paICD1,pbICD1},
 line_type = dots, points_joined = true,
 points([ [xaICD1, 0], [xaICD1,paICD1], [0, paICD1]]),
 points([[xbICD1,0],[xbICD1,pbICD1],[0, pbICD1]]), 
 points([[0,paICD1*(1+1/a1)], 
  [xaICD1+xbICD1,d1*(xaICD1+xbICD1)],[xaICD1+xbICD1,0]]), 
 line_type=solid,line_width = 2, key = "Demand, A",
 explicit(pa1, xa, 1, xmax), 
 color = yellow,key ="Marginal Revenue, A",
explicit(pa1*(1 + 1/a1), xa, 1, xmax),
key = "Demand, B", color=red,
explicit(pb1, xb, 1, xmax), color=orange,
key = "Marginal Revenue, B",
explicit(pb1*(1 + 1/b1), xb, 1, xmax),
color = black, key = "MC",
explicit(d1*x, x, 1, xmax),
dimensions = [540,480]   )$

### Price and Quantity without Discrimination

If the firm cannot discriminate, then the two demand curves are summed 
horizontally to form a single demand curve. The firm selects an X at which 
the resulting marginal revenue equals marginal cost. 

The next cell imposes pa = pb and solves for xb in terms of xa. The 
positive solution is applied below.

assume(xa>0)$ soln:float(solve(pa1=pb1,xb));

The first expression below, PICN, adds the result above to the list named
params1 using the cons( ) commmand. PICN is the first output item.
The derivative of this profit function with respect to xa is named 
diffPICN1, which is the second output item. 

The ICN indicates increasing-cost nondiscriminatory in the names below.

PICN:subst(cons(soln[1],params1),pa*xa+pb*xb-(C+(d/2)*(xa+xb)^2));   
diffPICN1 : diff(PICN, xa);

/* Find the critical value of xa */
xaICN1: find_root(diffPICN1,xa,0.1,100)$   

/* Use the critical value of xa to determine xb and xa + xb. */
xbICN1: float(subst(xa=xaICN1,rhs(soln[1])))$ 
xICN1:xaICN1+xbICN1$

/* Use the values above to determine prices and profit */    
[paICN1,pbICN1]: subst( [xa=xaICN1, xb=xbICN1],[pa1,pb1])$
PICN1 : float(subst([xa=xaICN1, xb=xbICN1] ,PICN))$

/*Print a table of these values */
matrix(["paICN1","xaICN1","pbICN1","xbICN1","xICN1",
"PICN1"],[paICN1, xaICN1, pbICN1, xbICN1, xICN1, PICN1]);

The next cell calculates and reports the comparison of discrimation
vs. single-price sales on Consumer Surplus in each of the two markets 
and on total surpluses, including profits. 

In this case, discrimination reduces total surplus and redistributes
among consumers with nondiscrimination increasing consumer surplus 
in market A and decreasing it in market B.

CSaICD1 : float(integrate(pa1-paICD1, xa, 0, xaICD1))$
CSaICN1 : float(integrate(pa1-paICN1, xa, 0, xaICN1))$
CSbICD1 : float(integrate(pb1-pbICD1, xb, 0, xbICD1))$
CSbICN1 : float(integrate(pb1-pbICN1, xb, 0, xbICN1))$
CSICD1 : CSaICD1 + CSbICD1$  CSICN1:CSaICN1+CSbICN1$
SICD1 : CSICD1+PICD1$  SICN1:CSICN1 + PICN1$    matrix(
["CSaICD", "CSaICN", "CSbICD", "CSbICN", "SICD", "SICN"],
[CSaICD1, CSaICN1, CSbICD1, CSbICN1, SICD1, SICN1]);