Ask Your Question
0

Polynomial: find the common factor

asked 12 years ago

alexana gravatar image

updated 10 years ago

FrédéricC gravatar image

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!

Preview: (hide)

2 Answers

Sort by » oldest newest most voted
1

answered 12 years ago

Volker Braun gravatar image

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)]
Preview: (hide)
link
0

answered 12 years ago

calc314 gravatar image

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)
Preview: (hide)
link

Your Answer

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

Add Answer

Question Tools

Stats

Asked: 12 years ago

Seen: 918 times

Last updated: Jul 04 '12