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.
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$.