Maple 2021 Questions and Posts

These are Posts and Questions associated with the product, Maple 2021

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?

I would like to plot graph of 2d function f(x, y) = (-ax/(1+y^2), x+by) where x from -5 to 5 and y from -5 to 5 and parameter bar of a and b. Thank you 

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?

I have tried to translate the Mathematica-Code of OEIS (A219954):

with MmaTranslator. In the translator occurs an error message with the IF-Statement ...

I will be happy to have this in Maple. I am interested in the digitCount in the above Code.

Sequence is:

 

Thanks for help :)

Hello Everyone;

I need help to solve the following system using rk-4 method

restart;
NULL;
NULL;
C := 1.0;
gK := 36.0;
gNa := 120.0;
gL := 0.3;
VK := -77.0;
VNa := 50.0;
VL := -54.0;
III := 20;
alpha_n := 0.01*(v(t) + 55.0)/(1 - exp(-1.0/10.0*v(t) - 11.0/2.0));
beta_n := 0.125*exp((-v(t))/80.0 + (-1)*13.0/16.0);
alpha_m := 0.1*(v(t) + 40.0)/(1 - exp(-1.0/10.0*v(t) - 4.0));
beta_m := 4.0*exp(-1.0/18.0*v(t) - 65.0/18.0);
alpha_h := 0.07*exp((-1)*(v(t) + 65.0)/20.0);
beta_h := 1/(1.0 + exp((-v(t) + 35.0)/10.0));

dsys1 := {diff(h(t), t) = alpha_h*(1 - h(t)) - beta_h*h(t), diff(m(t), t) = alpha_m*(1 - m(t)) - beta_m*m(t), diff(n(t), t) = alpha_n*(1 - n(t)) - beta_n(t), diff(v(t), t) = III - gK*n(t)^4*(v(t) - VK) - gNa*m(t)^3*h(t)*(v(t) - VNa) - gL*(v(t) - VL), h(0) = 0.9996937394, m(0) = 0.02890553447, n(0) = 0.2445865495, v(0) = -70};

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!

Hello Everyone;

Can anybody help me to solve the analytical solution of the following ODE?
AAS := C*diff(y(t), t) + (-B0*y(t)^3 - B1*y(t)^2 - B2*y(t) - B3);y[0] := 1

C,B0,B1,B2 are constants.

Dear Maple experts,

I am running a Maple code with several lines/ curves in a plot.

For two of the curves, I use style=pointline. But in the legend the symbols on the lines are not shown. Can you advise how we can make them appear?

I have attached the file. Thank you so much! 

Download LegendPlot.mw

Hello Everyone;

I need to solve the following nonlinear ODE

C*diff(y(x), x) + (-B0*y(x)^3 - B1*y(x)^2 - B2*y(x) - B3) = 0, y(0)=B4

where B0,B1,B2,B3 and B4 are constants. I am trying in Maple 2021, but receiving solution in the form of integral. Is that any other ways that I will be able exact solution. Maple sheet is atatched. I am waiting for your kind respose.

Thanks

Question1.mw

restart

 

infolevel[dsolve] := 4

4

(1)

ode22 := C*(diff(y(x), x))-B0*y(x)^3-B1*y(x)^2-B2*y(x)-B3 = 0

C*(diff(y(x), x))-B0*y(x)^3-B1*y(x)^2-B2*y(x)-B3 = 0

(2)

solll := dsolve(ode22, implicit, useInt)

Methods for first order ODEs:

 

--- Trying classification methods ---

 

trying a quadrature

 

trying 1st order linear

 

trying Bernoulli

 

trying separable

 

<- separable successful

 

x-Intat(C/(B0*_a^3+B1*_a^2+B2*_a+B3), _a = y(x))+_C1 = 0

(3)

ode[257] := C*(diff(y(x), x))-B0*y(x)^3-B1*y(x)^2-B2*y(x)-B3 = 0

C*(diff(y(x), x))-B0*y(x)^3-B1*y(x)^2-B2*y(x)-B3 = 0

(4)

dsolve(ode[257], implicit)

Methods for first order ODEs:

 

--- Trying classification methods ---

 

trying a quadrature

 

trying 1st order linear

 

trying Bernoulli

 

trying separable

 

<- separable successful

 

x-Intat(C/(B0*_a^3+B1*_a^2+B2*_a+B3), _a = y(x))+_C1 = 0

(5)

NULL

Download Question1.mw

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

I am currently unable to type in maple 2021, there is no cursor, nothing shows up when I type etc. I am also unable to save files. I went into document mode, nothing. Some of the dialogs don't show up. Where does maple save documents and how do I change that setting? That might be my problem. Furthermore, there are no tabs visable, like I can't access any documents I open.

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?

aRandStep2D := proc(X0, Y0, dx, dy)
  local X, Y, P, R;
  P := Array(1 .. 2);
  R := rand(1 .. 8)();
  if R = 1 then X := X0 - dx; Y := Y0 + dy; end if;
  if R = 2 then X := X0; Y := Y0 + dy; end if;
  if R = 3 then X := X0 + dx; Y := Y0 + dy; end if;
  if R = 4 then X := X0 - dx; Y := Y0; end if;
  if R = 5 then X := X0 + dx; Y := Y0; end if;
  if R = 6 then X := X0 - dx; Y := Y0 - dy; end if;
  if R = 7 then X := X0; Y := Y0 - dy; end if;
  if R = 8 then X := X0 + dx; Y := Y0 - dy; end if;
  P[1] := X; P[2] := Y;
  return P;
end proc 

SetStart := proc(b)
  local alpha, R, P;
  P := Array(1 .. 2);
  alpha := rand(1 .. b)();
  P[1] := alpha*b;
  P[2] := alpha*b;
  return P;
end proc 

RandomFactTpq := proc(N, pb, dx, dy)
  local alpha, X, Y, f, P, counter, B, n, T;
  P := Array(1 .. 2);
  counter := 0; f := 1;
  B := floor(evalf(sqrt(N))); #Set maximal searching steps
  T := floor(evalf(sqrt(N))); #For SetStart's use
  P := SetStart(T);
  X := P[1]; Y := P[2];
  while f = 1 and counter < B do  #loop
    n := pb - X - Y;
    f := gcd(N, n);
    if f > 1then break; end if;
    P := aRandStep2D(X, Y, dx, dy); #A random move
    X := P[1]; Y := P[2];
    if X < 1 or Y < 1 or N - pb - 1 < X or X <= Y then
      P := SetStart(T);       # Restart when out of borders
      X := P[1]; Y := P[2];
    end if;
    counter := counter + 1;    #Counting the searched steps
  end do;
  if  f>1  then print(Find at point (X, Y), found divisor = f, searching steps = counter);
  else print(This*time*finds*no*result, test*again!); end if;
end proc


wxbRandWalkTpqNew4.pdf

5 6 7 8 9 10 11 Last Page 7 of 40