Linear Algebra: UNIT IV: Matrix Decomposition

QR Decomposition: Example Solved Problems

Matrix Decomposition

Important Example Solved Problems - Engineering Maths or Mathematics - Matrix Decomposition: QR Decomposition: Example Solved Problems

QR Decomposition

WORKED EXAMPLES

 

Example 1

Use the modified Gram−Schmidt process to construct an orthogonal set of vectors from the linearly independent set { X1, X2, X3 } where


Solution:

First iteration

r11 = || X1 ||2 = √ <X1, X1> = √[(− 4)2 + (3)2 + (6)2] = √[16+9+36] = √61.

 r11= || X1 ||2 = 7.81025

 Q1 = (1/r11). X1 = 1/7.81025 [−4, 3, 6]T

= [ ‒4/7.81025 , 3/7.81025 , 6/7.81025 ]

Q1 = [− 0.512148, 0.384111, 0.768221]T

r12 = <X2, Q1>

= < (2,−3, 6), (−0.512148, 0.384111, 0.768221) >

= [ (2)(− 0.512148) + (− 3)(0.384111) + (6)(0.768221) ]

= [−1.024296 − 1.152333 + 4.609326]

 r12 = 2.432697

 r13 = <X3, Q1>

= < (2, 3, 0), (−0.512148, 0.384111, 0.768221) >

= [(2) (−0.512148) + (3)(0.384111) + (0)(0.768221)]

= [−1.024296 + 1.152333 + 0]

 r13=0.128037

X2 = X2 − r12Q1

= [2,−3, 6]T − 2.432697[−0.512148, 0.384111, 0.768221]T

= [2,−3, 6]T + [1.2459,−0.934426, −1.86885]T

X2 = [3.2459, − 3.934426, 4.13115]T

X3 = X3 − r13Q1

= [2, 3, 0]T − (0.128037) [−0.512148, 0.384111, 0.768221]T

= [2, 3, 0]T + [0.06557,−0.04198, −0.09368]T

X3 = [2.06557, 2.95082−0.09836]T

Second iteration: (from the first iteration data)

r22 = || X2 ||2 = √ <X2, X2> = √[ (3.2459)2 + (− 3.934426)2 + (4.13115)2]

= √[ 10.53587 + 15.47971 + 17.06640 ] = √43.08198

 r22 = 6.563686

Q2 = (1/r11). X2 = 1/1 6.563686 [3.2459, 3.934426, 4.13115]T

Q2 = [0.494524, −0.599423, 0.629394]T

 r23 = <X3, Q2>

= < (2.06557, 2.95082,−0.09826), (0.494524, −0.599423, 0.629394) >

= [ (2.06557)(0.494524) + (2.95082)(−0.599423) + (−0.09836) (0.629394) ]

= [1.021473 − 1.768789 − 0.061907]

 r23 = − 0.809223

 X3 = X3 − r23Q2

= [2.06557, 2.95082,−0.09836]T + 0.809223[0.494524, −0.599423, 0.629394]T

= [2.06557, 2.95082, − 0.09836]T + [0.400181, −0.485067, 0.509321]T

 X3 = [2.465751, 2.465753, 0.410961]T

Third iteration: (from the second iteration data)

 r33 = || X3 ||2 = √[(2.465751)2 + (2.465753)2 + (0.410961)2]

= √[6.079927 +6.079937 +0.168888]

= √12.328752

 r33 = 3.511232

 Q3 = (1/r33)X3 = 1/3.511232 [2.465751, 2.465753, 0.410961]T

Q3 = [0.702246, 0.702247, 0.117041]T

  An orthonormal set is {Q1, Q2, Q3}

 

Example 2

Construct a QR decomposition for the given matrix


Solution:

We know that the QR decomposition is A = QR. Where A is the given matrix, Q is the matrix which consists of Q1, Q2, Q3 (ie) [Q1, Q2 Q3] and R is the upper triangular matrix in the form  

From the Example 1, the given matrix A can be written as


Then we have to apply modified Gram−Schmidt process to construct an orthogonal set of vectors from the linearly independent set {X1, X2, X3} for the considered column vectors X1, X2, X3.

From Example (1), we have

Q1 = [−0.512148, 0.384111, 0.768221]T

Q2 = [0.494524, −0.599423, 0.629395]T

Q3 = [0.702247, 0.702247, 0.117041]T

R =  is an upper triangular matrix.

 From Q1, Q2 and Q3 we can formulate the elements of Q and R.


A direct calculation shows that A = QR.

 

Example 3

Construct a QR decomposition for the given matrix A = .

Solution:

We know that the QR decomposition is A = QR.

From the given matrix A, we have


First iteration

 r11 = || X1 ||2 = √<X1, X1> = √[12 +02 + 12] = √2 = 1.414213.

 Q1 = 1/(r11) . X1 = 1 / 1.414213 [1, 0, 1]T

 Q1 = [0.707107, 0.0, 0.707107]T

 r12 = <X2, Q1> = < (0, 1, 1), (0.707107, 0.0, 0.707107) >

 = [0 (0.707107) + 1 (0.0) + (1)(0.707107)] = [0+0+0.707107]

 r12 = 0.707107

 r13 = <X3, Q1> = < (1, 1, 2), (0.707107, 0.0, 0.707107) >

= [1 (0.707107) + 1 (0.0) + 2 (0.7071071)] = [0.707107+0+1.414214]

 r13 = 2.121321

 X2 = X2−r12Q1

= [0, 1, 1]T − 0.707107 [0.707107, 0.0, 0.707107]T

= [0, 1, 1]T + [−0.499947, 0.0, −0.499947]T

 X2 = [−0.499947, 1.0, 0.500053]T

 X3 = X3−r13Q1

= [1, 1, 2]T − 2.121321[0.707107, 0.0, 0.707107]T

= [1, 1, 2]T + [−1.5000009, 0.0,− 1.5000009]T

X3 = [−0.5000009, 1.0, 0.4999991]T

Second iteration: (from the first iteration)

 r22 = || X2 ||2 = √<X2, X2>

= √[(− 0.499947)2 + (1.0)2 + (0.500053)2]

= √[0.249947 + 1.0+ 0.250053] = √1.5

 r22 = 1.224745

Q2 = 1/(r22) . X2 = 1 / 1.224745 [‒0.499947, 1.0, 0.500053]T

Q2 = [−0.408205, 0.816496, 0.408291]T

 r23 = <X3, Q2> = < (1, 1, 2)T, (−0.408205, 0.816496, 0.408291)T >

= [ (1)(−0.408205) + (1)(0.816496) + (2)(0:408291) ]

= [−0.408205+0.816496 +0.816582]

 r23 = 1.224873

X3 = X3−r23Q2

= [−0.5000009, 1.0, 0.4999991])T − 1.224873[−0.408205, 0.816496, 0.408291]T

= [−0.5000009, 1.0, 0.499999]T + [0.499999,− 1.000103, −0.500105]T

X3 = [−0.0000019, −0.000103, −0.0001059]T

Third iteration: (from the second iteration)

r33= || X3 ||2 = √[(−0.0000019)2 + (− 0.000103)2 + (−0.0001059)2]

= √[0.00000000 +0.000000011 +0.0000001121]

=√0.00000002121

r33 = 0.000149

Q3 = 1/r33 • X3

= 1/0.000149 [−0.0000019, −0.000103, −0.0001059]T

Q3 = [−0.012837,−0.691275,−0.710738]T


A direct calculation shows that A= QR.

 

Example 4

Construct the QR decomposition for the given matrix


Solution:

Let us consider


First iteration

We know that A = QR

Let r11 = || X1 ||2 = √<X1, X1> = √[02 + 12 + 12 + 12] = √3 = 1.732051

Q1 = 1/r11 . X1 = 1/√3 [0, 1, 1, 1]T = [ 0, 1/√3, 1/√3, 1/√3 ]T

Q1= [0, 0.577350, 0.577350, 0.577350]T

r11 = <X2, Q1>

= < (1, 0, 1, 1), (0, 0.577350, 0.577350, 0.577350) >

= [(1) 0+ (0) 0.577350+ (1) 0.577350+ (1) 0.577350]

= [0+0+0.577350 +0.577350]

r12 = 1.1547

r13 = <X3, Q1>

= < (1, 1, 0, 1), (0, 0.577350, 0.577350, 0.377350) >

= [1(0) + (1)0.577350 + (0)0.577350 + (1)0.577350]

= [0+0.577350+0+0.577350]

 r13 = 1.1547

r14 = < X4,Q1 >

= < (1, 1, 1, 0), (0, 0.577350, 0.577350, 0.577350) >

= [(1) 0+ (1) 0.577350 + (1) 0.57735 + (0) 0.577350]

= [0+0.577350+0.577350+0]

r14 = 1.1547

X2 = X2−r12Q1

= [1, 0, 1, 1]T ‒ 1.1547[0, 0.577350, 0.577350, 0.577350]T

= [1, 0, 1, 1]T + [0, − 0.666667, −0.666667, – 0.666667]T

X2 = [1, − 0.666667, 0.333333, 0.333333]T

X3 = X3 − r13Q1

= [1, 1, 0, 1]T – 1.1547[0, 0.577350, 0.577350, 0.577350]T

= [1, 1, 0, 1]T + [0, − 0.666667, − 0.666667, – 0.666667]T

 X3 = [1, 0.333333, – 0.666667, 0.333333]T

X4 = X4 − r14Q1

= [1, 1, 1, 0]T – 1.1547 [0, 0.577350, 0.577350, 0.577350]T

= [1, 1, 1, 0]T + [0, − 0.666667, −0.666667, – 0.666667]T

X4 = [1, 0.333333, 0.333333,− 0.666667]T

Second iteration: (from the iteration vectors)

 r22 = || X2 ||2 = √[(1)2 + (−0.666667)2 + (0.333333)2 + (0.333333)2]

= √[ 1 +0.444444 +0.111111 + 0.111111]

= √1.666666

r22 = 1.290994

Q2 = 1/r22 . X2

 = 1/1.290994 [1, − 0.666667, 0.333333, 0.333333]T

Q2 = [0.774596, −0.516398, 0.258198, 0.258198]T

r23 = <X3, Q2>

= < (1, 0.333333,−0.666667, 0.333333)T, (0.774596, −0.516398, 0.258198, 0.258198)T >

= [ (1)(0.774596) + (0.333333)(−0.516398) + (−0.666667)(0.258198) + (0.333333)(0.258198) ]

= [0.774596 −0.172132−0.172132 +0.086065]

r23 = 0.516397

r24 = (X4, Q2)

= < (1, 0.333333, 0.333333, ‒ 0.666667)T, (0.774596, – 0.516398, 0.258198, 0.258198)T >

= [ (1) 0.774596 − (0.333333)(0.516398) + (0.333333) (0.258198) − (0.666667) (0.258198)]

= [0.774596−0.172132 +0.086065 − 0.172132]

 r24 = 0.516397

 X3 = X3 − r23Q2

= [1, 0.333333, −0.666667, 0.333333]T − 0.516397[0.774596 −0.516398, 0.258198, 0.258198]T

= [1, 0.333333, −0.666667, 0.333333]T + [−0.399999, 0.266665, −0.133332, −0.133332]T

X2 = [0.600001, 0.599998, −0.799999, 0.200001]T

X4 = X4− r24Q2

= [1, 0.333333, 0.333333,−0.666667]T −0.516397 [0.774596 −0.516398, 0.258198 0.258198]T

= [1, 0.333333, 0.333333, −0.666667]T + [−0.399999, 0.266666, −0.133332, −0.133332]T

X4 = [0.600001, 0.599999, 0.200001, −0.799999]T

Third iteration: (using vectors from the second iteration)

r33 = || X3 ||2 = √<X3, X3>

= √[(0.600001)2 + (0.599999)2 + (− 0.799999)2 + (0.200001)2]

= √[0.360001 +0.359998 +0.639998 +0.0400004]

= √1.399997

r33 = 1.183215

Q3 = 1/r33 . X3

= 1/1.183215 [0.600001, 0.599998, −0.799999, 0.200001]T

 Q3 = [0.507093, 0.507091, −0.676123, 0.169031]T

r34 = <X4, Q3 >

= < (0.600001, 0.599999, 0.200001, −0.799999)T, (0.507093, 0.507091, – 0.676123, 0.169031)T >

= [(0.600001) (0.507093) + (0.599999) (0.507091) + (0.200001) (−0.676123) + (−0.799999) (0.169031)]

= [0.304256+0.304254−0.134246 −0.135224]

r34 = 0.33904

X4 = X4 − r34Q3

= [0.600001, 0.59999, 0.200001,−0.799999]T – 0.33904 [0.507093, 0.507091, −0.676123, 0.169031]T

= [0.600001, 0.59999, 0.200001, −0.799999]T + [−0.171924, −0.171924, 0.229232, −0.057308]T

X4 = [0.428077, 0.428075, 0.429233,−0.857307]T

Fourth iteration: (using the vector from the third iteration)

 r44 = || X4 ||2 = √[0.183249 +0.183248 +0.184241 +0.734975]

= √1.285713

r44 = 1.133892

Q4 = 1/r44 . X4

= 1/1.133892 [0.428077, 0.428075, 0.429233, −0.857307]T

Q4= [0.377528, 0.377527, 0.378548, −0.756074]T

  The QR decomposition is


A direct calculation shows that A = QR.

 

Example 5

Apply the shifted QR algorithm to the matrix A =  to find the eigenvalues.

Solution:

We know that the shifted QR algorithm is

Ak−1 − Sk−1I = Qk−1 Rk−1 and

Ak = Rk−1Qk−1 + Sk−1I

Put k=1: The first equation becomes

 A0 – S0I = Q0R0

First iteration:

Let us consider A0 = , and S0 = 5


Now let us consider  We have to apply QR decomposition for this matrix by defining


I−iteration for X1 and X2

 r11 = || X1 ||2 = √<X1, X1> = √(−2)2 + (1)2 = √5=2.236068

Q1 = 1/(r11) X1 = 1/2.236068 [‒2,1]T

Q1 = [−0.894428, 0.447214]T

 r12 = <X2, Q1>

= < (1, 0), (−0.894428, 0.447214) >

= [1 (0.894428) + 0 (0.447214)]

r12 = −0.894428

X2 = X2 − r12Q1

= [1,0]T +0.894428[−0.894428, 0.447214]T

= [1, 0]T + [−0.800001, 0.400001]T

X2 = [0.199999, 0:4000011]T

II−iteration

r22 = ||X2||2 = √<X2, X2> =√[(0.199999)2 + (0.400001)2]

= √[0.039999 +0.160001] = √0.2

 r22 = 0.447214

Q2 = 1/r22 . X2 = 1/0.447214 [0.199999, 0.40001]T

Q2 = [0.447191, 0.894429]T


Here R0 is the upper triangular matrix 

Now the second equation for the shifted QR algorithum is

 A1 = R0Q0+ S0l

A1 = R0Q0 + 5I


Second iteration


To find Q1R1 let us apply gain QR decomposition

(ie. modified Gram−Schmidt process to find Q1R1)

I−iteration

For that  

 r11 = || X1 ||2 = √ <X1, X2> = √[(− 2.8)2 + (0.2)2] = √(7.84 + 0.04)

= √7.88 = 2.80713377

 r11 = 2.807133

 Q1 = 1/r11 . X1 = 1/2.807133 [−2.8, 0.2]T

 Q1= [−0.99746, 0.071247]T

 r12 = <X2, Q1> = < (0.2, 0), (− 0.99746, 0.071247) >

= [(0.2) (− 0.99746) + (0) (0.071247)] = −0.199492

X2 = X2 − r12Q1

= [0.2, 0]T + 0.199492[−0.99746, 0.071247]T

= [0.2, 0]T + [−0.198986, 0.014213]T

X2 = [0.001014, 0.014213]T

II−iteration

 r22= || X2 ||2 = √[(0.001014)2 + (0.014213)2]

= √[0.000001028 +0.000202001]

= √0.000203037 = 0.0142478

 r22 = 0.0142478

Q2 = 1/r22 . X2 = 1/0.0142478 [0.001014, 0.014213]T

Q2 = [0.71168882, 0.9975575]T


Third iteration:


Let us apply modified Gram−Schmidt process to construct QR decomposition for the above X1 and X2.

After applying the Gram−Schimdt process, we get

 Q1 = [−1.0, 0.000359]T and Q2 = [0.000359, 1.0]T


 The eigenvalues of A3 are

 λ1 = 2.585786 and λ2 = 5.414213

 

Example 6

Apply shifted QR algorithm to A=  and find the eigenvalues.

Solution:

Let us consider A0 =  

We know that the shifted QR algorithm is

Ak−1 − Sk−1I = Qk−1Rk−1 and

Ak = Rk−1Qk−1 + Sk−1I

Put k = 1; the first equation becomes A0−S0I = Q0R0

First iteration:


Now we have to apply shifted QR algorithm to find Q0 and R0.


Second iteration:


By applying Gram−Schmidt process we have


 The three eigenvalues are 3, 3, 14.0

 

Linear Algebra: UNIT IV: Matrix Decomposition : Tag: maths, mathematics : Matrix Decomposition - QR Decomposition: Example Solved Problems


Linear Algebra: UNIT IV: Matrix Decomposition



Under Subject


Linear Algebra

MA25C02 2nd Semester | 2025 Regulation



Related Subjects


English Essentials II

EN25C02 2nd Semester | 2025 Regulation | 2nd Semester 2025 Regulation



Linear Algebra

MA25C02 2nd Semester | 2025 Regulation


Transforms and its Applications

MA25C03 2nd Semester EEE Dept | 2025 Regulation | 2nd Semester 2025 Regulation


Applied Physics (CE) II

PH25C02 2nd Semester Civil, Agri Depts | 2025 Regulation | 2nd Semester 2025 Regulation


Applied Physics (CSIE) II

PH25C03 2nd Semester AIDS, CSE, IT, CSE(CY) Dept | 2025 Regulation | 2nd Semester 2025 Regulation


Applied Physics (EE) II

PH25C04 2nd Semester EEE Dept | 2025 Regulation | 2nd Semester 2025 Regulation


Applied Physics (ME) II

PH25C05 2nd Semester Mechanical Dept | 2025 Regulation | 2nd Semester 2025 Regulation


Applied Chemistry (CE) II

CY25C02 2nd Semester Civil Dept | 2025 Regulation | 2nd Semester 2025 Regulation


Applied Chemistry (ME) II

CY25C03 2nd Semester Mechanical Dept | 2025 Regulation | 2nd Semester 2025 Regulation


Electron Devices

EC25C01 2nd Semester ECE Dept | 2025 Regulation | 2nd Semester 2025 Regulation


Digital Principles and Computer Organization

CS25C06 2nd Semester AIDS, CSE, IT, CSE(CY) Dept | 2025 Regulation | 2nd Semester 2025 Regulation


Basic Electrical and Electronics Engineering

EE25C01 2nd Semester | 2025 Regulation | 2nd Semester 2025 Regulation


Basic Civil and Mechanical Engineering

GE25C01 2nd Semester EEE Dept | 2025 Regulation | 2nd Semester 2025 Regulation


Data Structures using CPlusPlus

CS25C05 2nd Semester ECE Dept | 2025 Regulation | 2nd Semester 2025 Regulation


Engineering Drawing

ME25C01 EEE, Mech, Agri, EEE Depts | 2025 Regulation | 2nd Semester 2025 Regulation


Data Structures and Algorithms

CS25C04 2nd Semester EEE Dept | 2025 Regulation


Circuits and Network Analysis

EC25C02 2nd Semester ECE Dept | 2025 Regulation | 2nd Semester 2025 Regulation


Engineering Mechanics

ME25C02 2nd Semester Mech, Civil, Agri Depts | 2025 Regulation | 2nd Semester 2025 Regulation


Object Oriented Programming (OOPs)

CS25C07 2nd Semester CSE, CSE(CY) Depts | 2025 Regulation | 2nd Semester 2025 Regulation