Ask Your Question
0

Polynomial: find the common factor

asked 2012-07-04 03:25:29 -0500

alexana gravatar image

updated 2015-01-16 04:12:17 -0500

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!

edit retag flag offensive close merge delete

2 answers

Sort by » oldest newest most voted
1

answered 2012-07-04 07:49:48 -0500

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
0

answered 2012-07-04 07:14:24 -0500

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)
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

Stats

Asked: 2012-07-04 03:25:29 -0500

Seen: 255 times

Last updated: Jul 04 '12