       Re: Re: Polynomial rewriting question

• To: mathgroup at smc.vnet.net
• Subject: [mg101457] Re: [mg101421] Re: Polynomial rewriting question
• From: Daniel Lichtblau <danl at wolfram.com>
• Date: Wed, 8 Jul 2009 07:07:48 -0400 (EDT)
• References: <h2i4q2\$93f\$1@smc.vnet.net> <200907070904.FAA21983@smc.vnet.net>

```Leonid wrote:
> Hi Andrew,
>
> One simple way is to substitute x= t+y and then call Simplify:
>
> In =
> Clear[p1,p2,p3,x,y,z,w,p,h];
> p1 = x*z - y*z;
> p2 =  x^2*w - 2*x*y*w + y^2 w + p;
> p3 =  2*s + h + x - y;
>
> In = Simplify[# /. x -> t + y] & /@ {p1, p2, p3}
>
> Out = {t z,p+t^2 w,h+2 s+t}
>
> Whether or not this will be useful in your setting I don't know -
> depends on how complex is the real problem. For polynomials this
> should
> work.
>
> Regards,
> Leonid
>
>
> On Jul 2, 4:14 am, AndrewTamra <AndrewTa... at yahoo.com> wrote:
>> Consider the following polynomials: Here x,y,z,w,h are variables; rest are constants.
>> (1) x*z-y*z, (2) x^2*w -2*x*y*w +y^2w + p, (3) 2*s+h+x-y
>>
>> When we look closely at these, we notice that everywhere x and y occur, they occur as "x-y". Suppose we let t= x-y, then we can rewrite the above polynomials as (1) tz (2) t^2*w (3) 2*s+h+t.
>>
>> How can do this in Mathematica? i.e., given the above 3 polynomials and the set of variables as input, I should get output of "x-y" and the 3 rewritten polynomials  tz, t^2*w, 2*s+h+t.
>>
>> Note that the above is an example. When I apply the program to any arbitrary and large number of polynomials, in place of "x-y" above, I would like to get the largest polynomial (maximum number of monomial terms) with as many variables in it as possible.
>>
>> Thanks a lot.
>> Andrew.
>

I somehow missed the original post (and cannot seem to locate it via the
MathGroup archives or Google groups, which might just be ineptness on my
part). Anyway, automating this process is hit-or-miss at best. Can be
attempted using FullSimplify and Experimental`OptimizeExpression, as below.

In:= InputForm[Experimental`OptimizeExpression[
FullSimplify[{x*z-y*z, x^2*w -2*x*y*w +y^2w + p, 2*s+h+x-y}],
OptimizationLevel->2]]

Out//InputForm=
Experimental`OptimizedExpression[Block[{Compile`\$1, Compile`\$2,
Compile`\$4},
Compile`\$1 = -y; Compile`\$2 = x + Compile`\$1; Compile`\$4 = Compile`\$2^2;
{Compile`\$2*z, p + w*Compile`\$4, h + 2*s + x + Compile`\$1}]]

FullSimplify will (sometimes) manage to get its teeth into nature of the
x-y appearances e.g. in partial factorization, and then the expression
optimization might use this in common subexpression elimination.

Daniel Lichtblau
Wolfram Research

```

• Prev by Date: Re: Re: including specific values in parametric plots
• Next by Date: Re: Pattern matching / subsequence matching, question
• Previous by thread: Re: Polynomial rewriting question
• Next by thread: Re: Polynomial rewriting question