Ask Your Question

# Polynomial: find the common factor

Hello, assuming I have a polynomial like this:

sage: var('y, x')
(y, x)
sage: y = x^2 + 6*x^3 + 3*x^4


When I use collect_common_factors(), I get:

(3*x^2 + 6*x + 1)*x^2


Now, is there a way to know which are the common_factors collected?

In this case, I'm expecting this output:

x^2


Thank you everyone!

edit retag close merge delete

## 2 Answers

Sort by » oldest newest most voted

If are dealing with polynomials only you should look into using polynomial rings.

sage: R.<x> = QQ[]
sage: y = x^2 + 6*x^3 + 3*x^4
sage: y.factor()
(3) * x^2 * (x^2 + 2*x + 1/3)
sage: list(_)
[(x, 2), (x^2 + 2*x + 1/3, 1)]

more

I can't find a specific function to get the terms out of a polynomial, but here is some code that should do the job for a function just of x.

var('x,y')
y = 2*x^2 + x^3 + 10*x^4
info=y.coeffs()
terms=[a[0]*x^a[1] for a in info]
gcd(terms)

more

## Your Answer

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

Add Answer

## Stats

Asked: 2012-07-04 10:25:29 +0200

Seen: 772 times

Last updated: Jul 04 '12