Ask Your Question

Polynomial: find the common factor

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

alexana gravatar image

updated 2015-01-16 11:12:17 +0200

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:


Thank you everyone!

edit retag flag offensive close merge delete

2 Answers

Sort by » oldest newest most voted

answered 2012-07-04 14:49:48 +0200

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)]
edit flag offensive delete link more

answered 2012-07-04 14:14:24 +0200

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.

y = 2*x^2 + x^3 + 10*x^4
terms=[a[0]*x^a[1] for a in info]
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


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

Seen: 772 times

Last updated: Jul 04 '12