RezaZanjirani

40 Reputation

One Badge

1 years, 234 days

MaplePrimes Activity


These are questions asked by RezaZanjirani

Dear Maple users/ experts

I have three functions, each with two parameters, alpha and delta, changing over 0..1. I want to partition the region in terms of what part gets the highest value. In the attached maple file, I used "implicit plot" and did it for any pair of functions in a reasonable time. But I don't know how these three plots can be consolidated into one. ('inequal' command was not precise while taking too long).  2D_implicitplot_with_three_functions.mw

Dear Maple experts, I have written a not-very-complicated Maple procedure, including eval, if, etc. However,

restartNULL

with(plots)

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

NULL

NULLNULL

FirmModelH := proc (alpha, beta, delta, h) local q, p, pr, FirmpfSiS, F1, G1, G2, G3, RecpfSiS, sol, UnsoldSiS, EnvironSiS, p0, UsedSoldPrimary, xi, ps, qs, prs, prof1F, prof1P, prof2F, prof2P, kappa; option remember; kappa := (beta*(ps-delta*v)*(1-h)+sExp*(1-beta))/(beta^2*((ps-delta*v)*(1-h)-sExp)/(u*(1-alpha))+2*cr); prof1F := (ps-c)*qs+((1/2)*beta^2*qs^2*xi^2/(u*(1-alpha))-(1/2)*(1+beta*xi)^2*qs^2/u)*(ps-s)+h*(ps-delta*v)*(beta*xi*qs-(1/2)*beta^2*qs^2*xi^2/(u*(1-alpha))); prof1P := (ps-c)*qs+((1/2)*beta^2*kappa^2/(u*(1-alpha))-(1/2)*(qs+beta*kappa)^2/u)*(ps-s)+h*(ps-delta*v)*(beta*kappa-(1/2)*beta^2*kappa^2/(u*(1-alpha))); prof2F := (ps-c)*qs-(1/2)*(ps-s)*qs^2/(alpha*u)+h*(ps-delta*v)*(beta*xi*qs-(1/2)*beta^2*qs^2*xi^2/(u*(1-alpha))); prof2P := (ps-c)*qs-(1/2)*(ps-s)*qs^2/(alpha*u)+h*(ps-delta*v)*(beta*kappa-(1/2)*beta^2*kappa^2/(u*(1-alpha))); xi := 1; if alpha <= 1/(1+beta) then p, q := (eval([ps, qs], solve({diff(prof1F, qs) = 0, qs = alpha*u*(v-ps)/(v-s), c < ps, sExp+delta*v < ps}, [ps, qs])[1]))[]; if eval(kappa, [ps = p, prs = p-delta*v]) < q then p, q := (eval([ps, qs], solve({diff(prof1P, qs) = 0, qs = alpha*u*(v-ps)/(v-s), c < ps, sExp+delta*v < ps}, [ps, qs])[1]))[] end if; xi := min(1, (eval(kappa, [ps = p]))/q); FirmpfSiS := eval(prof1F, [ps = p, qs = q]); RecpfSiS := ((1-h)*(p-delta*v)-sExp)*(beta*xi*q-(1/2)*beta^2*xi^2*q^2/(u*(1-alpha)))+sExp*xi*q-cr*xi^2*q^2; UnsoldSiS := (1/2)*(1+beta*xi)^2*q^2/u-(1/2)*beta^2*xi^2*q^2/(u*(1-alpha)); EnvironSiS := q+UnsoldSiS else p, q := (eval([ps, qs], solve({diff(prof2F, qs) = 0, qs = alpha*u*(v-ps)/(v-s), c < ps, sExp+delta*v < ps}, [ps, qs])[1]))[]; pr = p-delta*v; if eval(kappa, [ps = p]) < q then p, q := (eval([ps, qs], solve({diff(prof2P, qs) = 0, qs = alpha*u*(v-ps)/(v-s), c < ps, sExp+delta*v < ps}, [ps, qs])[1]))[] end if; kappa := (beta*(p-delta*v)*(1-h)+sExp*(1-beta))/(beta^2*((1-h)*(p-delta*v)-sExp)/(u*(1-alpha))+2*cr); xi := min(1, (eval(kappa, [ps = p]))/q); FirmpfSiS := eval(prof2F, [ps = p, qs = q]); RecpfSiS := ((1-h)*(p-delta*v)-sExp)*(beta*xi*q-(1/2)*beta^2*xi^2*q^2/(u*(1-alpha)))+sExp*xi*q-cr*xi^2*q^2; UnsoldSiS := (1/2)*(1+beta*xi)^2*q^2/u-(1/2)*beta^2*xi^2*q^2/(u*(1-alpha)); EnvironSiS := q+UnsoldSiS end if; return p, q, FirmpfSiS, RecpfSiS, EnvironSiS, UnsoldSiS, UsedSoldPrimary, xi end proc
NULL

NULL

NULLNULL

NULL

FirmModelH(.8, .15, .15, .10)[3]

Error, (in FirmModelH) cannot determine if this expression is true or false: (-0.4957031250e-11*(-0.3155744681e13*xi^2+(0.3966029880e25*xi^4-0.2830096342e26*xi^3+0.4078080001e26*xi^2+0.5006706391e26*xi+0.5289940424e27)^(1/2)+0.1144851064e14*xi+0.7761702136e13)/(63.*xi^2-240.*xi-800.)-0.9750e-2)/(-0.3717773438e-11*(-0.3155744681e13*xi^2+(0.3966029880e25*xi^4-0.2830096342e26*xi^3+0.4078080001e26*xi^2+0.5006706391e26*xi+0.5289940424e27)^(1/2)+0.1144851064e14*xi+0.7761702136e13)/(63.*xi^2-240.*xi-800.)+0.768750000e-2) < (24.89361704*xi^2-102.*xi-720.0000001+0.1250000000e-10*(0.3966029880e25*xi^4-0.2830096342e26*xi^3+0.4078080001e26*xi^2+0.500670...

 

NULL

NULLNULLNULLNULLNULL

``

pltH01A := plot('FirmModelH(alpha, .25, .40, 0)[1]', alpha = 0. .. 1, color = yellow, legend = [SiS(h__0)], labels = [alpha, "New Product Price"], labeldirections = ["horizontal", "vertical"], symbolsize = 10, numpoints = 50, adaptive = false, axes = boxed, thickness = 1.0)

NULLNULLNULL

TH1 := table([seq(h = sprintf("SiS:", h), h = .1 .. .5, .2)])

WhyNotH1 := proc (alpha, h) if not [alpha, h]::(list(numeric)) then return ('procname')(args) end if; FirmModelH(alpha, 0.25, 0.40,h)[1] end proc:NULL

 

pltH1 := plot([seq(WhyNotH1(alpha, h), h = .1 .. .5, .2)], alpha = 0. .. 1, linestyle = [dash, dashdot, longdash], color = [red, green, blue], legend = [seq(typeset(TH1[h], 'h' = h), h = .1 .. .5, .2)], legendstyle = [location = left], labels = [alpha, "New Product Price"], labeldirections = ["horizontal", "vertical"], legendstyle = [location = bottom], thickness = 1.0, adaptive = false, axes = boxed)

 

Download SiS_Quadratic_(goal).mw

it faces an error saying that Maple cannot determine if the procedure is true. Would you please have a look and advise?

Dear Maple experts

I face an issue in using ‘implicit plot’ or ‘inequal’ commands in the attached file.

I use three Maple procedures to make some simple calculations and draw an output. It is Firm Profit versus ‘alpha’. This graph is correct and makes perfect sense.

Then, I use ‘inequal’ command to compare the same outputs when ‘alpha’ and ‘delta’ change. There is a conflict between these plots and the above diagram. For example, P2 plot says

restartNULL

with(plots); with(RealDomain)

NULL

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

``

FirmModelPP := proc (alpha, beta, delta) local p0, xi0, q0, Firmpf0, G01, Recpf0, Unsold0, Environ0; 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; G01 := int(F(N), N = 0 .. q0); Firmpf0 := (p0-c)*q0-(p0-s)*G01; Recpf0 := (sExp-cr)*xi0*q0; Unsold0 := G01; Environ0 := q0+Unsold0; return p0, q0, Firmpf0, Recpf0, Environ0, Unsold0 end proc

NULL

NULLNULLNULL

FirmModelFC := proc (alpha, beta, delta) local p00, xi00, q00, Firmpf00, G001, G002, Recpf00, Unsold00, Environ00, pr00; option remember; xi00 := 1; p00 := s+sqrt((v-s)*(c-s)); q00 := alpha*u*(v-p00)/(v-s); f(N) := 1/u; F(N) := N/u; G001 := int(F(N), N = 0 .. q00/alpha); G002 := int(F(N), N = 0 .. beta*xi00*q00/(1-alpha)); pr00 := p00-delta*v; Firmpf00 := (p00-c)*q00-alpha*(p00-s)*G001; Recpf00 := xi00*q00*(sExp-cr)+(pr00-sExp)*(beta*xi00*q00-(1-alpha)*G002); Unsold00 := alpha*G001; Environ00 := q00+Unsold00; return p00, q00, Firmpf00, Recpf00, Environ00, Unsold00 end proc

NULLNULL``

NULLNULL

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, prof1m, prof2m; option remember; xi := 1; prs := ps-delta*v; prof1m := (ps-c)*qs+((1/2)*beta^2*xi^2*qs^2/(u*(1-alpha))-(1/2)*(1+beta*xi)^2*qs^2/u)*(ps-s)+(prs-sExp)*(beta*xi*qs-(1/2)*beta^2*xi^2*qs^2/(u*(1-alpha))); prof2m := (ps-c)*qs-(1/2)*(ps-s)*qs^2/(alpha*u)+(prs-sExp)*(beta*xi*qs-(1/2)*beta^2*xi^2*qs^2/(u*(1-alpha))); if alpha <= 1/(1+beta*xi) then p, q := (eval([ps, qs], solve({diff(prof1m, qs) = 0, qs = alpha*u*(v-ps)/(v-s), c < ps, sExp+delta*v < ps, qs < 2*u*(1-alpha)/(beta*xi)}, [ps, qs])[1]))[]; `h&Assign;`*(p-delta*v-sExp)/(p-delta*v); FirmpfSiS := eval(prof1m, [ps = p, qs = q, prs = p-delta*v]); RecpfSiS := (sExp-cr)*xi*q; UnsoldSiS := (1/2)*(1+beta*xi)^2*q^2/u-(1/2)*beta^2*xi^2*q^2/(u*(1-alpha)); EnvironSiS := q+UnsoldSiS else p, q := (eval([ps, qs], solve({diff(prof2m, qs) = 0, qs = alpha*u*(v-ps)/(v-s), c < ps, sExp+delta*v < ps, qs < 2*u*(1-alpha)/(beta*xi)}, [ps, qs])[1]))[]; h := (p-delta*v-sExp)/(p-delta*v); FirmpfSiS := eval(prof2m, [ps = p, qs = q, prs = p-delta*v]); RecpfSiS := (sExp-cr)*xi*q; UnsoldSiS := (1/2)*q^2/(alpha*u); EnvironSiS := q+UnsoldSiS end if; return p, q, FirmpfSiS, RecpfSiS, EnvironSiS, UnsoldSiS, h, OldSoldPrim, xi end proc

``

``

NULL

NULL

``

NULLNULL

NULLNULL

pltPP3A := plot('FirmModelPP(alpha, .35, .40)[3]', alpha = 0. .. 1.0, color = red, legend = "", style = pointline, labels = [alpha, "Firm Profit"], labeldirections = ["horizontal", "vertical"], symbolsize = 10, axes = boxed, symbol = box, numpoints = 10, adaptive = false, thickness = 1.0, view = [0 .. 1, 0 .. .18])

NULL

pltPP3B := plot([[0., eval('FirmModelPP(0., .35, .40)[3]', alpha = 0.)]], color = red, legend = ["PP"], style = point, symbol = box, symbolsize = 10, axes = boxed, view = [0 .. 1, 0 .. .18])

NULL

pltFC3A := plot('FirmModelFC(alpha, .35, .40)[3]', alpha = 0. .. 1, linestyle = [solid], color = black, legend = "FC", labels = [alpha, "Firm Profit"], labeldirections = ["horizontal", "vertical"], axes = boxed, adaptive = false, thickness = .7, view = [0 .. 1.0, 0 .. .18])

NULL

NULLNULLNULLNULLNULL

pltHmax3A := plot('FirmModelHmax(alpha, .35, .40)[3]', alpha = 0. .. 1.0, linestyle = [dashdot], color = brown, legend = [SiS(h__max)], labels = [alpha, "Firm Profit"], labeldirections = ["horizontal", "vertical"], symbolsize = 10, numpoints = 50, adaptive = false, thickness = 1.0, axes = boxed, view = [0 .. 1, 0 .. .19])

``

NULLNULLNULL

display([pltPP3A, pltPP3B, pltFC3A, pltHmax3A])

 

NULL

``

NULL

NULL

NULL

``

NULL

``

NULL

NULL

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

NULL

P2 := plots:-inequal(diffr2(alpha, delta) <= 0, alpha = 0 .. 1, delta = 0 .. 1, optionsfeasible = [[color = "Spring 1"]])

 

``

NULL

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

NULL

P3 := plots:-inequal(diffr3(alpha, delta) <= 0, alpha = 0 .. 1, delta = 0 .. 1, colour = "Orange")

 

``

Download ConflcitInequal.mw

SiS is superior to FC in small ‘alpha’s. But in the initial diagram, it is obvious that it should be the opposite!

Perhaps I am making a mistake in using commands. Would you please help me?

Dear Maple experts, I want to write text in a specific location within a Maple plot like p<c. To do that, I use 'plots:-textplot' as follows:

plots:-textplot([[0.1, 0.80, p < c, color = black]], font = [times, 11], rotation = 'horizontal');

The issue is that in my code, 'p' and 'c' are parameters with specific values. Therefore,  in my plot, their values appear instead of p<c. Even if I use 'p<c' or "p<c" it does not work.

Would you please guide me on how to solve the issue?

Dear Maple experts,

I have a system of several nonlinear equaitons. My code can solve it for a given parameter. But when I want to plot it, it takes too much time with no results. So, I decided to plot it for several given points. I get the answer for the points individually, but I don't know how to apply this to 'plot' command. Would you please help?

restartNULL

with(plots); with(RealDomain)

NULL

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

NULL

NULL

FirmModelPartial1 := proc (alpha, beta, delta) local L1s, qs, ps, prs, hs, `&kappa;s`, `&lambda;__1s`, `&lambda;__2s`, `&lambda;__3s`, q, p, pr, h, kappa, `&lambda;__1`, `&lambda;__2`, `&lambda;__3`, FirmpfSiS, RecpfSiS, UnsoldSiS, EnvironSiS, p0, OldSoldPrim, xi, prof1, prof2, L1, L2, E1, E2, E3, E4, E5, E6, E7, E8, E9, E10, E11, E12; prof1 := (ps-c)*qs+((1/2)*beta^2*`&kappa;s`^2/(u*(1-alpha))-(1/2)*(qs+beta*`&kappa;s`)^2/u)*(ps-s)+hs*prs*(beta*`&kappa;s`-(1/2)*beta^2*`&kappa;s`^2/(u*(1-alpha))); L1s := prof1+`&lambda;__1s`*(1-sExp/prs-hs)+`&lambda;__2s`*(qs-`&kappa;s`)+`&lambda;__3s`*(qs-alpha*beta*`&kappa;s`/(1-alpha)); E1 := qs*(diff(L1s, qs)) = 0; E2 := hs*(diff(L1s, hs)) = 0; E3 := `&lambda;__1s`*(1-sExp/prs-hs) = 0; E4 := `&lambda;__2s`*(qs-`&kappa;s`) = 0; E5 := `&lambda;__3s`*(qs-alpha*beta*`&kappa;s`/(1-alpha)) = 0; E6 := qs = alpha*u*(v-ps)/(v-s); E7 := prs = ps-delta*v; E8 := `&kappa;s` = (beta*prs*(1-hs)+sExp*(1-beta))/(beta^2*(prs*(1-hs)-sExp)/(u*(1-alpha))+2*cr); p, q, pr, h, kappa, `&lambda;__1`, `&lambda;__2`, `&lambda;__3` := (eval([ps, qs, prs, hs, `&kappa;s`, `&lambda;__1s`, `&lambda;__2s`, `&lambda;__3s`], solve({0 <= qs-alpha*beta*`&kappa;s`/(1-alpha), 0 <= qs-`&kappa;s`, 0 <= 1-sExp/prs-hs, 0 <= `&lambda;__1s`, 0 <= `&lambda;__2s`, 0 <= `&lambda;__3s`, diff(L1s, qs) <= 0, diff(L1s, hs) <= 0, c < ps, (1/2)*beta*`&kappa;s`/(u*(1-alpha)) < 1, sExp+delta*v < ps, E1, E2, E3, E4, E5, E6, E7, E8}, [ps, qs, prs, hs, `&kappa;s`, `&lambda;__1s`, `&lambda;__2s`, `&lambda;__3s`])[1]))[]; xi := kappa/q; FirmpfSiS := max(0, eval(prof1, [ps = p, qs = q, prs = p-delta*v, hs = h, `&kappa;s` = kappa])); RecpfSiS := ((1-h)*pr-sExp)*(beta*kappa-(1/2)*beta^2*kappa^2/(u*(1-alpha)))+(sExp-cr)*kappa; UnsoldSiS := (1/2)*(q+beta*kappa)^2/u-(1/2)*beta^2*kappa^2/(u*(1-alpha)); EnvironSiS := q+UnsoldSiS; return p, q, FirmpfSiS, RecpfSiS, EnvironSiS, h, UnsoldSiS, h, xi end proc

NULL

NULL

FirmModelPartial1(.1, .2, .1)[3]

Error, (in FirmModelPartial1) invalid subscript selector

 

NULL

FirmModelPartial1(.2, .2, .1)[3]

Error, (in FirmModelPartial1) invalid subscript selector

 

FirmModelPartial1(.3, .2, .1)[3]

.2200894743

(1)

NULL

FirmModelPartial1(.4, .2, .1)[3]

.2892440018

(2)

FirmModelPartial1(.5, .2, .1)[3]

.3801240291

(3)

FirmModelPartial1(.6, .2, .1)[3]

.4921660779

(4)

FirmModelPartial1(.7, .2, .1)[3]

.6227094789

(5)

FirmModelPartial1(.8, .2, .1)[3]

.7668402612

(6)

FirmModelPartial1(.9, .2, .1)[3]

.9161921261

(7)
 

plot('FirmModelPartial1(alpha, .2, .2)[3]', alpha = .1 .. .90, adaptive = false, sample = [.1, .2, .3, .4, .5, .6, .7, .8, .9])

 

Download Reza_Tchno_(v3).mw

Besdies, it seems for some points there is no feasible solution. So, there is no need to have plot for them.

I attach the code. Thank you so much!

1 2 3 Page 1 of 3