Singular values by QR decomposition

1.8k Views Asked by At

I have a hypothesis on some relationship between matrices, but no proof for it. I have a feeling this should exist already, could anyone point me in the right direction?

If I have a square matrix $A$ (let's say full rank, but otherwise arbitrary) and calculate its QR decomposition as $A = QR$ so that the diagonal of R is positive (so R is unique), my hypothesis is that the diagonal of $R$, which gives its eigenvalues, also gives the singular values of $A$. In other words, $diag(R) = eig(R) = \sqrt{eig(R^T R)} = sing(A)$. This seems to imply that $eig(R)^2 = eig(R^2) = eig(R^T R)$.

This seems to be true in practice, but from what properties does this follow? I tested this by generating lots of matrices w. random values between -1 and 1 and calculating these numbers using this program:

import numpy as np
from utils import qr_pos

def is_diagonal(A):
    return np.count_nonzero(A - np.diag(np.diagonal(A))) == 0

def test_eig(n=30, tol=0.00001):
    M = np.random.rand(N, N) # Random matrix
    M = 2*M - 1              # Entries from -1 to 1
    Q, R = qr_pos(M)         # QR dec. so that diag(R) is positive
    if is_diagonal(R):
        print 'R is diagonal!'
    RTR = np.transpose(R) * R
    sinvals = np.sqrt(np.linalg.eigvals(RTR))
    diff = np.linalg.norm(sinvals - np.diag(R))

    # print 'Singular values:', sinvals
    # print 'Diagonal of R:', np.diag(R)
    # print 'Difference:', diff
    return diff < tol, M

success = True
N = 300
for i in range(N):
    equal, M = test_eig()
    print 'i',
    if not equal:
        print
        print 'Case found where the hypothesis does not hold:', M
        success = False
        break
if success:
    print
    print 'Hypothesis holds for', N, 'random test cases.'

Which outputs:

i i i i ... i i i
Hypothesis holds for 300 random test cases.
2

There are 2 best solutions below

1
On BEST ANSWER

Here's a quick example:

$$ M = \pmatrix{1&2\\1&1} \implies\\ Q = \frac 1{\sqrt{2}}\pmatrix{1 & 1\\1 & -1}, \quad R = \frac 1{\sqrt{2}} \pmatrix{2 & 3\\ 0 & 1} $$ The singular values of $M$ (and of $R$) are $\sqrt{\frac{7 \pm 3\sqrt{5}}{2}}$, which doesn't match the diagonal entries of $R$.

0
On

Accepted answer is nice, this is just another way of seeing this.

Hypothesis : Assume the diagonal of $R$ contains the singular values.

If you use the Gram-Schmidt process to compute the $A = QR$, you have $r_{1,1} = \|a_1\|$ with $a_1$ the first column of $A$, meaning that $\|a_1\|$ is a singular value of $A$, which is not always true.

Moreover using every permutation of $A$ and of its transpose gives that the norm of each columns and rows of $A$ are singular values of $A$, which exceed the number of possible singular values.

So the hypothesis is wrong.