I would like to find all the real roots of a univariate polynomial. I could use Jenkins-Traub algorithm for example, but I want to learn how to solve it using the companion matrix.
I know how to turn a polynomial to companion matrix and I found a script which does QR decomposition: http://quantstart.com/articles/QR-Decomposition-with-Python-and-NumPy
And this is where I'm lost: what to do next? I think I have to calculate multiple decompositions but when I do, I always get the same result (obviously). I also read that it might be useful to first convert the companion matrix to Hessenberg form - but how? Then there are "shifts" - what are they?
I also found http://www.nr.com/webnotes/nr3web17.pdf but as I don't understand any of it I would like to know if there is any simpler method (even if slower or less stable).
In other words: reading http://en.wikipedia.org/wiki/QR_algorithm
"let A be a real matrix of which we want to compute the eigenvalues"
ok, that's my companion matrix, right?"we compute the QR decomposition Ak=QkRk"
that would beQ, R = householder(A)
from the very first link, right?"We then form Ak+1 = RkQk"
easy, just multiply R and Q"Under certain conditions,[2] the matrices Ak converge to a triangular matrix, the Schur form of A. The eigenvalues of a triangular matrix are listed on the diagonal, and the eigenvalue problem is solved."
...wait, what? I tried:for i in range(100): Q, R = householder(A) A = mult_matrix(R, Q)
but there doesn't seem to be any progress made and I cannot see any numbers even close to the correct roots.
Please, can anyone explain this to me?
PS: I don't want to blindly use LAPACK or similar as I want to understand how it works, at least in very simplified terms.
PPS: There is also http://adorio-research.org/wordpress/?p=184 (not sure how is it different from the first method, though...)