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 'Case found where the hypothesis does not hold:', M
        success = False
if success:
    print 'Hypothesis holds for', N, 'random test cases.'

Which outputs:

i i i i ... i i i
Hypothesis holds for 300 random test cases.
  • $\begingroup$ The QR decomposition does not by itself give either the singular values or the eigenvalues of a matrix. QR decomposition may well be used in an iterative procedure to find singular values or eigenvalues. $\endgroup$ – hardmath Jan 23 '18 at 16:58
  • 1
    $\begingroup$ The eigenvalues of $R$ are not usually the singular values of $A$ (in fact they can't be unless $R$ is diagonal). However, both $R$ and $A$ have the same singular values. $\endgroup$ – Omnomnomnom Jan 23 '18 at 17:10
  • $\begingroup$ @Omnomnomnom I added a program I used to test my hypothesis. It seems to be the case that the eigenvalues of $R$ are the singular values of $A$ in many cases, and in none of the cases is $R$ diagonal. How can this be the case? $\endgroup$ – nardi Jan 23 '18 at 22:05
  • $\begingroup$ Note that unless $R$ is diagonal, we cannot say $R^2 = R^T R$. Would it suffice to give an example where nonsingular $R^2$ and $R^T R$ have different eigenvalues? $\endgroup$ – hardmath Jan 23 '18 at 23:32
  • $\begingroup$ @nardi not sure what's wrong with your code, but I've put a specific example down into an answer $\endgroup$ – Omnomnomnom Jan 23 '18 at 23:56

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

  • $\begingroup$ You're right, this is not true. I made an error in that I used * instead of np.dot, so I was not getting the proper matrix product. $\endgroup$ – nardi Jan 24 '18 at 16:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.