ASKSAGE: Sage Q&A Forum - Individual question feedhttp://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Mon, 21 Jan 2013 03:31:32 -0600Factorizing a polynomial with two variableshttp://ask.sagemath.org/question/9724/factorizing-a-polynomial-with-two-variables/Hi, I would like to factorize the following polynomial in $t$, with an integer indeterminate $n$,
$f_n(t) = 2^n ((n-1)t^n+1)^{n-1} - n^{n-1} t^{(n-1)(n-2)} (t^{n-1} + 1)(t+1)^{n-1}$
I expect it to have a factor of $(t-1)^2$ and hope that after division the polynomial in $t$ would have positive coefficients.
1. Is there any way I can verify this by Sage?
2. I have tried to check that $f_n(t)$ has a factor of $(t-1)^2$ by checking that $f_n(1) = f_n'(1) = 0$. I named my polynomial $f$, and let $h$ be f.derivative(t), and try to find $h(t=1)$. Here's what I got,
> (n - 1)^2*2^n*n*n^(n - 2) - (n - 1)*2^(n - 1)*n^(n - 1) - 2*(n - 1)*2^(n
- 2)*n^(n - 1) - 2*(n^2 - 3*n + 2)*2^(n - 1)*n^(n - 1)
Which turns out to be 0 when I verify by hand. However it seems like Sage is unable to detect the redundance in the expression (e.g. $n \times n^{n-2} = n^{n-1}$). Did I do the computation in the "wrong way"? If so, what's the proper way to do it?
Thanks!
Sun, 20 Jan 2013 20:43:03 -0600http://ask.sagemath.org/question/9724/factorizing-a-polynomial-with-two-variables/Answer by ppurka for <p>Hi, I would like to factorize the following polynomial in $t$, with an integer indeterminate $n$,</p>
<p>$f_n(t) = 2^n ((n-1)t^n+1)^{n-1} - n^{n-1} t^{(n-1)(n-2)} (t^{n-1} + 1)(t+1)^{n-1}$</p>
<p>I expect it to have a factor of $(t-1)^2$ and hope that after division the polynomial in $t$ would have positive coefficients. </p>
<ol>
<li><p>Is there any way I can verify this by Sage?</p></li>
<li><p>I have tried to check that $f_n(t)$ has a factor of $(t-1)^2$ by checking that $f_n(1) = f_n'(1) = 0$. I named my polynomial $f$, and let $h$ be f.derivative(t), and try to find $h(t=1)$. Here's what I got,</p></li>
</ol>
<blockquote>
<p>(n - 1)^2<em>2^n</em>n<em>n^(n - 2) - (n - 1)</em>2^(n - 1)<em>n^(n - 1) - 2</em>(n - 1)<em>2^(n
- 2)</em>n^(n - 1) - 2<em>(n^2 - 3</em>n + 2)<em>2^(n - 1)</em>n^(n - 1)</p>
</blockquote>
<p>Which turns out to be 0 when I verify by hand. However it seems like Sage is unable to detect the redundance in the expression (e.g. $n \times n^{n-2} = n^{n-1}$). Did I do the computation in the "wrong way"? If so, what's the proper way to do it?</p>
<p>Thanks!</p>
http://ask.sagemath.org/question/9724/factorizing-a-polynomial-with-two-variables/?answer=14480#post-id-14480Try to use `full_simplify` on the expression
sage: var('n')
n
sage: implicit_multiplication(True)
sage: F = (n - 1)^2 2^n n n^(n - 2) - (n - 1)2^(n - 1)n^(n - 1) - 2(n - 1)2^(n - 2)n^(n - 1) - 2(n^2 - 3n + 2)2^(n - 1)n^(n - 1)
sage: F.full_simplify()
0
Sun, 20 Jan 2013 20:55:08 -0600http://ask.sagemath.org/question/9724/factorizing-a-polynomial-with-two-variables/?answer=14480#post-id-14480Comment by Sanchez for <p>Try to use <code>full_simplify</code> on the expression</p>
<pre><code>sage: var('n')
n
sage: implicit_multiplication(True)
sage: F = (n - 1)^2 2^n n n^(n - 2) - (n - 1)2^(n - 1)n^(n - 1) - 2(n - 1)2^(n - 2)n^(n - 1) - 2(n^2 - 3n + 2)2^(n - 1)n^(n - 1)
sage: F.full_simplify()
0
</code></pre>
http://ask.sagemath.org/question/9724/factorizing-a-polynomial-with-two-variables/?comment=18374#post-id-18374Thanks! That settles my second question.Sun, 20 Jan 2013 21:21:24 -0600http://ask.sagemath.org/question/9724/factorizing-a-polynomial-with-two-variables/?comment=18374#post-id-18374Comment by ppurka for <p>Try to use <code>full_simplify</code> on the expression</p>
<pre><code>sage: var('n')
n
sage: implicit_multiplication(True)
sage: F = (n - 1)^2 2^n n n^(n - 2) - (n - 1)2^(n - 1)n^(n - 1) - 2(n - 1)2^(n - 2)n^(n - 1) - 2(n^2 - 3n + 2)2^(n - 1)n^(n - 1)
sage: F.full_simplify()
0
</code></pre>
http://ask.sagemath.org/question/9724/factorizing-a-polynomial-with-two-variables/?comment=18367#post-id-18367For the first question, I think your method is correct. There can be some other methods, like looking at the factors of f(t) using `f.factor_list()`, or by looking manually at the output of `f(t)/(t-1)^2`, etc. But these are going to be slow and not always give results which are in their simplest form.Mon, 21 Jan 2013 03:31:32 -0600http://ask.sagemath.org/question/9724/factorizing-a-polynomial-with-two-variables/?comment=18367#post-id-18367