• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
nullsquared

Factoring Multivariable Polynomials

5 posts in this topic

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!
0

Share this post


Link to post
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...]
1

Share this post


Link to post
Share on other sites
Hey, thanks for the reply!
[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.
0

Share this post


Link to post
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).
1

Share this post


Link to post
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!
0

Share this post


Link to post
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.
0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0