# Factoring Multivariable Polynomials

This topic is 2565 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hey,

I'm a high school student (11th grade) and I'm working on a computer algebra system for a research project. Most things are are going well (sums, products, derivatives, integrals, series, expansion, complex analysis, factoring basic expressions, etc.). However, I am having difficulty with one key area: factoring polynomials (and, by extension, multivariable polynomials).

I have the book Computer algebra : systems and algorithms for algebraic computation by James Davenport, but the described algorithms in the factoring chapter go way over my head once eigenvectors, eigenvectors, determinants, etc. come into play. I have an undergraduate algebra book which I'm using to self-study these topics, but they are relatively difficult to understand without practical experience provided by an actual teacher. Unfortunately, the highest math class in my school is AP BC Calc (which I'm acing by taking naps during class) but it is miles behind any of this stuff.

My system can factor something like ax+ay+az+bx+by+bz into (a+b)(x+y+z) or x^x*ln(x)+x^x into (x^x)(ln(x)+1) by "reverse distribution", but it cannot factor a^2+2ab+b^2 into (a+b)(a+b), for example - and this is a critical requirement for simplification of expressions like sin^4(x)+2sin^2(x)cos^2(x)+cos^4(x) which reduces to 1 when it is factored.

Does anyone here have any experience with factoring polynomials in computer algebra systems, or know anyone that does? Or, perhaps, does anyone have any resources alternative to the aforementioned book?

Thanks!

##### Share on other sites
You might want to check out out a linear algebra book; I like [url="http://books.google.com/books?id=Gv4pCVyoUVYC&printsec=frontcover&dq=gilbert+strang+introduction+to+linear+algebra&hl=en&src=bmrr&ei=_HkrTd_XIsK78gaY2_3RAQ&sa=X&oi=book_result&ct=result&resnum=1&ved=0CDQQ6AEwAA#v=onepage&q&f=false"]Gilbert Strang's[/url] (Chapter 6 is eigenvectors and eigenvalues). I know it's harder to learn math on your own, but it sounds like linear algebra isn't actually out of your league; I think that with a proper introduction you'd probably "get" eigenvalues and eigenvectors, and be able to understand Davenport.

Google has no preview of Davenport's book, so I can't be sure exactly what he's doing, but I can make some guesses.

1.) My first guess (this post, before edits) was that he's looking at the [url="http://en.wikipedia.org/wiki/Companion_matrix"]Companion Matrix[/url] for a polynomial. The eigenvalues of the companion matrix are the roots of the polynomial. This only really helps for polynomials of one variable though.

2.) My second guess is that he's explaining multivariate [i]quadratic [/i]polynomials in terms of the eigenvectors and eigenvalues of matrices. [EDIT: On second thought, probably not...]

##### Share on other sites
[quote name='Emergent' timestamp='1294695342' post='4756881']
You might want to check out out a linear algebra book; I like [url="http://books.google.com/books?id=Gv4pCVyoUVYC&printsec=frontcover&dq=gilbert+strang+introduction+to+linear+algebra&hl=en&src=bmrr&ei=_HkrTd_XIsK78gaY2_3RAQ&sa=X&oi=book_result&ct=result&resnum=1&ved=0CDQQ6AEwAA#v=onepage&q&f=false"]Gilbert Strang's[/url] (Chapter 6 is eigenvectors and eigenvalues). I know it's harder to learn math on your own, but it sounds like linear algebra isn't actually out of your league; I think that with a proper introduction you'd probably "get" eigenvalues and eigenvectors, and be able to understand Davenport.
[/quote]
Yes, I have an undergraduate algebra book covering all of this stuff. I'm definitely trying my best to learn from it, but learning from books can be very difficult.

[quote]
Google has no preview of Davenport's book, so I can't be sure exactly what he's doing, but I can make some guesses.
[/quote]
You can actually find the full book by digging through a couple of link on his homepage ([url="http://people.bath.ac.uk/masjhd/"]http://people.bath.ac.uk/masjhd/[/url]), but for convenience: http://staff.bath.ac.uk/masjhd/masternew.pdf

The factoring starts from page 176 in the PDF.

[quote]
1.) My first guess (this post, before edits) was that he's looking at the [url="http://en.wikipedia.org/wiki/Companion_matrix"]Companion Matrix[/url] for a polynomial. The eigenvalues of the companion matrix are the roots of the polynomial. This only really helps for polynomials of one variable though.

2.) My second guess is that he's explaining multivariate [i]quadratic [/i]polynomials in terms of the eigenvectors and eigenvalues of matrices. [EDIT: On second thought, probably not...]
[/quote]
The eigenvalues and eigenvectors actually come in with Berlekamp's algorithm as described in the book. Theres a lot more besides Berlekamp's algorithm in the factoring algorithm, but I figured I have to narrow it down before I can move on.

##### Share on other sites
Technically, an expression like
[indent]
cos[sup]4[/sup](x) + 2cos[sup]2[/sup](x)sin[sup]2[/sup](x) + sin[sup]4[/sup](x)[/indent]

is not a polynomial, but a transcendental function. In this particular case, you can simply consider sin[sup]2[/sup](x) and cos[sup]2[/sup](x) as indeterminate and then use a polynomial factorization algorithm to simplify it, but it is not always possible or useful to use such an algorithm. Sometimes, it is better to use some trigonometric identity for example. Moreover, the algorithm in that book is designed for polynomials with rational coefficients (actually integer) and you may have expressions with transcendental numbers like pi or with square roots. You have to consider them as "indeterminate" if you want to use that algorithm, but the results may not be particularly good. A factorization algorithm which works on reals or complex numbers may however introduce bad looking factorizations and also contains some approximations of the real roots.

I'm not an expert of this field, but I know there are some ACM journal on mathematical softwares. You may search for papers on expression simplification and polynomial factorization at the ACM portal ([url="http://portal.acm.org/"]http://portal.acm.org/[/url]) to find additional material on the subject. To read the paper there you have to pay, but the preprints of several papers are freely available on internet. Note however that some papers may require advanced knowledge of algebra (in particular of field or ring theory).

##### Share on other sites
Hey,
[quote name='apatriarca' timestamp='1294740941' post='4757184']Technically, an expression like
[indent]
cos[sup]4[/sup](x) + 2cos[sup]2[/sup](x)sin[sup]2[/sup](x) + sin[sup]4[/sup](x)[/indent]

is not a polynomial, but a transcendental function. In this particular case, you can simply consider sin[sup]2[/sup](x) and cos[sup]2[/sup](x) as indeterminate and then use a polynomial factorization algorithm to simplify it, but it is not always possible or useful to use such an algorithm. Sometimes, it is better to use some trigonometric identity for example. Moreover, the algorithm in that book is designed for polynomials with rational coefficients (actually integer) and you may have expressions with transcendental numbers like pi or with square roots. You have to consider them as "indeterminate" if you want to use that algorithm, but the results may not be particularly good. A factorization algorithm which works on reals or complex numbers may however introduce bad looking factorizations and also contains some approximations of the real roots.
[/quote]
Yes, I would match that particular expression against the polynomial a^2+2ab+b^2, factor that, and then substitute back in for a and b. I was only using it as a practical example, since you can raise sin^2(x)+cos^2(x) to any integer power and it should still reduce to 1. However, yes, the book only describes an algorithm for working with integer coefficients (which, by extension, will work for any rational coefficients by factoring out the the smallest denominator). I know that the big-boy computer algebra systems like Mathematica can factor polynomials with irrational coefficients, so I suppose I should look for a different algorithm.

[quote]
I'm not an expert of this field, but I know there are some ACM journal on mathematical softwares. You may search for papers on expression simplification and polynomial factorization at the ACM portal ([url="http://portal.acm.org/"]http://portal.acm.org/[/url]) to find additional material on the subject. To read the paper there you have to pay, but the preprints of several papers are freely available on internet. Note however that some papers may require advanced knowledge of algebra (in particular of field or ring theory).
[/quote]

Alright, thank you very much for the extra resources!

##### Share on other sites
[quote name='nullsquared' timestamp='1294708824' post='4756992']
The eigenvalues and eigenvectors actually come in with Berlekamp's algorithm as described in the book. Theres a lot more besides Berlekamp's algorithm in the factoring algorithm, but I figured I have to narrow it down before I can move on.
[/quote]

Ok. I took a look at the PDF; much of the math I have only a passing familiarity with. Nevertheless, I might be able to help a little. I see Berlekamp's algorithm is described on p.164. Is it step [3] that's causing confusion? I'll quote here for convenience:

[quote]
[2] Calculate the matrix Q.
[3] Find a basis of its eigenvectors for the eigenvalue 1. One eigenvector
is always the vector [1; 0; 0;:::; 0],
[/quote]
This sounds straightforward enough, though there are some subtleties.

So your problem is computing a basis for an eigenspace...

Typically, one uses the SVD for this, but you actually know the eigenvalue a priori, so I think we can do better...

Well, the 1-eigenspace of Q is the null space of Q-I, and so the null space of P=(Q-I)^T (Q-I). P is a symmetric real matrix, so by the spectral theorem it is orthogonally diagonalizable. Its 0-eigenvectors span the 1-eigenspace of the original matrix Q. Finally QR-decomposition will tell you the range and null space of P (see [url="http://en.wikipedia.org/wiki/Kernel_%28matrix%29#Numerical_computation_of_null_space"]wiki: Kernel (math)[/url]). The advantage of this approach is that everything is computed in a finite number of steps (not asymptotically), so it seems compatible with the idea of using exact arithmetic, etc, as one usually sees in computer algebra systems.

There may well be more efficient ways to do this, but it sounds like the above will solve this one part of your puzzle.