# Computation of (log) determinant of Gramian matrix

Given a matrix $$X \in \mathbb{R}^{n \times p}$$ with linearly independent columns and $$n > p$$. Is there a fast way to compute the determinant or log-determinant of $$A = X^T X$$?

Since $$A$$ is positive definite, a good option is to compute the Cholesky decomposition of $$A$$, such that $$A = L L^T$$, where $$L$$ is a triangular matrix. This way, $$\det(A) = (\det(L))^2$$.

Since $$L$$ is a triangular matrix, $$\det(L) = \prod_{i = 1}^p L_{ii}$$, with $$L_{ii}$$ the $$i$$-th element of $$L$$'s diagonal.

Then we have that $$\det(A) = (\prod_{i = 1}^p L_{ii})^2$$, and $$\log(\det(A)) = 2 \sum_{i = 1}^p \log(L_{ii})$$.

But I was wondering if there is a more direct way that does not involve the Cholesky decomposition. Maybe using $$X$$ directly.

I am assuming that you mean $$X \in \mathbb{R}^{n \times p}$$, rather than computing $$A$$ explicitly, and then decompose it, let's decompose $$X$$ directly.

Let the SVD decomposition of $$X=U\Sigma V^T$$, where $$\Sigma = \begin{bmatrix} diag(\sigma_1, \ldots, \sigma_p) \\ O_{n \times p} \end{bmatrix} , U \in \mathbb{R}^{n \times n}, V \in \mathbb{R}^{p \times p}$$.

Then we have $$A=V\Sigma^T UU^T\Sigma V^T=Vdiag(\sigma_1^2, \ldots, \sigma_p^2)V^T$$

Hence $$\det(A)=\prod_{i=1}^p \sigma_i^2$$

That is determinant of $$A$$ is the product of the square of the singular values of $$X$$.

• Oh no, I meant $X \in \mathbb{R}^{n \times p}$. I fixed it. Sorry about that. However, your answer could still hold if the dimensions are corrected. Feb 11, 2020 at 19:03
• I don't remember exactly how it was, but I think there was an equivalence between Cholesky decomposition and SVD if the matrix was positive definite. Am I right? Feb 11, 2020 at 19:10
• If $X \in \mathbb{R}^{n \times p}$, $n <p$, then the columns can't be linearly independent. Feb 12, 2020 at 1:49
• Yes, you're totally right. Used the incorrect symbol. It's $n > p$. In the particular case I am thinking about, $X$ is a data matrix with $n$ observations and $p$ variables. Feb 12, 2020 at 13:26
• I have changed my answer accordingly. Feb 12, 2020 at 13:44