Task 1: Reduction to Hessenberg

Recall that in precept 4, we wrote the code for QR decomposition by Housholder using the following algorithm (10.1 in the book): gs1

And the algorithm to form Q given the householder reflectors (10.3 the book): gs1

The code from precept 4 is copy pasted for you below

Adapt this code to compute a reduction to upper Hessenberg, using the algorithm below:

gs1

Task 2: Polynomials rootfinding by eigensolver

Recall the companion matrix of the polynomial: $$ p(z) = z^m + a_{m-1} z^{m-1} + a_{m-2} z^{m-2} + \cdots a_1 z + a_0 $$ is:

</figure> Given a polynomial, form its companion matrix and find the roots of the polynomial using the funciton np.linalg.linalg.eigvals(A) which computes the eigenvalue decomposition.

Try it for $m =5,50$ and $500$. What do you notice?