# Matrix determinant lemma for non-invertible matrices

I would like to calculate the following determinant

$$\det (XX^T + D)$$

where $X \in \mathbb{R}^{m \times n}$. In my specific application:

• the size of $m$ is such that calculating $XX^T$ is out of the question (but $X^TX$ is fine).

• $D$ is a diagonal matrix with some zero elements on the diagonal (i.e., $\det(D)=0$).

Is anyone aware of any techniques that can be used in this case? An extension of the matrix determinant lemma that can be applied to non-invertible matrices?

• Are the nonzero diagonal entries of $D$ positive? Jul 2 '18 at 13:10
• In the application I am tackling yes. Jul 3 '18 at 9:56

For the sake of simplicity, say that $$D=\begin{bmatrix}0&0\\0&\tilde{D}\end{bmatrix},$$ where $\tilde{D}$ is an $(m-k)\times(m-k)$ nonsingular matrix (so that the leading zero block is $k\times k$).
You can "fix" the singular block by a suitable diagonal matrix and then compensate it back to the low-rank update. Say, $\Delta=\mathrm{diag}(\delta_i)_{i=1}^k$ be a nonsingular diagonal matrix which we want to add to the leading block of $D$ to make it nonsingular. Note that if $E_k$ are the first $k$ columns of the identity matrix then $$D_+=\begin{bmatrix}\Delta & 0 \\ 0 & \tilde{D}\end{bmatrix}=D+E_k\Delta E_k^T$$ so $$D+XX^T=D_+-E_k\Delta E_k^T+XX^T =D_++[E_k,X][-E_k \Delta,X]^T=:D_++YZ^T.$$ You can apply the lemma to this matrix. If $k$ (the number of zero diagonal entries of $D$) is sufficiently small, this should not much harm the efficiency.