Ask Your Question

Computing square free part of a multivariate polynomial

asked 2017-02-28 14:49:14 -0500

KittyL gravatar image

updated 2017-02-28 14:52:38 -0500

In one of the algorithms I am working on, there is a part asking for the square-free part of a multivariate polynomial. I can find it using a complicated way, namely,

I = ideal(f)
IRad = I.radical().groebner_basis()

But I think this must be a very inefficient way to do it. Is there a better way? Thank you!

edit retag flag offensive close merge delete


Could you provide a way to construct some interesting f ?

tmonteil gravatar imagetmonteil ( 2017-02-28 15:49:47 -0500 )edit

Do you mean an example? For example, if f is in Q[x,y,z], then f could be (x-y)^2*(y-z)^2*(x+y+3). Then the square free part would be (x-y)*(y-z)*(x+y+3).

KittyL gravatar imageKittyL ( 2017-02-28 16:53:33 -0500 )edit

1 answer

Sort by ยป oldest newest most voted

answered 2017-03-20 16:38:49 -0500

dan_fulea gravatar image

Solution by example. Suppose we want to associate for the special polynomial $f$ from

R.<x,y,z> = QQ[]
f = (x+y+z)^3 * (x^2+y^3+z^4)^7

the polynomial g, which is the product of the two prime factors, taken each to the power one. The one-liner does the job, we require a successful factorization:

g = prod( [ factor for (factor,power) in f.factor() ] )


sage: R.<x,y,z> = QQ[]
sage: f = (x+y+z)^3 * (x^2+y^3+z^4)^7
sage: g = prod( [ factor for (factor,power) in f.factor() ] )
sage: g
x*z^4 + y*z^4 + z^5 + x*y^3 + y^4 + y^3*z + x^3 + x^2*y + x^2*z
sage: g.factor()
(x + y + z) * (z^4 + y^3 + x^2)

Some more lines that play with the factorization instance:

sage: fi = f.factor()
sage: type( fi )
<class 'sage.structure.factorization.Factorization'>

sage: fi[0]
(x + y + z, 3)
sage: fi[1]
(z^4 + y^3 + x^2, 7)
sage: # fi[2]    # -> error, so there should be something to get the full information.

sage: type( fi[0] )
<type 'tuple'>

sage: # how many factors there are?
sage: len( fi )
sage: # the above uses the iterator of fi,
sage: for factor, power in fi:
....:     print factor, power
x + y + z 3
z^4 + y^3 + x^2 7
sage: # alternatively:
sage: for factor in fi:    print factor
(x + y + z, 3)
(z^4 + y^3 + x^2, 7)
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2017-02-28 14:49:14 -0500

Seen: 45 times

Last updated: Mar 20