qr
PDF · 4 pages · 52.9 KB
Open PDF file
Short teaching handout from a course labeled CSI4050, dated March 10, 2004. It develops the Householder matrix H = I - beta uu^T, shows it is symmetric and its own inverse, and derives how to choose u to zero a column below the diagonal. It then builds A = QR, solves Ax = b by back substitution, and compares QR with Gaussian elimination and Gram-Schmidt. Embedded exercises are included. Authorship is not stated in the text.
AI-written summary; may contain errors.
Extracted text (machine-read; may contain errors)
March10,2004
TheQRFactorization
Gaussian elimination, andtheclosely-related LUandPLU factorizations, provideone
approac htosolving alinear system Ax=b.Thisapproac hisbased onusing elemen tary
matrices, whichsimply implemen trowoperations. Amuchnewerapproac histheQR
factorization ,whichisbased onHouseholder matrices. Weareinterested inthisalgorithm
because itwillprovidesome niceexamples ofalgorithm developmen tandanalysis.
TheHouseholder Matrix
Thefollowingdevelopsaspecialutilitymatrix that,liketherowoperation-based matrices,
canbeusedtoperform amatrix factorization.
Consider amatrix Hoftheform
H=I uuT;
where Iisthenbynidentitymatrix, uisannby1matrix|basically avector|and is
some xedbutunkno wnrealnumber.
4 Compute byhand thematrix Hthatresults fromu=2
41
2
33
5and=1.
Nowwewanttogure outhowtopickuandtomakeHespecially nice.
First, notethatHissymmetric, nomatter what values uandhave.Toseethis,just
usebasicproperties ofthetransp oseoperation, namely (AT)T=A,(A+B)T=AT+BT,
(AB)T=BTAT,and(A)T=ATwhere AandBareanymatrices forwhichthegiven
operations aredened, andisanyrealnumber.
Specically ,
HT=(I uuT)T=IT (uuT)T=I (uuT)T=I (uT)TuT=I uuT=H:
4 Aretheelemen tarymatrices usedinthePLUfactorization symmetric? Aretheinverses
oftheelemen tarymatrices easytocompute?
Next, wewanttogure outhowtopicktomakeHhaveaniceinverse. Itturns out
thatwecanpicksothatHisitsowninverse,namely HH=I.
Thefollowingderivation usesbasic matrix algebra properties, whichsaythatyoucan
doalgebra justlikeyou'reusedto,except thatyoumustkeepthings thataremultiplied
together inthecorrect order. And,youcancomm utescalars withmatrices freely.
Leavingoutalotofbasic algebra steps, wehave
HH=(I uuT)(I uuT)=I+(2uTu 2)uuT;
soifwepicktomake
2uTu 2=0;
CSI4050 Page1
March10,2004
wehave=0or=2
uTu.Clearly =0doesyieldaniceH,namely H=I,butthat's
notveryhelpful, sowetake=2
uTu.
Wenowocially dene aHouseholder matrix foragivenvectorutobe
H=I 2
uTuuuT:
4 Letu=2
41
2
33
5andcompute thecorresp onding Householder matrix. Verifydirectly that
HT=HandHH=I.
We'realmost donewiththepreliminaries beforewecandene theQRfactorization. Now
wereachthecrucial point,namely pickingusothatthecorresp onding Householder matrix
\zeroesout"agivencolumn ofamatrix belowthediagonal.
Specically ,letv(for\victim," perhaps) beanyvector andassume thatwewanttond
aHouseholder matrix HsuchthatHv=2
664
0
...
03
775:
Let'sjustformHvandseeifwecangure outhowtodothis:
Hv=(I uuT)v=v uTvu:
4 Thisinnocent-looking calculation alsoshowshowHvcanbeecien tlycomputed for
anyvectorv.Ingeneral, whatistheeciency classformultiplying annbynmatrix by
annvector? What istheeciency classforthealgorithm suggested bythepreceding
calculation?
Now,looking attheformulaabove,withourfavoritevalueforplugged in,wehave
Hv=v 2uTv
uTuu:
Ifwewantthatquantitytohaveallzeroes,except intherstspot,oneobvious thing
suggests itself: takeutomatchvinpositions 2through n,andddle withu1tomakethe
scalar equal to1.
So,wewanttosolvetheequation
2uTv
uTu=1
for,where
u=2
664
v2
...
vn3
775:
CSI4050 Page2
March10,2004
After some algebraic suering, weobtain theequivalentequation
2 2v1 v2
2 ::: v2
n=0;
whichisaquadratic equation withunkno wnandhasthesolutions
=2v1p
4v2
1+4(v2
2+:::+v2n
2:
Thissimplies inconvincing fashion to
=v1q
v2
1+v2
2+:::+v2n:
Either solution doeswhat wewantingeneral, sowecanpickthesigntomatchthe
signofv1.
So,theupshot ofthiswhole discussion isthatifwehaveamatrix Athatwewantto
transform, webeginbyforming avectoruthatisidenticaltotherstcolumn ofAexcept
intherstposition, where ithastheoriginal valueofAwiththesumofthesquares ofall
thecomponentsoftherstcolumn added orsubtracted.
Then wetakethatu,compute thecorresp onding ,andtheresulting Histhematrix we
multiply Abyzeroitoutbelowthediagonal, justlikeinGaussian elimination.
4 Here's amajorpointofthisdiscussion: howecien tlycanHAbeformed? Should H
beformed? Should Hbestored?
Then, theprocessisrepeated, justlikeinGaussian elimination, atstepkzeroing out
column kofHk 1H2H1Abelowrowk,while leavingrows1through k 1unchanged.
4 Verifythatforming uforcolumn kbyputting 0inspots1through k 1worksas
desired.
So,eventually weobtain
HnH2H1A=R;
where Risuppertriangular. Then wemultiply bothsidesrepeatedly byHn,Hn 1,ldots,
H2,H1,toobtain
A=H1H2HnR
anddenote H1H2HnbyQ,soA=QRasdesired, where Risuppertriangular andQ
is,well,whataboutQ?
Itturns outthatQ,asaproductofHouseholder matrices, isaverynicematrix, having
muchbetterproperties ingeneral thanthematrix LfromGaussian elimination.
QhastheverynicepropertythatQTQ=I.
4 Verifythis.
CSI4050 Page3
March10,2004
Thismeans thatthecolumns ofQformasetofmutually perpendicular vectors oflength 1
(intheusual Euclidean wayofmeasuring thelength ofavector). Infact,theQRfactoriza-
tionisabettermetho dfornding anorthogonal basisforasubspace spanned byagiven
setofvectors thanthemucholder andmore famous \Gram Schmidt orthogonalization
algorithm."
Now,tosolveAx=boncewehaveA=QR,wenotethatwewantAx=QRx=b,so
ifwemultiply bothsidesbyQT,wehaveQTQRx=QTb,orRx=QTb.Thus,givena
newright-hand sidevectorb,werstformQTb,andthenusebacksubstitution tondx,
whichwecandobecause Risuppertriangular.
Atthispointyoumightbeexpecting aniceexample workedout,showingthisprocess
on,say,a4by4matrix, butyou're notgoing togetit,because there wouldn't bemuch
point!Thedeepfacthereisthatthisalgorithm alwaysleadstohorrible numbers,andonly
thetiniest ofexamples canbe\rigged" toworkoutdecently.Thiswhole thing isreally
anadvertisemen tforyoureducation: bystudying complex algorithms andmathematics
indepth, yougaintheabilitytodealwithalgorithms thataresimply tohideous todo
byhand. Youcan't understand theQRalgorithm byjustworking through anexample
(though working through asmall onewouldhelpalittle), youcanonlyunderstand it
through abstract analysis, andbyprogramming itup.
4 Havingsaidallthat,formbyhand theQRfactorization ofthematrix
A=2
42 21
1 24=52
27=533
5:
While doing this,think abouthowtheQRfactorization processcanbeecien tly
implemen ted,andwhatit'seciency classwillbe.
So,itturns outthattheQRapproac hiscompetitive,interms ofrun-time eciency ,with
Gaussian elimination withpartial pivoting. But,itistypically betterthanthatalgorithm
inthepresence ofill-conditioning.
Also, itcanbeusedasatoolforother purposes. Asmentioned above,itcanbeusedas
apractical alternativ etotheGram-Sc hmidt algorithm. Itprovides atypically superior
alternativ etothe\normal equations" when doing least-squares regression. And, itisthe
corecomputational elemen tinalgorithms tocompute eigenvalues.
CSI4050 Page4