Question 1 (Hessenberg Form, Eigenvalues, QR Algorithm)
Let A be the inverse Hilbert matrix
Using SciPy 0.10.0 and later, you should be able to create A by using the command
A = scipy linalg. invhilbert (4)
Otherwise, you will need to create A by specifying its components.
(a) Find the two vectors V1, V2 and their corresponding Householder transformations Q1.Q2
which will reduce A to upper Hessenberg form H:
A = Q2Q1HQ;Q2
Show each of the two steps of the reduction. You can perform these steps by hand or by
(b) Use the function scipy linalg. eig in PYTHON to obtain the spectra of each of A
and H. You must produce two sorted vectors of eigenvalues (i.e. one vector for A and
one for H) and display them in long format. Use numpy . sort as appropriate. Find
the relative error between these two vectors of eigenvalues.
(c) Use PYTHON (or any other programming language) to write a function which uses the
unshifted QR algorithm to produce the Schur decomposition of a tridiagonal matrix.
You must submit your code in electronic form SO that it can be run, if necessary. Use
your function to obtain the spectrum of H, sort the resulting vector, and compare your
answer to that of b) above. You can use the command
numpy set_printoptions (precision=16)
to set the default output precision to 16 significant figures (this is somewhat like the
format long in matlab).
(d) Explain, in general terms, any differences between the eigenvalues produced by the
eig function in b) above, and the eigenvalues produced by your Schur decomposition
in c) above. Use your observations of the code and the outputs, as well as the theory
covered in the Notes. Remember that both vectors of eigenvalues are approximations.
Recall the significance of size of the matrix A in relation to methods for obtaining the
roots of polynomials.
These solutions may offer step-by-step problem-solving explanations or good writing examples that include modern styles of formatting and construction
of bibliographies out of text citations and references. Students may use these solutions for personal skill-building and practice.
Unethical use is strictly forbidden.
import numpy as np
import scipy.linalg as lg
from scipy.linalg import *
n=A.shape ; H=A.copy() ; Qs=;Vs=;
for k in range(0,n-2):
H,Qs,Vs = computeHessenberg(A)