Basak

15 Reputation

2 Badges

6 years, 190 days

MaplePrimes Activity


These are questions asked by Basak

Hi,

I get the error message "Error, invalid input: diff expects 2 or more arguments, but received 1" from the following program. Could you please help me? Thank you i,n advance for your help!

som:=0:

for b1 from 10 to 10 by 1 do
for b2 from 1 to 2 by 1 do
for alpha from 0.5 to 0.5 by 0.1 do
for beta from 0.33 to 0.5 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 1 to 10 by 0.1 do
for lambdaj from 0.2 to 0.4 by 0.1 do
for gammaj from 0.2 to 0.4 by 0.1 do

p:='p';

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;
UTSQ:=UiSQ+UjSQ+USQ;

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

aineg:=-(alpha*b2*f*lambdaj*p+b2*f*lambdaj*p+alpha*b1*c+b1*c)/(c*(alpha*b2*lambdaj-2*alpha*b2-b2*beta+b2*lambdaj-2*b2-c));
ajneg:=(alpha*b2*f*lambdaj*p+alpha*b1*c*lambdaj+b2*f*lambdaj*p+c*f*lambdaj*p-alpha*b1*c-b1*beta*c+b1*c*lambdaj-b1*c)/(c*(alpha*b2*lambdaj-2*alpha*b2-b2*beta+b2*lambdaj-2*b2-c));
uj:=beta*(b1*(aineg+ajneg)-(b2/2)*(aineg+ajneg)^2)-(c/2)*ajneg^2-p*f*(ajneg-aj);
uL:=(alpha+1)*(b1*(aineg+ajneg)-(b2/2)*(aineg+ajneg)^2)-(c/2)*aineg^2+p*f*(ajneg-aj);
eqtj:=gammaj*(uL-USQ)-((1-gammaj)/(1-lambdaj))*(uj-UjSQ)-tj;
tj:=solve(eqtj,tj);

dai:=diff(ai,p);
daj:=diff(aj,p);
daineg:=diff(aineg,p);
dajneg:=diff(ajneg,p);
dtj:=diff(tj,p);
Ujp:=beta*(b1*(ai+aj)-(b2/2)*(ai+aj)^2)-(c/2)*aj^2-p*f*(ajneg-aj)+(1-lambdaj)*tj;
ULp:=(alpha+1)*(b1*(ai+aj)-(b2/2)*(ai+aj)^2)-(c/2)*ai^2+p*f*(ajneg-aj)-tj-g*((p^2)/2);
eqp:=diff(ULp,p);
eqpp:=diff(eqp,p);
p:=solve(eqp,p);

CSQ:=b1-b2*(aiSQ+ajSQ);
Cabat:=b1-b2*(ai+aj);
Cneg:=b1-b2*(aineg+ajneg);

if (ai>aineg) then f*(aineg-ai)=0
else if (aj>ajneg) then f*(ajneg-aj)=0
else if (CSQ>0 and Cabat>0  and Cneg>0 and eqpp<0 and p>0 and p<1 and beta<alpha and aiSQ>0 and ajSQ>0 and ai>0 and aj>0 and aineg>0 and ajneg>0 and tj>0)
then
#print(b1,b2,alpha,beta,c,f,g,lambdaj,gammaj,p);
som:=som+1;
fi;fi;fi;
od;od;od;od;od;od;od;od;od;
som;
 

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

Hi,

I am writing a simple program on Maple with the command :

som:=0;

for a from 3000 to 5000 by 100 do

for b from 100 to 1000 by 100 do

for c from 3000 to 3000 by 100 do

for d from 1000 to 1000 by 100 do

for e from 1000 to 10000 by 1000 do

for f from 200 to 2000 by 100 do

for p from 1 to 10 by 1 do

tot:=0;

 

C2:=c*d-N^2*(f^2-b*d);

C3:=a*d-e*f;

C4:=c*e-N^2*(a*f-e*b);

 

if (C2>0 and C3>0 and C4>0)

then

print(a,b,c,d,e,f,p);

som:=som+1;

fi;

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

som;

 

That gives me the error messsage: Error, numeric exception: division by zero

Is there a simple way to say to the program to continue to execute even it falls at some point to « bad » parameter constellations with division by zero ?

Thank you for your help !

Best regards,

Basak

Hi,

I would like to ask a very basic question. The solution would indeed simplify my life!

I have a function called (eu) :

eu := -2*n^2*B^2+2*n*B^2*p-2*n*B^2*p^2+n*B^2-B^2*p+B^2*p^3+n*c*d

I would like to collect it with respect to two specific terms: (n-p+p^2) and (n-p+p^3), that would give me at the end:

eu := -2*n*B^2*(n-p+p^2)+B^2*(n-p+p^3)+n*c*d

Collect command gives me the following error meesage: "Error, (in collect) cannot collect n-p+p^2".

Would you have a solution for this problem?

Thanks in advance.

Basak

Page 1 of 1