Professional Documents
Culture Documents
The QR Factorization: Least-Squares Methods
The QR Factorization: Least-Squares Methods
• the QR factorization
• orthogonal matrices
10–1
Least-squares methods
least-squares problem
normal equations
AT Ax = AT b
AT Ax = AT b
algorithm:
1. calculate C = AT A (C is symmetric: 12 n(n + 1)(2m − 1) ≈ mn2 flops)
2. Cholesky factorization C = LLT ((1/3)n3 flops)
3. calculate d = AT b (2mn flops)
4. solve Lz = d by forward substitution (n2 flops)
5. solve LT x = z by backward substitution (n2 flops)
example
3 −6 −1
A = 4 −8 , b= 7
0 1 2
· ¸ · ¸
T 25 −50 T 25
1. calculate A A = and A b =
−50 101 −48
· ¸· ¸
5 0 5 −10
2. Cholesky factorization: AT A =
−10 1 0 1
· ¸· ¸ · ¸
5 0 z1 25
3. forward substitution: solve =
−10 1 z2 −48
z1 = 5, z2 = 2
· ¸· ¸ · ¸
5 −10 x1 5
4. backward substitution: solve =
0 1 x2 2
x1 = 5, x2 = 2
A = QR
AT Ax = AT b
RT QT QRx = RT QT b
RT Rx = RT QT b (QT Q = I)
Rx = QT b (R nonsingular)
algorithm
1. QR factorization: A = QR with
3/5 0 · ¸
5 −10
Q = 4/5 0 , R=
0 1
0 1
· ¸
T 5
2. calculate d = Q b =
2
· ¸· ¸ · ¸
5 −10 x1 5
3. backward substitution: solve =
0 1 x2 2
x1 = 5, x2 = 2
Orthogonal matrices
Q = [q1 q2 · · · qn] ∈ Rm×n (m ≥ n) is orthogonal if QT Q = I
T
q1 q1 q1T q2 · · · q1T qn
T T T
q q q q · · · q q
2 1 2 2 2 n
QT Q =
.. .. ... ..
qnT q1 qnT q2 · · · qnT qn
properties
• the columns qi have unit norm: qiT qi = 1 for i = 1, . . . , n
• the columns are mutually orthogonal: qiT qj = 0 for i 6= j
• rank Q = n, i.e., the columns of Q are linearly independent
Qx = 0 =⇒ QT Qx = 0 =⇒ x=0
• a1 ∈ Rm, A2 ∈ Rm×(n−1)
i.e.,
q1T q1 = 1, QT2 Q2 = I, q1T Q2 = 0
R12 = q1T A2
A2 − q1R12 = Q2R22,
A2 − q1R12 = A2 − (1/r11)a1R12
with
q1T q1 = 1, q2T q2 = 1, q3T q3 = 1
q1T q2 = 0, q1T q3 = 0, q2T q3 = 0
0 26 3/5 · ¸
0 −7 4/5 £ ¤ £ ¤ r22 r23
− 0 10 = q2 q3
4 4 0 0 r33
−3 −3 0
0 20
0 −15 £ ¤
i.e., the QR factorization of = q2r22 q2r23 + q3r33
4 4
−3 −3
0
0
r22 = 5, q2 =
4/5
−3/5
therefore, r23 = 5
QR factorization so far:
9 0 26 3/5 0 q13
12 15 0 10
0 −7 4/5
0 q23
0 5
A=
0 = 5
4 4 0 4/5 q33
0 0 r33
0 −3 −3 0 −3/5 q43
in summary,
9 0 26 3/5 0 4/5
12 15 0 10
0 −7
4/5
0 −3/5
A=
0 = 0 5 5
4 4 0 4/5 0
0 0 25
0 −3 −3 0 −3/5 0
= QR
solution:
normal equations AT Ax = AT b:
· ¸· ¸ · ¸
1 −1 x1 0
=
−1 1 + 10−10 x2 10−10
solution: x1 = 1, x2 = 1
1 0 · ¸ · ¸
1 −1 T 0
Q = 0 1 , R= , Q b=
0 10−5 10−5
0 0
solution of Rx = QT b is x1 = 1, x2 = 1
Summary