**2**

# Factoring Multivariable Polynomials

###
#1
Members - Reputation: **122**

Posted 09 January 2011 - 01:11 PM

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!

###
#2
Members - Reputation: **971**

Posted 10 January 2011 - 03:35 PM

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 Companion Matrix 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

*quadratic*polynomials in terms of the eigenvectors and eigenvalues of matrices. [EDIT: On second thought, probably not...]

###
#3
Members - Reputation: **122**

Posted 10 January 2011 - 07:20 PM

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.You might want to check out out a linear algebra book; I like Gilbert Strang's (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.

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

The factoring starts from page 176 in the PDF.

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.1.) My first guess (this post, before edits) was that he's looking at the Companion Matrix 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 multivariatequadraticpolynomials in terms of the eigenvectors and eigenvalues of matrices. [EDIT: On second thought, probably not...]

###
#4
Crossbones+ - Reputation: **1650**

Posted 11 January 2011 - 04:15 AM

cos^{4}(x) + 2cos^{2}(x)sin^{2}(x) + sin^{4}(x)

is not a polynomial, but a transcendental function. In this particular case, you can simply consider sin

^{2}(x) and cos

^{2}(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 (http://portal.acm.org/) 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).

###
#5
Members - Reputation: **122**

Posted 11 January 2011 - 08:41 AM

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.Technically, an expression like

cos^{4}(x) + 2cos^{2}(x)sin^{2}(x) + sin^{4}(x)

is not a polynomial, but a transcendental function. In this particular case, you can simply consider sin^{2}(x) and cos^{2}(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 (http://portal.acm.org/) 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).

Alright, thank you very much for the extra resources!

###
#6
Members - Reputation: **971**

Posted 11 January 2011 - 01:26 PM

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.

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:

This sounds straightforward enough, though there are some subtleties.[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],

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 wiki: Kernel (math)). 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.