[Date Index]
[Thread Index]
[Author Index]
Re: Re: Q: Factor with Polynominals?
*To*: mathgroup at smc.vnet.net
*Subject*: [mg27048] Re: [mg26985] Re: Q: Factor with Polynominals?
*From*: "Allan Hayes" <hay at haystack.demon.co.uk>
*Date*: Thu, 1 Feb 2001 03:00:35 -0500 (EST)
*References*: <B69E204A.A7EF%andrzej@tuins.ac.jp>
*Sender*: owner-wri-mathgroup at wolfram.com
Andrzej,
Following up your idea, I arrived at a kind of Horner transformation:
he[f_, 0, _] = f;
he[0, g_, _] = 0;
he[f_, g_, 0] = f;
he[f_, g_, n_:Infinity] :=
{he[#1, g, n - 1], #2} & @@ Flatten[PolynomialReduce[f, g]].{g, 1}
Examples
he[Expand[(x^2 + y^2)^4 + y (x^2 + y^2) + y], x^2 + y^2]
y + (x^2 + y^2)*(y + (x^2 + y^2)^3)
he[Expand[(x^2 + y^2)^4 + y (x^2 + y^2) + y], x^2 + y^2, 2]
y + (x^2 + y^2)*(y + (x^2 + y^2)*(x^4 + 2*x^2*y^2 + y^4))
he[Expand[(x^2 + y^2)^4 + y (x^2 + y^2) + y], x^2 + y^2, 1]
y + (x^2 + y^2)*(x^6 + y + 3*x^4*y^2 + 3*x^2*y^4 + y^6)
Of course, if we always want to go as far as possible we can simplify the
code:
Clear[he]
he[f_, 0] = f;
he[0, g_] = 0;
he[f_, g_] := {he[#1, g], #2} & @@ Flatten[PolynomialReduce[f, g]].{g, 1}
Allan
---------------------
Allan Hayes
Mathematica Training and Consulting
Leicester UK
www.haystack.demon.co.uk
hay at haystack.demon.co.uk
Voice: +44 (0)116 271 4198
Fax: +44 (0)870 164 0565
----- Original Message -----
From: "Andrzej Kozlowski" <andrzej at tuins.ac.jp>
To: mathgroup at smc.vnet.net
<hay at haystack.demon.co.uk>
Subject: [mg27048] Re: [mg26985] Re: Q: Factor with Polynominals?
> 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.
>
> --
> Andrzej Kozlowski
> Toyama International University
> JAPAN
>
> http://platon.c.u-tokyo.ac.jp/andrzej/
> http://sigma.tuins.ac.jp/
>
>
> on 01.1.31 1:22 PM, Robert at robert.schuerhuber at gmx.at wrote:
>
> >
> >
> > thanks again for your answers!
> > unfortunately your method works with the (rather simple) examples, but
it
> > fails
> > with longer, more complex poynomials.
> > robert
> >
> > Allan Hayes wrote:
> >
> >> Here is a technique that works, with little thought, for both of the
> >> examples given so far in this thread.
> >>
> >> poly = (x^2 + y^2)^4 + y (x^2 + y^2) + y;
> >> poly2 = 3 x^2 + 3 y^2 + x + y^3 + y x^2;
> >>
> >> tf[u___ + a_ b_ + v___ + a_ c_ + w___] := u + a(b + c) + v + w;
> >> tf[z_] := z;
> >>
> >> fs = FullSimplify[poly, TransformationFunctions -> {Automatic, tf},
> >> ComplexityFunction -> (Length[#] &)
> >> ]
> >
> >
> >
>
>
Prev by Date:
**Appending to Lists**
Next by Date:
**Re: Problem with the GaussianQuadratureWeights[n, a, b]**
Previous by thread:
**Re: Re: Q: Factor with Polynominals?**
Next by thread:
**Appending to Lists**
| |