Question: Differentiate three regions with implicitplot and/or inequal commands

Dear Maple Expeets, In the attached Maple file, I have three procedures that are run smoothly. I am trying to compare outputs from each procedure to see which one if larger than the others. For changes on two parameters (alpha and delta), I used implicitplot and inequal commands to identify each region by a specific color. But the outcome is not reasonable. Would you please help with this? Thanks in advance!

NULLNULL

restart

with(plots)

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

NULL

FirmModelPP := proc (alpha, delta) local p0, xi0, q0, Firmpf0, G0, Recpf0, Unsold0, Environ0, SoldPre0; option remember; xi0 := 1; p0 := min(s+sqrt((v-s)*(c-s)), delta*v+sExp); q0 := u*(v-p0)/(v-s); f(N) := 1/u; F(N) := N/u; G0 := int(F(N), N = 0 .. q0); Firmpf0 := (p0-c)*q0-(p0-s)*G0; Recpf0 := (sExp-cr)*xi0*q0; Environ0 := q0+G0; Unsold0 := G0; SoldPre0 := 0; return p0, q0, Firmpf0, Recpf0, Environ0, Unsold0, SoldPre0 end proc

NULL

FirmModelFC := proc (alpha, beta, delta) local p00, xi00, q00, Firmpf00, G00, Recpf00, Unsold00, Environ00, pr00, SoldPre00; option remember; xi00 := 1; p00 := s+sqrt((v-s)*(c-s)); if p00 < delta*v+sExp then q00 := u*(v-p00)/(v-s); f(N) := 1/u; F(N) := N/u; G00 := int(F(N), N = 0 .. q00); Firmpf00 := (p00-c)*q00-(p00-s)*G00; Recpf00 := `&xi;00*q00*`(sExp-cr); Unsold00 := G00; Environ00 := q00+Unsold00 else q00 := alpha*u*(v-p00)/(v-s); f(N) := 1/u; F(N) := N/u; G00 := int(F(N), N = 0 .. q00/alpha); pr00 := p00-delta*v; Firmpf00 := (p00-c)*q00-alpha*(p00-s)*G00; Recpf00 := (sExp-cr)*xi00*q00+(beta*xi00*q00-(1/2)*beta^2*xi00^2*q00^2/(u*(1-alpha)))*(pr00-sExp); Unsold00 := G00; Environ00 := q00+Unsold00; SoldPre00 := beta*xi00*q00-(1/2)*beta^2*xi00^2*q00^2/(u*(1-alpha)) end if; return p00, q00, Firmpf00, Recpf00, Environ00, Unsold00, SoldPre00 end proc

NULLNULL

NULL

FirmModelHmax := proc (alpha, beta, delta) local q, p, pr, FirmpfSiS, F1, G1, G2, G3, RecpfSiS, sol, UnsoldSiS, EnvironSiS, p0, OldSoldPrim, xi, h; option remember; xi := 1; if alpha <= 1/(1+beta*xi) then p := max(`assuming`([solve(u*(psol-c+(psol-delta*v-sExp)*beta*xi)/(beta^2*xi^2*(psol-delta*v-sExp)/(1-alpha)-(beta^2*xi^2/(1-alpha)-(1+beta*xi)^2)*(psol-s)) = alpha*u*(v-psol)/(v-s), psol, useassumptions)], [0 < psol])); q := alpha*u*(v-p)/(v-s); 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 := (p-c)*q+(p-s)*((1-alpha)*G2-G3)+h*(p-delta*v)*(beta*xi*q-(1-alpha)*G2); 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 := max(`assuming`([solve(u*(psol-c+(psol-delta*v-sExp)*beta*xi)/((psol-s)/u+beta^2*xi^2*(psol-delta*v-sExp)/(1-alpha)) = alpha*u*(v-psol)/(v-s), psol, useassumptions)], [0 < psol])); 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 := (p-c)*q-alpha*(p-s)*G1+h*(p-delta*v)*(beta*xi*q-(1-alpha)*G2); 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

NULLNULL

FirmModelH := proc (alpha, beta, delta, h) local q, p, pr, FirmpfSiS, F1, G1, G2, G3, RecpfSiS, sol, UnsoldSiS, EnvironSiS, p0, OldSoldPrim, xi; option remember; xi := 1; if alpha <= 1/(1+beta*xi) then p := max(`assuming`([solve(u*(psol-c+h*(psol-delta*v)*beta*xi)/(beta^2*xi^2*h*(psol-delta*v)/(1-alpha)-(beta^2*xi^2/(1-alpha)-(1+beta*xi)^2)*(psol-s)) = alpha*u*(v-psol)/(v-s), psol, useassumptions)], [0 < psol])); q := alpha*u*(v-p)/(v-s); G2 := (1/2)*beta^2*xi^2*q^2/(u*(1-alpha)^2); G3 := (1/2)*q^2*(1+beta*xi)^2/u; FirmpfSiS := (p-c)*q+(p-s)*((1-alpha)*G2-G3)+h*(p-delta*v)*(beta*xi*q-(1-alpha)*G2); 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 := max(`assuming`([solve(u*(psol-c+h*(psol-delta*v)*beta*xi)/((psol-s)/u+beta^2*xi^2*h*(psol-delta*v)/(1-alpha)) = alpha*u*(v-psol)/(v-s), psol, useassumptions)], [0 < psol])); 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; FirmpfSiS := (p-c)*q-alpha*(p-s)*G1+h*(p-delta*v)*(beta*xi*q-(1-alpha)*G2); 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

NULL

NULL

NULL

NULL

NULL

NULL

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

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

diffr3 := proc (alpha, delta) if not [alpha, delta]::(list(numeric)) then return ('procname')(args) end if; FirmModelFC(alpha, delta)[3]-FirmModelPP(alpha, delta)[3] end proc

P1 := implicitplot(diffr1, 0 .. 1, 0 .. 1, color = gray, thickness = 1)

P2 := implicitplot(diffr2, 0 .. 1, 0 .. 1, color = black, thickness = 1)

P3 := implicitplot(diffr3, 0 .. 1, 0 .. 1, color = pink, thickness = 1)

``

``

 

 

NULL

``

NULL

P7 := inequal({diffr1(alpha, delta) > 0, diffr2(alpha, delta) > 0, diffr3(alpha, delta) > 0}, alpha = 0 .. 1, delta = 0 .. 1, color = "LightBlue")

P8 := inequal({diffr1(alpha, delta) > 0, diffr2(alpha, delta) > 0, diffr3(alpha, delta) < 0}, alpha = 0 .. 1, delta = 0 .. 1, color = yellow)``

P9 := inequal({diffr1(alpha, delta) > 0, diffr3(alpha, delta) > 0, diffr2(alpha, delta) < 0}, alpha = 0 .. 1, delta = 0 .. 1, color = cyan)

P10 := inequal({diffr1(alpha, delta) > 0, diffr2(alpha, delta) < 0, diffr3(alpha, delta) < 0}, alpha = 0 .. 1, delta = 0 .. 1, color = grey)

P11 := inequal({diffr2(alpha, delta) > 0, diffr3(alpha, delta) > 0, diffr1(alpha, delta) < 0}, alpha = 0 .. 1, delta = 0 .. 1, color = green)

P12 := inequal({diffr2(alpha, delta) > 0, diffr1(alpha, delta) < 0, diffr3(alpha, delta) < 0}, alpha = 0 .. 1, delta = 0 .. 1, color = red)

P13 := inequal({diffr3(alpha, delta) > 0, diffr1(alpha, delta) < 0, diffr2(alpha, delta) < 0}, alpha = 0 .. 1, delta = 0 .. 1, color = pink)

P14 := inequal({diffr1(alpha, delta) < 0, diffr2(alpha, delta) < 0, diffr3(alpha, delta) < 0}, alpha = 0 .. 1, delta = 0 .. 1, color = coral)

NULL

display(P7, P8, P9, P10, P11, P12, P13, P14, textplot([.2, .9, "some text"]), scaling = constrained, view = [0 .. 1, 0 .. 1], labels = [alpha, delta])

 

``


 

Download Compare_three_regions.mw

the final plot does not look reasonable. Would you please guide me?

Please Wait...