# [Maxima] poly of pow 2

Barton Willis willisb at unk.edu
Thu Nov 29 06:13:22 CST 2007

```Maybe I don't understand 'divide,' but for polynomials in two or more
variables, divide sometimes gives a quotient that is non-polynomial
(rational function). This is a problem for 'sfactor.' Maybe I could switch
to
poly_pseudo_divide (defined in grobner) or it's equivalent (is there
another such function?)

Example: Let p and q be the polynomials

(%i81) p;
(%o81) -256*y^3-(8448*x-46176)*y^2-(16-15168*x)*y+16*x+1

(%i82) q;
(%o82) 120*x*y-43*x

Let's divide p by q. All these quotients are non-polynomial:

(%i83) divide(p,q,x);
(%o83) [-(8448*y^2-15168*y-16)/(120*y-43),-256*y^3+46176*y^2-16*y+1]
(%i84) divide(p,q,x,y);
(%o84) [-(7200
*y^2+(237600*x-1296120)*y-341460*x-463993)/(3375*x),(14736780*x+19955074)/3375]

(%i85) divide(p,q,y,x);
(%o85) [-(8448*y^2-15168*y-16)/(120*y-43),-256*y^3+46176*y^2-16*y+1]

BW

-----maxima-bounces at math.utexas.edu wrote: -----

>To: Daniel Lakeland
>From: Barton Willis
>Sent by: maxima-bounces at math.utexas.edu
>Date: 11/28/2007 04:59PM
>cc: maxima at math.utexas.edu
>Subject: Re: [Maxima] poly of pow 2
>
>-----maxima-bounces at math.utexas.edu wrote: -----
>
>>To: maxima at math.utexas.edu
>>From: Daniel Lakeland
>>Sent by: maxima-bounces at math.utexas.edu
>>Date: 11/28/2007 02:00PM
>>Subject: Re: [Maxima] poly of pow 2
>>
>
>>What's wrong with it? Apparently it's useful enough that two different
>>people have asked for it within a few months.
>
>At least for polynomials in several variables, sfactor is buggy.
>Here is a variant of sfactor (that is I suppose also buggy).
>
>(%i52) nfactor(p,x) := block([n, cf, s, d],
>  p : expand(p),
>  n : hipow(p,x),
>  (if n <= 1 then p else (
>    cf : coeff(p,x,n),
>    s : x,
>    d : expand(cf * s^n - p),
>    while hipow(d,x) > 0 do (
>       d : expand(first(divide(cf * s^n - p, n * cf * s^(n-1)))),
>       s : s - d),
>     cf * s^n + nfactor(p - cf * s^n,x))))\$
>
>sfactor(p,x) := block([n, cf, s, d],
>  p : expand(p),
>  n : hipow(p,x),
>  if oddp(n) or n = 0 then p else (
>   cf : coeff(p,x,n),
>   s : x^(n/2),
>   d : expand(cf * s^2 - p),
>   while hipow(d,x) > 0 do (
>     d : expand(first(divide(cf * s^2 - p, 2 * cf * s))),
>     s : s - d),
>   cf * s^2 + sfactor(p - cf * s^2,x)))\$
>
>(%i54) p : x^4 + x^3 + x^2+x+1\$
>
>(%i55) nfactor(p,x);
>(%o55) (5*(x+3/4)^2)/8+(x+1/4)^4+165/256
>
>(%i56) sfactor(p,x);
>(%o56) (x^2+x/2+3/8)^2+(5*x)/8+55/64
>
>(%i57) p : expand((x-y)^4 + (x+6*y)^2 + 1)\$
>
>(%i58) nfactor(p,x);
>(%o58) (6*y+x)^2+(x-y)^4+1
>
>Yikes! Seems to endlessly loop....
>
>(%i59) sfactor(p,x);
>
>I understand what's going on, but I don't know the cure.
>
>BW
>_______________________________________________
>Maxima mailing list
>Maxima at math.utexas.edu
>http://www.math.utexas.edu/mailman/listinfo/maxima
```