Re: Re: Q: Factor with Polynominals?

*To*: mathgroup at smc.vnet.net*Subject*: [mg27039] Re: [mg26985] Re: Q: Factor with Polynominals?*From*: Andrzej Kozlowski <andrzej at tuins.ac.jp>*Date*: Thu, 1 Feb 2001 03:00:26 -0500 (EST)*Sender*: owner-wri-mathgroup at wolfram.com

Actually, I just realized how to make PolynomialFactore do exactly what you wanted (I think). Here is the improved code: PolynomialFactor[f_, g_] := Block[{v}, Simplify[If[PolynomialReduce[f, g][[1, 1]] === 0, PolynomialReduce[f, g][[2]], PolynomialFactor[PolynomialReduce[f, g][[1, 1]], g]*g + PolynomialReduce[f, g][[2]]] /. g -> v] /. v -> g] Now: In[3]:= PolynomialFactor[3 x^2 + 3 y^2 + x + y^3 + y x^2, x^2 + y^2] Out[3]= 2 2 x + (3 + y) (x + y ) In[4]:= PolynomialFactor[Expand[(x^2 + y^2)^4 + y (x^2 + y^2) + y], x^2 + y^2] Out[4]= 2 2 2 2 4 y + y (x + y ) + (x + y ) Try it on your other examples. -- Andrzej Kozlowski Toyama International University JAPAN http://platon.c.u-tokyo.ac.jp/andrzej/ http://sigma.tuins.ac.jp/ on 01.1.31 8:04 PM, Andrzej Kozlowski at andrzej at tuins.ac.jp wrote: > I have found a bit of time to consider your problem more carefully and I > concluded that while in principle what you want done is quite easy, there > seems to be an ambiguity in what you call "factoring a polynomial". > > Here is the function which will produce the output you wanted in the first > case, while in your second case it will essentially the same output: > > PolynomialFactor[f_, g_] := > If[PolynomialReduce[f, g][[1, 1]] === 0, PolynomialReduce[f, g][[2]], > PolynomialFactor[PolynomialReduce[f, g][[1, 1]], g]*g + > PolynomialReduce[f, g][[2]]] > > Here is what happens with your two examples: > > In[2]:= > PolynomialFactor[3 x^2 + 3 y^2 + x + y^3 + y x^2, x^2 + y^2] > > Out[2]= > x + (3 + y)*(x^2 + y^2) > > This is just what you wanted. > > In[3]:= > PolynomialFactor[Expand[(x^2 + y^2)^4 + y (x^2 + y^2) + y], x^2 + y^2] > > Out[3]= > 2 2 2 2 3 > y + (x + y ) (y + (x + y ) ) > > This looks somewhat different, but actually that's because it is factored more > deeply than you asked for. This sort of problem will occur in other examples, > e.g. > > In[15]:= > PolynomialFactor[(1 + x^2)^2*(x + 3) + (1 + x^2)*(x - 3), 1 + x^2] > > Out[15]= > 2 2 > (1 + x ) (-3 + x + (3 + x) (1 + x )) > > Again, this is factored further than is the case in your examples. One can > probably fix it with some further programming but quite frankly I do not think > it is worth the effort, having got to this point it should be easy to > re-arrange things by hand.