zxm20100129

25 Reputation

One Badge

13 years, 131 days

MaplePrimes Activity


These are questions asked by zxm20100129

I have encountered the problem of extracting multivariable polynomial coefficients, such as using the remove command,

eq2 := 3*p^4*a[2]^2+6*p^2*q^2*a[2]*b[2]+3*q^4*b[2]^2+p^4;
eq2 :=convert(eq2,list);    

eq2 := [3*p^4*a[2]^2, 6*p^2*q^2*a[2]*b[2], 3*q^4*b[2]^2, p^4]

map(t->remove(has,t,{p,q}),eq2);
[3*a[2]^2, 6*a[2]*b[2], 3*b[2]^2, undefined]

eq3 := 3*p^4*a[2]^2+6*p^2*q^2*a[2]*b[2]+3*q^4*b[2]^2;
eq3 :=convert(eq3,list);

map(t->remove(has,t,{p,q}),eq3);

[3*a[2]^2, 6*a[2]*b[2], 3*b[2]^2]

Because the term p ^ 4 similar to power appears, a program should be written to calculate it,      Programming           

extractxishu:=proc(p)           

local i,xishulist,teamlist;           

teamlist:=convert(p,list);           

xishulist:=[]:           

for i in teamlist do           

if type(i,`^`) then           

xishulist:=[xishulist[],1];           

else           

xishulist:=[xishulist[],remove(has,i,{p,q})];          

  end if;           

end do:           

end proc:           

Inspection procedure:         

 eq2 := 3*p^4*a[2]^2+6*p^2*q^2*a[2]*b[2]+3*q^4*b[2]^2+p^4*c[3]+p^3*q*c[3]+6*p^3*a[1]*a[2]+6*p^2*q*a[2]*b[1]+p*q^3*d[3]+6*p*q^2*a[1]*b[2]+q^4*d[3]+6*q^3*b[1]*b[2]+p^4+4*p^3*q+p^3*c[2]+6*p^2*q^2+p^2*q*c[2]+6*p^2*a[0]*a[2]+3*p^2*a[1]^2+6*p^2*a[2]*b[0]+4*p*q^3+p*q^2*d[2]+6*p*q*a[1]*b[1]+q^4+q^3*d[2]+6*q^2*a[0]*b[2]+6*q^2*b[0]*b[2]+3*q^2*b[1]^2+p^2*c[1] +p*q*c[1]+p*q*d[1]+6*p*a[0]*a[1]+6*p*a[1]*b[0]+q^2*d[1]+6*q*a[0]*b[1]+6*q*b[0]*b[1]+p*c[0]+p*d[0]+q*c[0]+q*d[0]+3*a[0]^2+6*a[0]*b[0]+3*b[0]^2            extractxishu(eq2);           

The result is incorrect  , It is found that the command is successful in a separate calculation, but extractxishu is invalid in the program. Why?

  Can any expert tell me where this mistake is? How to modify this program!

In using maple 17, for a for loop, the alias command is valid outside the for loop, but entering the for loop, maple verifies that alias is not recognized.The code is as follows:
with(PDEtools):
for k from 1 to 4 do
alias(u[k]=u[k](x,y,t));
alias(a[k]=a[k](x,y,t));
od:
print(has(a[1],x));
sol:=[]:
for i from 1 to 4 do
sol:=[sol[],a[i]=rhs(isolate(a[i]+diff(a[i],x)+i=0,diff(a[i],x)))];
print(has(a[i],x));
end do;
The output is as follows: thequestionofalias
true
[a[1] = a[1] + 1]
false
[a[1] = a[1] + 1, a[2] = a[2] + 2]
false
[a[1] = a[1] + 1, a[2] = a[2] + 2, a[3] = a[3] + 3]
false
[a[1] = a[1] + 1, a[2] = a[2] + 2, a[3] = a[3] + 3, a[4] = a[4] + 4]
false
Why is it outside the loop? A [1] ... A [4] has the variable x, but either a [ I ] or a [1] has no variable X.Send the question to the Forum and see which expert can answer it. See how you can make the alias command work inside a for loop! I'd appreciate it if you could answer that!

A question about the alias command: Can the abbreviation u[k] of the function call u[k](x, y) be implemented by the alias command, so that the type of u[k] is a function for any integer K?

example:
alias(F[k]=F[k](x));
output:F[k].
whattype(F[k]);
output:function
whattype(F[1]);
output:indexed
I want f[k] to be a function for any integer K. how to implement it? If there are experts to see this question to help answer, will be very grateful!

 

Page 1 of 1