Path: news.mathworks.com!not-for-mail
From: Alan Weiss <aweiss@mathworks.com>
Newsgroups: comp.soft-sys.matlab
Subject: Re: a problem about symbolic polynomial.
Date: Mon, 29 Dec 2008 14:20:54 -0500
Organization: The MathWorks, Inc.
Lines: 61
Message-ID: <gjb7um$col$1@fred.mathworks.com>
References: <gjak3a$gh6$1@fred.mathworks.com>
NNTP-Posting-Host: weissa.dhcp.mathworks.com
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
X-Trace: fred.mathworks.com 1230578454 13077 172.31.57.119 (29 Dec 2008 19:20:54 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Mon, 29 Dec 2008 19:20:54 +0000 (UTC)
User-Agent: Thunderbird 2.0.0.18 (Windows/20081105)
In-Reply-To: <gjak3a$gh6$1@fred.mathworks.com>
Xref: news.mathworks.com comp.soft-sys.matlab:509129


zedong wrote:
> I have a polygon:
> for example:
> syms x y x0 x1 x2 y0 y1 y2
> f=-1.0/12.0*x*(3*x*x*x*y2*y2*y0-3*x*x*x*y0*y0*y2-3
> *x*x*x*y0*y1*y1+12*y*y*y*x0*x1*x1+12*y*y*y*x0*x0*x
> 2-12*y*y*y*x0*x0*x1+12*y*y*y*x2*x2*x1-12*y*y*y*x2*
> x1*x1-12*y*y*y*x2*x2*x0-3*x*x*x*y2*y2*y1+3*x*x*x*y
> 2*y1*y1+3*x*x*x*y0*y0*y1+12*x2*x2*y0*x0*y1*y1+12*x
> 2*y0*y0*x1*x1*y2-12*x2*x2*y0*y0*x1*y1+12*x2*x2*y0*
> y0*x1*y-12*x2*y0*y0*x1*x1*y-24*x2*x2*y0*y*y*x1+24*
> x2*y0*y*y*x1*x1+12*x2*x2*y0*y*y*x0+12*y2*y2*x0*x0*
> y1*x1-12*y2*x0*x0*y1*y1*x2-12*y2*y2*x0*y0*x1*x1+12
> *y2*y2*x0*y*x1*x1-24*y2*x0*y*y*x1*x1-12*y2*y2*x0*x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y1+12
> *x*y2*y2*x0*y0*x1-12*x*x2*y0*y0*x1*y2-8*x*x*y*x0*y
> 0*y1+8*x*x*y*x2*y1*y2-8*x*x*y*x2*y0*y2+8*x*x*y0*y*
> x1*y1+8*x*x*y*x0*y0*y2+12*x*y*y*x2*x0*y2-12*x*y2*y
> 2*x0*y1*x1+12*x*y2*x0*y1*y1*x2-12*x*y*y*x0*y0*x2+1
> 2*x*x2*y0*y0*x1*y1-12*x*y*y*x0*x1*y1-12*x*y*y*x2*x
> 1*y2+12*x*y*y*x2*x1*y1+12*x*y*y*x0*y0*x1+24*x*x2*y
> 0*y*x1*y2-24*x*x2*y0*y*x1*y1+24*x*x2*y0*y*x0*y1+24
> *x*y2*x0*y*x1*y1-24*x*y*x0*y0*x1*y2-24*x*y*x2*x0*y
> 1*y2)
> 
> 
> It's very complex.
> Can I make it in x y order.
> 
>    (for example:
>        f=x*y*x0+x*y*x1+x*x*x2+x*x*y2;
>      I want to return:
>       f=(x0+x1)*xy+(x2+y2)*x^2
>       )

doc collect

In your example,
g = collect(f,x)

Alan Weiss
MATLAB mathematical toolbox documentation