I want to compute this:
$$\begin{bmatrix} U\\ Y \end{bmatrix} = \begin{bmatrix} L_{11} &0 \\ L_{21} & L_{22} \end{bmatrix}\begin{bmatrix} Q_1\\ Q_2 \end{bmatrix}$$
Is this matlab command right then?
>> L = tril(qr([U;Y]))The MATLAB command tril is lower-traingle function. Is this right way to compute the LQ - Decomposition?
The reason why I asking this simple question, is because a lot of books talking about LQ - Decomposition but not explaining how it's done.
$\endgroup$2 Answers
$\begingroup$Suppose you want a $LQ$ factorization of a matrix $A$. You then do a $QR$ factorization of $A^T$, i.e., $A^T=UR$, where $U$ is orthogonal and $R$ is upper triangular. Then $A = R^T U^T$ and $L = R^T$ is lower triangular, while $Q = U^T$ is orthogonal.
$\endgroup$ 5 $\begingroup$Here is the answer - In MATLAB way!
Assume that we have matrix U and Y.
>> U = magic(5)
U = 17 24 1 8 15 23 5 7 14 16 4 6 13 20 22 10 12 19 21 3 11 18 25 2 9
>> Y = 5*magic(5)
Y = 85 120 5 40 75 115 25 35 70 80 20 30 65 100 110 50 60 95 105 15 55 90 125 10 45Then we want to solve this:
$$\begin{bmatrix} U\\ Y \end{bmatrix} = \begin{bmatrix} L_{11} &0 \\ L_{21} & L_{22} \end{bmatrix}\begin{bmatrix} Q_1\\ Q_2 \end{bmatrix}$$
Then we do this:
>> [Q, L] = qr([U;Y]')
Q = -0.500216 0.509947 0.693606 -0.067606 -0.063859 -0.706188 -0.654162 -0.056572 -0.263444 -0.027712 -0.029424 0.312464 -0.367193 -0.546166 -0.684377 -0.235396 0.398863 -0.432121 -0.339759 0.695221 -0.441367 0.235160 -0.440626 0.715746 -0.208446
L = -33.98529 -25.59931 -21.03851 -20.30290 -23.39247 -169.92645 -127.99655 -105.19257 -101.51451 -116.96236 0.00000 19.99188 15.32765 12.26797 4.56029 0.00000 99.95941 76.63825 61.33983 22.80146 0.00000 0.00000 -20.67472 -11.11590 -7.39834 0.00000 -0.00000 -103.37360 -55.57948 -36.99169 0.00000 0.00000 0.00000 -19.20224 -13.37762 0.00000 -0.00000 0.00000 -96.01121 -66.88809 0.00000 0.00000 0.00000 0.00000 -18.79627 -0.00000 -0.00000 0.00000 -0.00000 -93.98136
>>We rewrite variable L to this:
>> L = L'
L = -33.98529 0.00000 0.00000 0.00000 0.00000 -25.59931 19.99188 0.00000 0.00000 0.00000 -21.03851 15.32765 -20.67472 0.00000 0.00000 -20.30290 12.26797 -11.11590 -19.20224 0.00000 -23.39247 4.56029 -7.39834 -13.37762 -18.79627 -169.92645 0.00000 0.00000 0.00000 -0.00000 -127.99655 99.95941 -0.00000 -0.00000 -0.00000 -105.19257 76.63825 -103.37360 0.00000 0.00000 -101.51451 61.33983 -55.57948 -96.01121 -0.00000 -116.96236 22.80146 -36.99169 -66.88809 -93.98136And we rewrite variable Q to this:
>> Q = Q'
Q = -0.500216 -0.706188 -0.029424 -0.235396 -0.441367 0.509947 -0.654162 0.312464 0.398863 0.235160 0.693606 -0.056572 -0.367193 -0.432121 -0.440626 -0.067606 -0.263444 -0.546166 -0.339759 0.715746 -0.063859 -0.027712 -0.684377 0.695221 -0.208446Now we check if [U;Y] = L*Q
>> [U;Y]
ans = 17 24 1 8 15 23 5 7 14 16 4 6 13 20 22 10 12 19 21 3 11 18 25 2 9 85 120 5 40 75 115 25 35 70 80 20 30 65 100 110 50 60 95 105 15 55 90 125 10 45
>> L*Q
ans = 17.0000 24.0000 1.0000 8.0000 15.0000 23.0000 5.0000 7.0000 14.0000 16.0000 4.0000 6.0000 13.0000 20.0000 22.0000 10.0000 12.0000 19.0000 21.0000 3.0000 11.0000 18.0000 25.0000 2.0000 9.0000 85.0000 120.0000 5.0000 40.0000 75.0000 115.0000 25.0000 35.0000 70.0000 80.0000 20.0000 30.0000 65.0000 100.0000 110.0000 50.0000 60.0000 95.0000 105.0000 15.0000 55.0000 90.0000 125.0000 10.0000 45.0000
>>Yes it is! Please, correct me if I'm wrong!
$\endgroup$