Hi,

I would like to ask you a question on the following program. Where does the error come from?

Thank you for your help in advance.

som:=0:

for b1 from 10 to 20 by 1 do

for b2 from 1 to 10 by 0.1 do

for alpha from 0.5 to 0.9 by 0.1 do

for beta from 0.1 to 0.4 by 0.1 do

for c from 1 to 1 by 1 do

for f from 1 to 10 by 1 do

for g from 8 to 470 by 1 do

for lambdai from 0.2 to 0.2 by 0.1 do

for lambdaj from 0.2 to 0.2 by 0.1 do

for gammai from 0.4 to 0.4 by 0.1 do

for gammaj from 0.4 to 0.4 by 0.1 do

aiSQ:=(alpha*b1)/(alpha*b2+beta*b2+c);

ajSQ:=(beta*b1)/(alpha*b2+beta*b2+c);

UiSQ:=(1/2)*alpha*b1^2*(alpha^2*b2+2*alpha*beta*b2+c*alpha+beta^2*b2+2*beta*c)/(alpha*b2+beta*b2+c)^2;

UjSQ:=(1/2)*beta*b1^2*(alpha^2*b2+2*alpha*beta*b2+2*c*alpha+beta^2*b2+beta*c)/(alpha*b2+beta*b2+c)^2;

USQ:=(1/2)*b1^2*(alpha+beta)*(alpha*b2+beta*b2+2*c)/(alpha*b2+beta*b2+c)^2;

ai:=(c*b1*alpha+c*p*f+p*f*beta*b2-alpha*b2*p*f)/(c*(alpha*b2+beta*b2+c));

aj:=(-p*f*beta*b2+alpha*b2*p*f+c*beta*b1+c*p*f)/(c*(alpha*b2+beta*b2+c));

aineg:=(-p*f*lambdai*b2*beta+c*b1-c*b1*lambdai+b2*p*f*lambdaj+b2*alpha*p*f*lambdaj-p*f*lambdai*b2+c*b1*alpha-c*p*f*lambdai)/(c*(b2*alpha-b2*lambdai+b2*beta-b2*lambdaj+c+2*b2));

ajneg:=-(b2*alpha*p*f*lambdaj-p*f*lambdai*b2-p*f*lambdai*b2*beta+b2*p*f*lambdaj+c*p*f*lambdaj-c*b1-c*beta*b1+c*lambdaj*b1)/(c*(b2*alpha-b2*lambdai+b2*beta-b2*lambdaj+c+2*b2));

ui:=alpha*(b1*(aineg+ajneg)-(b2/2)*(aineg+ajneg)^2)-(c/2)*aineg^2-p*f*(aineg-ai);

uj:=beta*(b1*(aineg+ajneg)-(b2/2)*(aineg+ajneg)^2)-(c/2)*ajneg^2-p*f*(ajneg-aj);

u:=(b1*(aineg+ajneg)-(b2/2)*(aineg+ajneg)^2)+p*f*(aineg-ai)+p*f*(ajneg-aj);

eqti:=gammai*(u-tj-USQ)-((1-gammai)/(1-lambdai))*(ui-UiSQ);

eqtj:=gammaj*(u-ti-USQ)-((1-gammaj)/(1-lambdaj))*(uj-UjSQ);

solt:=solve({eqti, eqtj}, {ti, tj});

ti:=subs(solt,ti);

tj:=subs(solt,tj);

dai:=diff(ai,p);

daj:=diff(aj,p);

daineg:=diff(aineg,p);

dajneg:=diff(ajneg,p);

dti:=diff(ti,p);

dtj:=diff(tj,p);

eqp:=(b1-b2*(ai+aj))*(dai+daj)-dti-dtj+f*(aineg-ai)+p*f(daineg-dai)+f*(ajneg-aj)+p*f(dajneg-daj)-g*p=0;

p:=solve(eqp,p);

Uip:=alpha*(b1*(ai+aj)-(b2/2)*(ai+aj)^2)-(c/2)*ai^2-p*f*(aineg-ai)+(1-lambdai)*ti;

Ujp:=beta*(b1*(ai+aj)-(b2/2)*(ai+aj)^2)-(c/2)*aj^2-p*f*(ajneg-aj)+(1-lambdaj)*tj;

Up:=(b1*(ai+aj)-(b2/2)*(ai+aj)^2)+p*f*(aineg-ai)+p*f*(ajneg-aj)-((g^2)/2)*p-ti-tj;

CSQ:=b1-b2*(aiSQ+ajSQ);

Cabat:=b1-b2*(ai+aj);

Cneg:=b1-b2*(aineg+ajneg);

if (CSQ>0 and Cabat>0 and Cneg>0 and beta<alpha and p>0 and p<1)

then

print(b1,b2,alpha,beta,c,f,g,lambdai,lambdaj,`aiSQ=`,aiSQ,`ajSQ=`,ajSQ,`UiSQ=`,UiSQ,`UjSQ=`,UjSQ,`USQ=`,USQ,`ai=`,ai,`aj=`,aj,`aineg=`,aineg,`ajneg=`,ajneg,`ti=`,ti,`tj=`,tj,`p=`,p,`Uip=`,Uip,`Ujp=`,Ujp,`Up=`,Up);

som:=som+1;

fi;

od;od;od;od;od;od;od;od;od;od;od;

som;

10, 1, 0.5, 0.1, 1, 1, 8, 0.2, 0.2, aiSQ=, 3.12500000000000, ajSQ=,

0.625000000000000, UiSQ=, 10.3515625000000, UjSQ=, 2.85156250000000, USQ=,

30.4687500000000, ai=, 3.14314584993738, aj=, 0.667340316520551, aineg=,

4.06068541500626, ajneg=, 2.80826596834794, ti=, 19.2559726892491, tj=,

7.44890809994178, p=, 0.0483889331663441, Uip=, 25.8431760998162, Ujp=,

8.71735374786572, Up=, 2.73962847065372

Error, (in solve) a constant is invalid as a variable, 7.44890809994178, 19.2559726892491

1