ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Wed, 04 Jul 2012 14:16:26 +0200Polynomial: distribute to greatest common factorhttps://ask.sagemath.org/question/9116/polynomial-distribute-to-greatest-common-factor/Hello, assuming I have a polinomial like this:
sage: var('x, y')
(x, y)
sage: y = 2*x^2 + x^3 + 10*x^4
is there a way to get it simplified applying the distributive property on the greatest common factor?
In this case, the output should be this:
y = x^2 * ( 2 + x + 10*x^2 )
Thank you!Sun, 01 Jul 2012 13:29:49 +0200https://ask.sagemath.org/question/9116/polynomial-distribute-to-greatest-common-factor/Comment by John Palmieri for <p>Hello, assuming I have a polinomial like this:</p>
<pre><code>sage: var('x, y')
(x, y)
sage: y = 2*x^2 + x^3 + 10*x^4
</code></pre>
<p>is there a way to get it simplified applying the distributive property on the greatest common factor? <br/>
In this case, the output should be this:</p>
<pre><code>y = x^2 * ( 2 + x + 10*x^2 )
</code></pre>
<p>Thank you!</p>
https://ask.sagemath.org/question/9116/polynomial-distribute-to-greatest-common-factor/?comment=19461#post-id-19461How about `factor(y)`?Sun, 01 Jul 2012 13:44:34 +0200https://ask.sagemath.org/question/9116/polynomial-distribute-to-greatest-common-factor/?comment=19461#post-id-19461Answer by calc314 for <p>Hello, assuming I have a polinomial like this:</p>
<pre><code>sage: var('x, y')
(x, y)
sage: y = 2*x^2 + x^3 + 10*x^4
</code></pre>
<p>is there a way to get it simplified applying the distributive property on the greatest common factor? <br/>
In this case, the output should be this:</p>
<pre><code>y = x^2 * ( 2 + x + 10*x^2 )
</code></pre>
<p>Thank you!</p>
https://ask.sagemath.org/question/9116/polynomial-distribute-to-greatest-common-factor/?answer=13780#post-id-13780Try:
y.collect_common_factors()
This gives the output you want.
You could also use `factor(y,x^2)` if you know upfront that you want to factor out $x^2$.
Sun, 01 Jul 2012 15:49:45 +0200https://ask.sagemath.org/question/9116/polynomial-distribute-to-greatest-common-factor/?answer=13780#post-id-13780Comment by calc314 for <p>Try:</p>
<pre><code>y.collect_common_factors()
</code></pre>
<p>This gives the output you want.</p>
<p>You could also use <code>factor(y,x^2)</code> if you know upfront that you want to factor out $x^2$.</p>
https://ask.sagemath.org/question/9116/polynomial-distribute-to-greatest-common-factor/?comment=19444#post-id-19444Sometimes it can indeed be hard to find all of the functionality. In this case, I used the command completion in the notebook interface to help me find it. To do this, I typed the polynomial name with a dot afterwards: `y.` Then, I hit the `tab` button. A menu appears with the (many) operations that you can do to this object `y`.Wed, 04 Jul 2012 14:16:26 +0200https://ask.sagemath.org/question/9116/polynomial-distribute-to-greatest-common-factor/?comment=19444#post-id-19444Comment by etuardu for <p>Try:</p>
<pre><code>y.collect_common_factors()
</code></pre>
<p>This gives the output you want.</p>
<p>You could also use <code>factor(y,x^2)</code> if you know upfront that you want to factor out $x^2$.</p>
https://ask.sagemath.org/question/9116/polynomial-distribute-to-greatest-common-factor/?comment=19445#post-id-19445Thank you, `collect_common_factors()` is indeed what I was looking for. It was that easy and I apologize if I couldn't manage to find out myself but it seems this function lacks of documentation or search engine indexing.Wed, 04 Jul 2012 11:10:23 +0200https://ask.sagemath.org/question/9116/polynomial-distribute-to-greatest-common-factor/?comment=19445#post-id-19445