Items tagged with collect collect Tagged Items Feed

Why does the collect command work for some expressions and not for others. Here is a screen shot

 The collect command is supposed to rewrite the expression in terms of the variable descending order.

p := expand((a^2+2*x)*(a^2+2*x));
                        4      2        2   2
                       a  + 4 a  x + 4 x

collect(p, x);
                        4      2        2   2
                       a  + 4 a  x + 4 x

Does not work.

But if you look at the screenshot , it works for other expressions.

I am using Maple-9 to simplify the expression and the expression is not having numerical coefficients. Example expression is given below.



The question here is: I want to collect all "positive terms" and "negative terms" and assign to new variable.


Please suggest steps for the above problem


Thank you in advance.


I have the following equation

phi = -arctan(sin(2*theta)*(cos(beta)-1)/(cos(beta)*cos(2*theta)-cos(2*theta)-cos(beta)-1))+theta;

phi = -arctan(sin(2*theta)*(cos(beta)-1)/(cos(beta)*cos(2*theta)-cos(2*theta)-cos(beta)-1))+theta


In the denominator I wish to collect the two cos(2*theta) terms  into a single term, as in



Is there a straighforward way of doing it?



in the worksheet i attached how can i collect  terms which include 1/w and 1/w^2 only ?


best regards


I am trying separation of variables in Maple. I get an equation that has the form   

And now I want to tell Maple to assign the terms with 1/R in them to one variable, say eq21, and the term with 1/Z to second variable, say eq22 The idea is that I can later more easily work with each separate ode. 

I do not know to separate those apart. I could offcourse copy and paste by hand, but I want to automate this.

I tried match() and patmatch() but I am not seeing the way. Here is the code:

T:=  (r,z)-> Z(z)*R(r);
eq1:= diff(T(r,z),r$2)+1/r*diff(T(r,z),r)+diff(T(r,z),z$2);

#need now way to break the above into 2 different variables.

ps. I know I can do this:

T:=  (r,z)-> Z(z)*R(r);
eq1:= diff(T(r,z),r$2)+1/r*diff(T(r,z),r)+diff(T(r,z),z$2);

But this for me is not the right way to do it. I think there should be more algebraic way.


Hi all,

Command collect can view a expression a as a general polynomial in specific indeterminate x with the calling sequence:

collect(a, x, form, func)

where form and func are optional arguments.


Then, I encountered a form like this:

collect(a, x, normal)


I'm not sure what does normal means in this case and cannot find the related information from Maple Help.

Does anyone know this? I'd appreciate any help on this topic.

Thanks a lot :)

(Sorry to not offer the worksheet file due to a private issue)

Hi ;

I need your help to write the system contains all these equation:

# system 1
# system 2
for j from 1 to N do
u[0, j] := (1/4)*(u[1,j]+u[1,j]+u[0, j-1]+u[0,j+1]-f[0,j]*h^2);
end do;
# System 3
for j from 1 to N do
u[N+1, j] := (1/4)*(u[N, j]+u[N-1,j]+u[N+1, j-1]+u[N+1, j+1]-f[N+1,j]*h^2);
end do;
 eqs := [ seq(seq(Stencil[1](h,i,j,u,f),i=1..N),j=1..N)];

How can collect these system 1 system2, system3 ans system4 in a set with one name.

sys:=[eqs,system3,system2,system2]; ( sys: here contains all the equation).

Thanks you.


Hi, please a Need a help.
I have an error in my code: Error, (in collect) cannot collect 0
Here, is the code:

Many thinks.


I gave this function:

g := -2-k[1](lambda*alpha[2]*k[2]+alpha[1](-2-2*k[2]+k[2]*lambda^2))+k[1](lambda*alpha[2]*k[2]+alpha[1](-2-2*k[2]+k[2]*lambda^2))*lambda(lambda*alpha[2]*k[2]+alpha[1](-2-2*k[2]+k[2]*lambda^2))^2

I would like to factor out or to collect:   (lambda*alpha[2]*k[2]+alpha[1](-2-2*k[2]+k[2]*lambda^2))

I use following command: collect(g, lambda*alpha[2]*k[2]+alpha[1](-2-2*k[2]+k[2]*lambda^2))

Nevertheless, I receive an error ...

Error, (in collect) cannot collect lambda*alpha[2]*k[2]+alpha[1](-2-2*k[2]+k[2]*lambda^2)


Could you help me to solve my issue ? 

What am I doing wrong ? Do I have to use another command for this ?

I would like to thank you in advance.

Best regards,




Say I have an expression like this:


I can factor out x,t and get an expected result:
collect(a0, [x,t]);

But how would I do it if I want to force Maple to act on the argument of exp?


This doesn't work:
collect(a1, [x,t])

This will do what I want for this expression but maybe not in general:

i have a problem in using command "collect".  

how to evaluate to equation (5.9) in page 195 from rodrigues formula?

rodrigues := exp(x)*(x^alpha)/n!*Diff(exp(-x)*(x^(n+alpha)), x$n);
rodrigues := subs(x=2*p, rodrigues);
rodrigues := subs(alpha=1/2, rodrigues);

Hi, this  must have been asked numerous time, but I cannot find it in MaplePrimes:

How does one "collect" sqrt terms? collect(expression,sqrt) does not work because sqrt is actually represented as ^(1/2) in  Maple. collect on '^' does not work either... ??

Mac Dude

Hello everyone,

I like to force following:

a/(a+b) --->  1/(1+b/a)

I know that collect is a powerful tool that is actually capable of doing such things. In a similar (old) thread, it was suggested to use a function in the last part like

collect(expression, varialble, (x->something)@factor)

but I don't understand what exactly this means. Any help?

another related question is, is the collect command available as right-click option?

I have a rather large multivatiate polynomial "Dtest"  I need to divie it by a cubic poly "DGm" using rem and quo. Both are determinants multiplied out,  both given below. Have spent the past 2 nights trying to sort, collect, expand, equate coefficients plex groebner etc. Am trying to collect up all the powers of c3 but cant anything to work. even expand doesn't fully expand "Dtest". If I set c1 and c2 to 1 things are...

1 2 Page 1 of 2