Question: System of two equations and evaluate

restart``

with(plots); with(RealDomain)

``

c := 1; cr := 0.3e-1*c; u := 1; sExp := 0.6e-1*c; s := .65*c

v := 3*c

``

NULL``

FirmModelHmax := proc (alpha, beta, delta) local q, p, pr, FirmpfSiS, F1, G1, G2, G3, RecpfSiS, sol, UnsoldSiS, EnvironSiS, p0, OldSoldPrim, xi, h, ps, qs, prs, prof1, prof2; xi := 1; prs := ps-delta*v; prof1 := qs*(ps-c)+(1/2)*(beta^2*xi^2*qs^2/(1-alpha)-(1+beta*xi)^2*qs^2)(ps-s)/u+(prs-sExp)(beta*xi*qs-(1/2)*beta^2*xi^2*qs^2/(u*(1-alpha))); prof2 := qs*(ps-c)-(1/2)*(ps-s)*qs^2*(prs-sExp)(beta*xi*qs-(1/2)*beta^2*xi^2*qs^2/(u*(1-alpha)))/(alpha*u); if alpha <= 1/(1+beta*xi) then [p, q] := solve({diff(prof1, qs) = 0, qs = alpha*u*(v-ps)/(v-s), 0 < ps}, [ps, qs]); G2 := (1/2)*beta^2*xi^2*q^2/(u*(1-alpha)^2); G3 := (1/2)*q^2*(1+beta*xi)^2/u; h := (p-delta*v-sExp)/(p-delta*v); FirmpfSiS := eval(prof1, [ps = p, qs = q, prs = p-delta*v]); RecpfSiS := ((1-h)*(p-delta*v)-sExp)*(beta*xi*q-G2)+sExp*xi*q-cr*xi*q; UnsoldSiS := G3-(1-alpha)*G2; EnvironSiS := q+UnsoldSiS; OldSoldPrim := beta*xi*q-(1-alpha)*G2 else [p, q] := solve({diff(prof2, qs) = 0, qs = alpha*u*(v-ps)/(v-s), 0 < ps}, [ps, qs]); q := alpha*u*(v-p)/(v-s); F1 := beta*xi*q/(u*(1-alpha)); G1 := (1/2)*q^2/(u*alpha^2); G2 := (1/2)*beta^2*xi^2*q^2/(u*(1-alpha)^2); G3 := (1/2)*q^2*(1+beta*xi)^2/u; h := (p-delta*v-sExp)/(p-delta*v); FirmpfSiS := eval(prof2, [ps = p, qs = q, prs = p-delta*v]); RecpfSiS := ((1-h)*(p-delta*v)-sExp)*(beta*xi*q-G2)+sExp*xi*q-cr*xi*q; UnsoldSiS := alpha*G1; EnvironSiS := q+UnsoldSiS; OldSoldPrim := beta*xi*q-(1-alpha)*G2 end if; return p, q, FirmpfSiS, RecpfSiS, EnvironSiS, h, UnsoldSiS, OldSoldPrim, xi end proc

``

NULL

``

WhyNot3 := proc (alpha, delta) if not [alpha, delta]::(list(numeric)) then return ('procname')(args) end if; FirmModelHmax(alpha, .2, delta)[3] end proc:

pltHmax1 := plot(
  [seq(WhyNot3(alpha, delta),delta=0.1..0.5,0.2)]  
  , alpha=0..2/(2 + 0.2*(1 - sqrt((c - s)/(v - s))))     
  , linestyle=[dot,dashdot,dash]    
  , legend=[seq('delta'=delta,delta=0.1..0.5,0.2)]    
  , legendstyle=[location=left]    
  , labels=["alpha","Firm profit"]    
  , labeldirections =["horizontal", "vertical"]  
  , legendstyle=[location=bottom]
):

display(pltHmax1)

Warning, unable to evaluate the functions to numeric values in the region; see the plotting command's help page to ensure the calling sequence is correct

 

 

 

NULL

Download HmaxProc.mw

Please Wait...