[Math] Determinant of matrix that is diagonal, but for last row/column

determinantlinear algebramatrices

I would like to compute the determinant of a symmetric $(K+1)\times (K+1)$ matrix in which the upper left $K \times K$ matrix is diagonal but the $(K+1)$th row and column are complete. E.g.
$$
X = \begin{bmatrix}
x_1 & 0 & \dots & 0 & y_1 \\
0 & x_2 & \dots & 0 & y_2 \\
\vdots & \vdots & \ddots & \vdots & \vdots \\
0 & 0 & \dots & x_K & y_K \\
y_1 & y_2 & \dots & y_K & y_{K+1}
\end{bmatrix}
$$
Is there a simple way to compute $\det(X)$?

Note, a similar question was asked for a matrix with the same form but with more constraints on the entries:

Determinant of an almost-diagonal matrix

I can't see that the answer to this question helps here though.

Best Answer

For aesthetic considerations suggested by Michael Hoppe, I'll rename $K$ into $n$ and $y_{K+1}$ into $x_{n+1}$, so the matrix whose determinant you're searching is

$$A=\begin{pmatrix} x_1 & 0 & \dots & 0 & y_1 \\ 0 & x_2 & \dots & 0 & y_2 \\ \vdots & \vdots & \ddots & \vdots & \vdots \\ 0 & 0 & \dots & x_n & y_n \\ y_1 & y_2 & \dots & y_n & x_{n+1} \end{pmatrix}. $$

First method. Use determinant expansion with respect to the last column to get

$$\mathrm{det}(A) = x_1...x_n x_{n+1} + \sum_{i=1}^n(-1)^{n+1+i} \mathrm{det}(A_i)$$

where $A_i$ is the matrix $A$ deprived of its last column and $i$-th row. For example,

$$A_1 = \begin{pmatrix}0& x_2 &0& ... &0 \\ 0 & 0 & x_3 & ... & 0 \\ \vdots & & & \ddots& \vdots\\ 0 & & ... & & x_n\\ y_1 & &... && y_n \\ \end{pmatrix}. $$ Using row expansion for $A_i$, it is easy to see that $\mathrm{det}(A_i)$ is equal to $(-1)^{n+i} y_i \prod_{j \neq i} x_j$, which yelds

\begin{align*}\mathrm{det}(A) &= \prod_{i=1}^{n+1} x_i - \sum_{i=1}^n y_i^2 \prod_{j \neq i, j\leqslant n}x_j \\ &= \prod_{i=1}^{n+1}x_i \left( 1 - \sum_{i=1}^n \frac{y_i^2}{x_i}\right). \end{align*}

Edit (second method, hint). This last expression suggests another method (maybe it's not working) : suppose that no $x_i$ is zero. Note $X = \mathrm{diag}(x_1, ..., x_{n+1})$ and $Y = A - X$, so that $A = X+Y = X(\mathrm{Id}+X^{-1}Y)$. Then, $\mathrm{det}(A) = \mathrm{det}(X) \mathrm{det}(\mathrm{Id} - X^{-1}Y)$. Now, all you have to do is to compute $\mathrm{det}(\mathrm{Id} - X^{-1}Y)$. Maybe there's a simple ay of doing this (I don't know).