chapter 1 supply and demand - amazon web...

38
Chapter 1 Supply and demand O. Afonso, P. B. Vasconcelos Computational Economics: a concise introduction O. Afonso, P. B. Vasconcelos Computational Economics 1 / 38

Upload: phungnhi

Post on 02-May-2018

220 views

Category:

Documents


4 download

TRANSCRIPT

Page 1: Chapter 1 Supply and demand - Amazon Web Servicess3-euw1-ap-pe-ws4-cws-documents.ri-prod.s3.amazonaws.com/... · Introduction The supply–demand model is used to understand the determination

Chapter 1Supply and demand

O. Afonso, P. B. Vasconcelos

Computational Economics: a concise introduction

O. Afonso, P. B. Vasconcelos Computational Economics 1 / 38

Page 2: Chapter 1 Supply and demand - Amazon Web Servicess3-euw1-ap-pe-ws4-cws-documents.ri-prod.s3.amazonaws.com/... · Introduction The supply–demand model is used to understand the determination

Overview

1 Introduction

2 Economic model (in autarky)

3 First computer program

4 Economic model with international-trade policy

5 Numerical solution

6 Computational implementation

7 Numerical results and simulation

8 Highlights

9 Main references

O. Afonso, P. B. Vasconcelos Computational Economics 2 / 38

Page 3: Chapter 1 Supply and demand - Amazon Web Servicess3-euw1-ap-pe-ws4-cws-documents.ri-prod.s3.amazonaws.com/... · Introduction The supply–demand model is used to understand the determination

Introduction

The supply–demand model is used to understand the determination of theprice and of the quantity of a good sold on the market.

In a context with a high degree of competition, buyers (sellers) bid againsteach other and thereby raise (lower) the price.The equilibrium is a point at which all the bidding has been done andnobody has an incentive to offer higher (or accept lower) prices.The closed–economy scenario is extended to an open one toaccommodate international trade policy. Market effects as well as socialwelfare are analysed.

MATLAB/Octave is used to solve the model in the different cases.

O. Afonso, P. B. Vasconcelos Computational Economics 3 / 38

Page 4: Chapter 1 Supply and demand - Amazon Web Servicess3-euw1-ap-pe-ws4-cws-documents.ri-prod.s3.amazonaws.com/... · Introduction The supply–demand model is used to understand the determination

Economic model (in autarky)

The model is composed of endogenous and exogenous variables,parameters and functional forms.The solution provides the market equilibrium price and quantity.It is straightforward to evaluate the impacts of changes in exogenousfactors that affect demand or supply and to measure those impacts onsocial welfare.The equations that characterise the model are:

demand, Qd = Qd − aP;supply, Qs = Qs + bP.

O. Afonso, P. B. Vasconcelos Computational Economics 4 / 38

Page 5: Chapter 1 Supply and demand - Amazon Web Servicess3-euw1-ap-pe-ws4-cws-documents.ri-prod.s3.amazonaws.com/... · Introduction The supply–demand model is used to understand the determination

Economic model (in autarky)

Endogenous variables:quantity demanded, Qd ;quantity offered, Qs;price of the good, P.

Exogenous variables:independent/autonomous quantity demanded, Qd ;independent/autonomous quantity offered, Qs.

Parameters:a > 0 is the sensitivity of the demand to price;b > 0 is the sensitivity of the supply to price.

O. Afonso, P. B. Vasconcelos Computational Economics 5 / 38

Page 6: Chapter 1 Supply and demand - Amazon Web Servicess3-euw1-ap-pe-ws4-cws-documents.ri-prod.s3.amazonaws.com/... · Introduction The supply–demand model is used to understand the determination

Economic model (in autarky)

Demand

Qd is the total amount of a good that buyers would choose to purchase ata given price P as well as other (exogenous) variables Qd , such asincome and wealth, prices of substitutes and complements, population,preferences (tastes) and expectations of future prices

Qd = Qd − aP. (1)

The Law of Demand states that when the price rises, the quantitydemanded falls (everything else remains constant);Changes or shifts in demand occur when one of the determinants ofdemand other than price changes;Representing (P,Qd ), respectively, on the x–axis and y–axis, it can bestated that:

demand position depends on Qd ;∂Qd∂P < 0 (negative slope).

O. Afonso, P. B. Vasconcelos Computational Economics 6 / 38

Page 7: Chapter 1 Supply and demand - Amazon Web Servicess3-euw1-ap-pe-ws4-cws-documents.ri-prod.s3.amazonaws.com/... · Introduction The supply–demand model is used to understand the determination

Economic model (in autarky)

Supply

Qs is the total amount of a good that sellers would choose to produce andsell given the price P, as well as other (exogenous) variables Qs, such asprices of factors of production, prices of alternative products the firmcould produce, technology, productive capacity and expectations of futureprices

Qs = Qs + bP. (2)

The Law of Supply states that when the price rises, the quantity suppliedalso rises (everything else remains constant).Changes or shifts in supply occur when one of the determinants of supplyother than price changes.

Supply position depends on Qs;∂Qs∂P > 0 (positive slope).

O. Afonso, P. B. Vasconcelos Computational Economics 7 / 38

Page 8: Chapter 1 Supply and demand - Amazon Web Servicess3-euw1-ap-pe-ws4-cws-documents.ri-prod.s3.amazonaws.com/... · Introduction The supply–demand model is used to understand the determination

Economic model (in autarky)

Demand and supply curves

The equilibrium is reached when the supply and demand curves crossQd = Qs, determining the equilibrium price Pe and the equilibriumquantity Qe

Pe = Qd−Qsa+b

Qe = Qd − aPe = Qs + bPe.

(3)

If price is below Pe, then there is ‘excess demand’ or ‘shortage’, Qd > Qs,and the quantity that actually occurs will be Qs.If price is above Pe, then there is ‘excess supply’ or ‘surplus’, Qd < Qs,and the quantity that actually occurs will be Qd .

O. Afonso, P. B. Vasconcelos Computational Economics 8 / 38

Page 9: Chapter 1 Supply and demand - Amazon Web Servicess3-euw1-ap-pe-ws4-cws-documents.ri-prod.s3.amazonaws.com/... · Introduction The supply–demand model is used to understand the determination

Economic model (in autarky)

Demand and supply curves

Thus, four basic laws of supply and demand are stressed.If demand increases (demand curve shifts to the right) and supply remainsunchanged, a shortage occurs, leading to a higher equilibrium price.If demand decreases (demand curve shifts to the left) and supply remainsunchanged, a surplus occurs, leading to a lower equilibrium price.If demand remains unchanged and supply increases (supply curve shifts tothe right), a surplus occurs, leading to a lower equilibrium price.If demand remains unchanged and supply decreases (supply curve shifts tothe left), a shortage occurs, leading to a higher equilibrium price.

O. Afonso, P. B. Vasconcelos Computational Economics 9 / 38

Page 10: Chapter 1 Supply and demand - Amazon Web Servicess3-euw1-ap-pe-ws4-cws-documents.ri-prod.s3.amazonaws.com/... · Introduction The supply–demand model is used to understand the determination

Economic model (in autarky)

Social welfare

Consumer surplus, Cs, is the consumers’ utility gain when what they arewilling to pay for the good is higher than what they really have to pay;graphically, for a linear demand function, it is the area given by:

Cs =Qe (Pmax − Pe)

2,

where Pmax ≡ Qda is the price in which the quantity demanded is zero.

Producer surplus, Ps, is the gain that producers’ obtain when the price ofthe good that they sell in the market is higher than what they would bewilling to sell; graphically, for a linear supply function, it is the area of:

Ps =

PeQs +

(Qe−Qs)Pe2 , if Qs ≥ 0

Qe(Pe−Pmin)2 , otherwise,

where Pmin ≡ −Qsb .

The social welfare, Sw , is the sum of the consumer surplus and theproducer surplus: Sw = Cs + Ps.O. Afonso, P. B. Vasconcelos Computational Economics 10 / 38

Page 11: Chapter 1 Supply and demand - Amazon Web Servicess3-euw1-ap-pe-ws4-cws-documents.ri-prod.s3.amazonaws.com/... · Introduction The supply–demand model is used to understand the determination

First computer program

Consider Qd = 1000, Qs = 250, a = 10 and b = 5.

%% Supply−demand model% Implemented by : P .B . Vasconcelos and O. Afonsodisp ( ’−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−− ’ ) ;disp ( ’ Supply−demand model i n autarky ’ ) ;disp ( ’−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−− ’ ) ;

%% parametersa = 10; % s e n s i t i v i t y o f the demand to p r i ceb = 5; % s e n s i t i v i t y o f the supply to p r i ce

%% exogenous v a r i a b l e sQd_bar = 1000; % independent / autonomous q u a n t i t y demandedQs_bar = 250; % independent / autonomous q u a n t i t y o f f e red

O. Afonso, P. B. Vasconcelos Computational Economics 11 / 38

Page 12: Chapter 1 Supply and demand - Amazon Web Servicess3-euw1-ap-pe-ws4-cws-documents.ri-prod.s3.amazonaws.com/... · Introduction The supply–demand model is used to understand the determination

First computer program

%% endogenous v a r i a b l e s% Qd, q u a n t i t y demanded% Qs, q u a n t i t y o f f e red% P, p r i ce

%% modelf p r i n t f ( ’Qd = %g − %g∗P \ n ’ , Qd_bar , a ) % demandf p r i n t f ( ’Qs = %g + %g∗P \ n ’ , Qs_bar , b ) % supply

%% compute the endogenous va r i a b l e s% so l v i ng a n a l i t i c a l l yPe = ( Qd_bar−Qs_bar ) / ( a+b ) ; Qe = Qd_bar−a∗Pe ;disp ( ’ computed endogenous va r i a b l e s : ( e q u i l i b r i u m po in t ) ’ )f p r i n t f ( ’ quan t i t y , Q: %g \ n ’ , Qe) ;f p r i n t f ( ’ p r ice , P : %g \ n ’ , Pe) ;

%% show the curves ( i n t h i s case the l i n e s )Q = 0:2∗Qe;plot (Q, ( Qd_bar−Q) / a , ’ b ’ ,Q, (Q−Qs_bar ) / b , ’ r−− ’ ) ;t i t l e ( ’demand and supply curves ’ ) ; legend ( ’demand ’ , ’ supply ’ ) ;xlabel ( ’ quan t i t y , Q ’ ) ; ylabel ( ’ p r ice , P ’ ) ;y l im ( [ 0 , Qd_bar / a ] ) ; x l im ( [0 ,2∗Qe ] )

O. Afonso, P. B. Vasconcelos Computational Economics 12 / 38

Page 13: Chapter 1 Supply and demand - Amazon Web Servicess3-euw1-ap-pe-ws4-cws-documents.ri-prod.s3.amazonaws.com/... · Introduction The supply–demand model is used to understand the determination

First computer program

First numerical results and simulations

---------------------------------------------------------Supply-demand model in autarky---------------------------------------------------------Qd = 1000 - 10*PQs = 250 + 5*Pcomputed endogenous variables: (equilibrium point)

quantity, Q: 500price, P: 50

O. Afonso, P. B. Vasconcelos Computational Economics 13 / 38

Page 14: Chapter 1 Supply and demand - Amazon Web Servicess3-euw1-ap-pe-ws4-cws-documents.ri-prod.s3.amazonaws.com/... · Introduction The supply–demand model is used to understand the determination

First computer program

0 100 200 300 400 500 600 700 800 900 10000

10

20

30

40

50

60

70

80

90

100demand and supply curves

quantity, Q

price, P

demand

supply

Supply and demand diagram

O. Afonso, P. B. Vasconcelos Computational Economics 14 / 38

Page 15: Chapter 1 Supply and demand - Amazon Web Servicess3-euw1-ap-pe-ws4-cws-documents.ri-prod.s3.amazonaws.com/... · Introduction The supply–demand model is used to understand the determination

First computer program

To show the consumer surplus and producer surplus, consider thefollowing code.

%% Supply−demand model : surp lus and wel fa re% Implemented by : P .B . Vasconcelos and O. Afonso

hold on ; % freezes the generated f i g u r e

%% consumer surp lusPmax = Qd_bar / a ;Cs = Qe∗ (Pmax−Pe) / 2 ;% area : (0 ,Pe) , (0 ,Pmax) , (Qe, Pe)f i l l ( [ 0 , 0 ,Qe ] , [ Pe ,Pmax, Pe ] , ’ c ’ ) ;annota t ion ( ’ tex tbox ’ , [ 0 . 1 5 , 0 . 5 5 , 0 . 1 , 0 . 1 ] , . . .

’ S t r i n g ’ , ’ Consumer Surplus ’ , ’ EdgeColor ’ , ’ none ’ )f p r i n t f ( ’ Consumer surp lus , Cs : %g \ n ’ , Cs) ;

O. Afonso, P. B. Vasconcelos Computational Economics 15 / 38

Page 16: Chapter 1 Supply and demand - Amazon Web Servicess3-euw1-ap-pe-ws4-cws-documents.ri-prod.s3.amazonaws.com/... · Introduction The supply–demand model is used to understand the determination

First computer program

%% producer surp lus :Pmin = −Qs_bar / b ;i f Qs_bar>=0

Ps = Pe∗Qs_bar +(Qe−Qs_bar ) ∗Pe / 2 ;% area : (0 ,0 ) , (0 ,Pe) , (Qe, Pe) , ( Qs_bar , 0 )f i l l ( [ 0 , 0 ,Qe, Qs_bar ] , [ 0 , Pe , Pe , 0 ] , ’ y ’ )annota t ion ( ’ tex tbox ’ , [ 0 . 15 0.35 0.1 0 . 1 ] , . . .

’ S t r i n g ’ , ’ Producer Surplus ’ , ’ EdgeColor ’ , ’ none ’ )else

Ps = Qe∗ (Pe−Pmin ) / 2 ;% area : (0 ,Pmim) , (0 ,Pe) , (Qe, Pe)f i l l ( [ 0 , 0 ,Qe ] , [ Pmin , Pe , Pe ] , ’ y ’ )annota t ion ( ’ tex tbox ’ , [ 0 . 15 0.35 0.1 0 . 1 ] , . . .

’ S t r i n g ’ , ’ Producer Surplus ’ , ’ EdgeColor ’ , ’ none ’ )endf p r i n t f ( ’ Producer surp lus , Ps : %g \ n ’ , Ps ) ;

The output is as follows.Consumer surplus, Cs: 12500Producer surplus, Ps: 18750

O. Afonso, P. B. Vasconcelos Computational Economics 16 / 38

Page 17: Chapter 1 Supply and demand - Amazon Web Servicess3-euw1-ap-pe-ws4-cws-documents.ri-prod.s3.amazonaws.com/... · Introduction The supply–demand model is used to understand the determination

First computer program

0 100 200 300 400 500 600 700 800 900 10000

10

20

30

40

50

60

70

80

90

100demand and supply curves

quantity, Q

price, P

demand

supply

Consumer Surplus

Producer Surplus

Consumer Surplus

Producer Surplus

Consumer and producer surplus

O. Afonso, P. B. Vasconcelos Computational Economics 17 / 38

Page 18: Chapter 1 Supply and demand - Amazon Web Servicess3-euw1-ap-pe-ws4-cws-documents.ri-prod.s3.amazonaws.com/... · Introduction The supply–demand model is used to understand the determination

Economic model with international-trade policy

Two big countries, Home (H) and Foreign (F ), which produce and consumethe final good, are considered.For simplification, the good can be costlessly transported, the exchange ratebetween currencies is fixed and production occurs under perfect competition.

Home demand, Qd,H = Qd,H − aHPH ;

Home supply, Qs,H = Qs,H + bHPH ;

Foreign demand, Qd,F = Qd,F − aF PF ;

Foreign supply, Qs,F = Qs,F + bF PF .Trade between countries emerges if, without trade (autarky), prices aredifferent in both countries.Let us assume that the price is higher in H, which under free trade impliesthat producers in F begin to export it to H.

O. Afonso, P. B. Vasconcelos Computational Economics 18 / 38

Page 19: Chapter 1 Supply and demand - Amazon Web Servicess3-euw1-ap-pe-ws4-cws-documents.ri-prod.s3.amazonaws.com/... · Introduction The supply–demand model is used to understand the determination

Economic model with international-trade policy

The exports raises the price in F and lowers its price in H until theelimination of the difference. When prices become equal, there is noadditional advantage to trade more quantity, and the prices and quantitiestraded stabilise.To find the world price, Pw and the quantity traded, Qw , two new curvesare defined:

Home import demand curve, MH = Qd,H − Qs,H , which represents theexcess of what H consumes over what H produces; andForeign export supply curve, EF = Qs,F − Qd,F , which is the excess of whatF produces over what F consumes.

O. Afonso, P. B. Vasconcelos Computational Economics 19 / 38

Page 20: Chapter 1 Supply and demand - Amazon Web Servicess3-euw1-ap-pe-ws4-cws-documents.ri-prod.s3.amazonaws.com/... · Introduction The supply–demand model is used to understand the determination

Economic model with international-trade policy

MH intercepts the price axis at Pe in H in which import demand equalszero; from then on, MH is downward sloping because as price increases,the quantity of imports demanded declines.EF also intercepts the price axis at Pe in F in which export supply equalszero; from then on, EF is upward sloping.Hence, the world equilibrium occurs when MH equals EF , which occurs atprice Pw .This framework can also be used to determine the effects on markets andagents’ welfare due to the imposition of some instrument of trade policy;e.g., a tariff on imports or an export subsidy.

O. Afonso, P. B. Vasconcelos Computational Economics 20 / 38

Page 21: Chapter 1 Supply and demand - Amazon Web Servicess3-euw1-ap-pe-ws4-cws-documents.ri-prod.s3.amazonaws.com/... · Introduction The supply–demand model is used to understand the determination

Economic model with international-trade policy

Effects of a tariff on imports

A tariff is a tax on imports and can be either specific (a fixed sum per unit)or ad valorem (a proportion of the value imported).The effects of a specific tariff t per unit are now analysed, starting byconsidering a scenario without tariff.With the tariff there will be an excess demand in H and an excess supplyin F .

Thus, the H price will rise and it will fall in F until the price difference is t .

In H, producers supply more, while consumers demand less, so thatfewer imports are demanded.

Hence, the producer surplus increases and the consumer surplus falls.In F , the lower price leads to a smaller export supply.

Thus, the producer surplus decreases and the consumer surplus increases.The increase in the H price is less than the amount of the tariff, becausepart of the tariff is reflected in a decline in F price and thus is not passedon to H consumers.

The government’s welfare is affected: it gains from collecting tariff revenue.

O. Afonso, P. B. Vasconcelos Computational Economics 21 / 38

Page 22: Chapter 1 Supply and demand - Amazon Web Servicess3-euw1-ap-pe-ws4-cws-documents.ri-prod.s3.amazonaws.com/... · Introduction The supply–demand model is used to understand the determination

Economic model with international-trade policy

Effects of a tariff on imports

Since the welfare gains and losses accrue to different agents, the overallcost–benefit evaluation of a tariff depends on how much consumers,producers and government are affected.In H, a tariff distorts the incentives of producers and consumers byinducing them to act as if imports were more expensive than they are:

consumers reduce consumption, which imposes a consumption distortionloss, andproducers expand production, which generates a production distortion loss;a gain in the terms of trade emerge because the tariff lowers foreign exportprices.

In F , consumers gain, and the reverse occurs with foreign producers: thenet welfare in F is negative, corresponding to the loss in trade terms.In terms of the world, the gain in trade terms in H is offset by the loss intrade terms in F and the distortions in H will prevail.

O. Afonso, P. B. Vasconcelos Computational Economics 22 / 38

Page 23: Chapter 1 Supply and demand - Amazon Web Servicess3-euw1-ap-pe-ws4-cws-documents.ri-prod.s3.amazonaws.com/... · Introduction The supply–demand model is used to understand the determination

Economic model with international-trade policy

Effects of an export subsidies

An export subsidy is a payment to an agent that ships a good abroad,which can also be either specific (a fixed sum per unit) or ad valorem (aproportion of the value exported).A governmental export subsidy affects the price (it is exactly the reverseof those of a tariff): the price rises in the exporting country, but becausethe price falls in the importing country, the price increase is less than thesubsidy.In the exporting country, consumers loss, producers gain, and thegovernment loses because it must expend money on the subsidy.

In net terms, the welfare of the exporting country is penalised.

In the Foreign importing country, consumers gain, and the reverse occurswith foreign producers.

The net welfare in Foreign country is positive, corresponding to the gain intrade terms.

In terms of the world, now the loss in trade terms in H is offset by the gainin trade terms in F and the distortions will prevail.

O. Afonso, P. B. Vasconcelos Computational Economics 23 / 38

Page 24: Chapter 1 Supply and demand - Amazon Web Servicess3-euw1-ap-pe-ws4-cws-documents.ri-prod.s3.amazonaws.com/... · Introduction The supply–demand model is used to understand the determination

Numerical solution

The models here are linear with respect to the endogenous variables and cantherefore be defined by a system of linear equations,

a11 x1 + a12 x2 + · · ·+ a1n xn = d1a21 x1 + a22 x2 + · · ·+ a2n xn = d2

...an1 x1 + an2 x2 + ...+ ann xn = dn

or, in matrix form,

Ax = d . (4)

O. Afonso, P. B. Vasconcelos Computational Economics 24 / 38

Page 25: Chapter 1 Supply and demand - Amazon Web Servicess3-euw1-ap-pe-ws4-cws-documents.ri-prod.s3.amazonaws.com/... · Introduction The supply–demand model is used to understand the determination

Numerical solution

Gaussian elimination

The basic idea is to transform the original system in an equivalent simplerone using operations that do not change the solution.These are called elementary row operations:

interchanging two equations;multiplying any equation by a nonzero scalar;adding a multiple of one equation to another.

By performing these operations, zero entries can be inserted into matrixA in order to produce an upper triangular matrix U.Then, system Ux = d (note that d is also changed with these operations)can be easily solved by

back-substitution:

xn = dn/unn, xi =

d i −n∑

j=i+1

uijxj

/uii , i = n − 1, · · · ,1. (5)

O. Afonso, P. B. Vasconcelos Computational Economics 25 / 38

Page 26: Chapter 1 Supply and demand - Amazon Web Servicess3-euw1-ap-pe-ws4-cws-documents.ri-prod.s3.amazonaws.com/... · Introduction The supply–demand model is used to understand the determination

Numerical solution

Gaussian elimination in practice

MATLAB/Octave: the solution for Ax = d only requires the command A\d(backward slash), which performs Gauss elimination.The algorithm under backward slash:

performs partial pivoting to ensure stability, andmanages data efficiently in today’s computers’ hierarchical memory.

The solution of systems of linear equations is one of the most frequenttasks in numerical computing.Gaussian elimination is a direct method; alternatively there are theso-called iterative methods, which are more suited to large dimensionalsystems and/or sparse matrices.

O. Afonso, P. B. Vasconcelos Computational Economics 26 / 38

Page 27: Chapter 1 Supply and demand - Amazon Web Servicess3-euw1-ap-pe-ws4-cws-documents.ri-prod.s3.amazonaws.com/... · Introduction The supply–demand model is used to understand the determination

Computational implementation

Three cases are considered: autarky (in which a country isself-sufficient), free international trade and restricted trade imposed bythe tariff or the subsidy.Baseline values:

Qd,H = 100, aH = 20, Qs,H = 20, bH = 20, Qd,F = 80, aF = 20, Qs,F = 40and bF = 20.

O. Afonso, P. B. Vasconcelos Computational Economics 27 / 38

Page 28: Chapter 1 Supply and demand - Amazon Web Servicess3-euw1-ap-pe-ws4-cws-documents.ri-prod.s3.amazonaws.com/... · Introduction The supply–demand model is used to understand the determination

Computational implementation

Presentation and solution for each country

%% Supply−demand model w i th t rade% Implemented by : P .B . Vasconcelos and O. Afonsodisp ( ’−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−− ’ ) ;disp ( ’ Supply−demand model w i th i n t e r n a t i o n a l t rade p o l i c y ’ ) ;disp ( ’−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−− ’ ) ;

%% parametersaH = 10; bH = 5; aF = 20; bF = 25;

%% exogenous v a r i a b l e sQd_barH = 1000; Qs_barH = 250; Qd_barF = 1400; Qs_barF = 500;

%% model% s o l u t i o n f o r each count ryAH = [1 aH; 1 −bH ] ; dH = [ Qd_barH ; Qs_barH ] ; xH = AH\dH ;AF = [1 aF ; 1 −bF ] ; dF = [ Qd_barF ; Qs_barF ] ; xF = AF \ dF ;disp ( ’ computed endogenous va r i a b l e s ( autarky ) : ’ )f p r i n t f ( ’ q u a n t i t y (Home) , QH: %7.2 f \ n ’ , xH ( 1 ) ) ;f p r i n t f ( ’ p r i ce (Home) , PH: %7.2 f \ n ’ , xH ( 2 ) ) ;f p r i n t f ( ’ q u a n t i t y ( Foreign ) , QF: %7.2 f \ n ’ , xF ( 1 ) ) ;f p r i n t f ( ’ p r i ce ( Foreign ) , PF : %7.2 f \ n ’ , xF ( 2 ) ) ;

O. Afonso, P. B. Vasconcelos Computational Economics 28 / 38

Page 29: Chapter 1 Supply and demand - Amazon Web Servicess3-euw1-ap-pe-ws4-cws-documents.ri-prod.s3.amazonaws.com/... · Introduction The supply–demand model is used to understand the determination

Computational implementation

Home import demand and Foreign export supply

% Home Import Demand and Foreign Export Supply% HID = QdH−QsH; FES = QsF−QdFaW = aH+bH; bW = bF+aF ;Qd_barW = Qd_barH−Qs_barH ; Qs_barW = Qs_barF−Qd_barF ;A = [ 1 aW ; 1 −bW ] ; d = [ Qd_barW ; Qs_barW ] ;x = A\ d ; QW = x ( 1 ) ; PW = x ( 2 ) ;disp ( ’ computed endogenous va r i a b l e s ( f r ee i n t e r n a t i o n a l t rade ) : ’ )f p r i n t f ( ’ q u a n t i t y ( World ) , QW: %7.2 f \ n ’ , QW) ;f p r i n t f ( ’ p r i ce ( World ) , PW: %7.2 f \ n ’ , PW) ;

QdHW = Qd_barH−aH∗x ( 2 ) ; QsHW = Qs_barH+bH∗x ( 2 ) ;QdFW = Qd_barF−aF∗x ( 2 ) ; QsFW = Qs_barF+bF∗x ( 2 ) ;f p r i n t f ( ’ Home eq . demand at PW, QdHW: %7.2 f \ n ’ , QdHW) ;f p r i n t f ( ’ Home eq . supply a t PW, QsHW: %7.2 f \ n ’ , QsHW) ;f p r i n t f ( ’ Foreign eq . demand at PW, QdFW: %7.2 f \ n ’ , QdFW) ;f p r i n t f ( ’ Foreign eq . supply a t PW, QsFW: %7.2 f \ n ’ , QsFW) ;

O. Afonso, P. B. Vasconcelos Computational Economics 29 / 38

Page 30: Chapter 1 Supply and demand - Amazon Web Servicess3-euw1-ap-pe-ws4-cws-documents.ri-prod.s3.amazonaws.com/... · Introduction The supply–demand model is used to understand the determination

Computational implementation

Plot the solution

%% p l o t sQmax = max ( [ xH ( 1 ) , xF ( 1 ) , x ( 1 ) ] ) ; Q = 0:1 .5∗Qmax;Pmax = max ( [ xH ( 2 ) , xF ( 2 ) , x ( 2 ) ] ) ;

% Home count rysubplot (1 ,3 ,1 ) ;plot (Q, ( Qd_barH−Q) / aH, ’ b ’ ,Q, (Q−Qs_barH ) / bH, ’ r−− ’ ) ;t i t l e ( ’Home market ’ ) ;xlabel ( ’ quan t i t y , Q ’ ) ; ylabel ( ’ p r ice , P ’ ) ;y l im ( [0 ,2∗Pmax ] ) ; x l im ( [ 0 , 1 . 2∗Qmax ] )

% Worldsubplot (1 ,3 ,2 ) ;plot (Q, ( Qd_barW−Q) /aW, ’ b ’ ,Q, (Q−Qs_barW) /bW, ’ r−− ’ ) ;t i t l e ( ’ World market ’ ) ;xlabel ( ’ quan t i t y , Q ’ ) ; ylabel ( ’ p r ice , P ’ ) ;y l im ( [0 ,2∗Pmax ] ) ; x l im ( [ 0 , 1 . 2∗Qmax ] )

% f o r e i g n count rysubplot (1 ,3 ,3 ) ;plot (Q, ( Qd_barF−Q) / aF , ’ b ’ ,Q, (Q−Qs_barF ) / bF , ’ r−− ’ ) ;t i t l e ( ’ Foreign market ’ ) ;xlabel ( ’ quan t i t y , Q ’ ) ; ylabel ( ’ p r ice , P ’ ) ;y l im ( [0 ,2∗Pmax ] ) ; x l im ( [ 0 , 1 . 2∗Qmax ] )

O. Afonso, P. B. Vasconcelos Computational Economics 30 / 38

Page 31: Chapter 1 Supply and demand - Amazon Web Servicess3-euw1-ap-pe-ws4-cws-documents.ri-prod.s3.amazonaws.com/... · Introduction The supply–demand model is used to understand the determination

Numerical results and simulation

---------------------------------------------------------Supply-demand model with international trade policy---------------------------------------------------------computed endogenous variables (autarky):

quantity (Home), QH: 500.00price (Home), PH: 50.00quantity (Foreign), QF: 1000.00price (Foreign), PF: 20.00

computed endogenous variables (free international trade):quantity (World), QW: 337.50price (World), PW: 27.50Home eq. demand at PW, QdHW: 725.00Home eq. supply at PW, QsHW: 387.50Foreign eq. demand at PW, QdFW: 850.00Foreign eq. supply at PW, QsFW: 1187.50

O. Afonso, P. B. Vasconcelos Computational Economics 31 / 38

Page 32: Chapter 1 Supply and demand - Amazon Web Servicess3-euw1-ap-pe-ws4-cws-documents.ri-prod.s3.amazonaws.com/... · Introduction The supply–demand model is used to understand the determination

Numerical results and simulation

0 500 10000

10

20

30

40

50

60

70

80

90

100Home market

quantity, Q

price, P

0 500 10000

10

20

30

40

50

60

70

80

90

100World market

quantity, Q

price, P

0 500 10000

10

20

30

40

50

60

70

80

90

100Foreign market

quantity, Qprice, P

Supply and demand curves for all markets

O. Afonso, P. B. Vasconcelos Computational Economics 32 / 38

Page 33: Chapter 1 Supply and demand - Amazon Web Servicess3-euw1-ap-pe-ws4-cws-documents.ri-prod.s3.amazonaws.com/... · Introduction The supply–demand model is used to understand the determination

Numerical results and simulation

Free trade vs restricted trade: tariffH, as an importing country, imposes a (specific) tariff to limit imports to 250.

---------------------------------------------------------Supply-demand model with international trade policy

tariff---------------------------------------------------------H limits imports to 250 unitscomputed endogenous variables (tariff):

Home price, PHt: 33.33Foreign price, PFt: 25.56tariff: 7.78Home quantity demanded, QdHt: 666.67Home quantity supplied, QsHt: 416.67Foreign quantity demanded, QdFt: 888.89Foreign quantity demanded, QsFt: 1138.89

computed welfare variation:Home, WH_var: 230.90Foreign, WF_var: -571.18

O. Afonso, P. B. Vasconcelos Computational Economics 33 / 38

Page 34: Chapter 1 Supply and demand - Amazon Web Servicess3-euw1-ap-pe-ws4-cws-documents.ri-prod.s3.amazonaws.com/... · Introduction The supply–demand model is used to understand the determination

Numerical results and simulation

0 500 100015

20

25

30

35

40

45

50

55Home market

quantity, Q

price, P

0 500 100015

20

25

30

35

40

45

50

55World market

quantity, Q

price, P

500 1000 150015

20

25

30

35

40

45

50

55Foreign market

quantity, Qprice, P

Supply and demand curves, with tariff, for all markets

O. Afonso, P. B. Vasconcelos Computational Economics 34 / 38

Page 35: Chapter 1 Supply and demand - Amazon Web Servicess3-euw1-ap-pe-ws4-cws-documents.ri-prod.s3.amazonaws.com/... · Introduction The supply–demand model is used to understand the determination

Numerical results and simulation

Free trade vs restricted trade: export subsidiesF , as an exporting country, imposes a (specific) subsidy in order to export 400units.

---------------------------------------------------------Supply-demand model with international trade policy

subsidy---------------------------------------------------------F applies a subsidy to exports to trade of 400 unitscomputed endogenous variables (subsidy):

Home price, PHs: 23.33Foreign price, PFs: 28.89subsidy: 5.56Home quantity demanded, QdHs: 766.67Home quantity supplied, QsHs: 366.67Foreign quantity demanded, QdFs: 822.22Foreign quantity demanded, QsFs: 1222.22

computed welfare variation:Home, WH_var: 512.15Foreign, WF_var: -1710.07

O. Afonso, P. B. Vasconcelos Computational Economics 35 / 38

Page 36: Chapter 1 Supply and demand - Amazon Web Servicess3-euw1-ap-pe-ws4-cws-documents.ri-prod.s3.amazonaws.com/... · Introduction The supply–demand model is used to understand the determination

Numerical results and simulation

0 500 1000

20

30

40

50

60

70

Home market

quantity, Q

price, P

0 500 1000

20

30

40

50

60

70

World market

quantity, Q

price, P

500 1000 1500

20

30

40

50

60

70

Foreign market

quantity, Qprice, P

Supply and demand curves, with subsidy, for all markets

O. Afonso, P. B. Vasconcelos Computational Economics 36 / 38

Page 37: Chapter 1 Supply and demand - Amazon Web Servicess3-euw1-ap-pe-ws4-cws-documents.ri-prod.s3.amazonaws.com/... · Introduction The supply–demand model is used to understand the determination

Highlights

The supply–demand model provides a practical and simple explanation ofhow markets work.In competitive markets, the model allows for the determination of priceand quantity traded, along with the social welfare.The framework is extended to consider international trade policy; theeffects of a tariff to imports and of a subsidy to exports are analysed.The Gaussian elimination method for the solution of a system of linearequations is introduced.

O. Afonso, P. B. Vasconcelos Computational Economics 37 / 38

Page 38: Chapter 1 Supply and demand - Amazon Web Servicess3-euw1-ap-pe-ws4-cws-documents.ri-prod.s3.amazonaws.com/... · Introduction The supply–demand model is used to understand the determination

Main references

A. Mas-Colell, M. D. Whinston, andJ. R. GreenMicroeconomic theoryOxford University Press (1995)

G. Dahlquist and Å BjörckNumerical methods in scientificcomputingSociety for Industrial Mathematics(2008)

J. W. DemmelApplied Numerical Linear AlgebraSociety for Industrial Mathematics(1997)

R. Krugman, M. Obstfeld, andM. J. MelitzInternational Economic: Theoryand PracticePrentice Hall, 9th Edition (2011)

J. M. PerloffMicroeconomics: Theory andApplications with CalculusPrentice Hall, 3rd edition (2013)

H. R. VarianMicroeconomic AnalysisW. W. Norton & Company, 3rdedition (1992)

O. Afonso, P. B. Vasconcelos Computational Economics 38 / 38