# 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)^22^nnn^(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)

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!

edit retag close merge delete

Sort by » oldest newest most voted

Try 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

more

Thanks! That settles my second question.

( 2013-01-20 21:21:24 -0500 )edit

For 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.

( 2013-01-21 03:31:32 -0500 )edit