# Determinant of matrix that is diagonal, but for last row/column

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.

• The matrix $X$ is called a symmetric arrowhead matrix. (I'm just saying this so that this thread shows up when people google for arrowhead matrices.) Commented May 31, 2019 at 17:51

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

• +1, exactly what I've got. The formula would look a bit nicer if one renamed $y_{k+1}$ by $x_{k+1}$. Commented Apr 11, 2017 at 10:52
• Great - thank you for your reply. By a slightly different method (and assuming no $x_i$ are zero - which is true for my problem), I arrived at $\det(A)=(x_{n+1}-\sum_{i=1}^n \frac{y_i^2}{x_i})\prod_{i=1}^n x_i$. Commented Apr 11, 2017 at 15:59

I'd do a Laplace expansion along the last row/column: $$\det X=\sum_{j=1}^{K+1} (-1)^{j+1} y_j \det X_j,$$ where $X_j$ is obtained by deleting the $j$th row and last column from $X$. Then $$\det X_{K+1}=x_1\cdot\ldots\cdot x_K$$ is easy. For the others, you have to do a second Laplace expansion: $$X_1=\left( \begin{matrix} 0 & x_2 & 0 & \cdots & y_2 \\ 0 & 0 & x_3 & \cdots & y_3 \\ \vdots & & & & \vdots \\ y_1 & 0 & 0 & \cdots & y_{K+1} \end{matrix} \right)$$ so $$\det X_1=y_1 \det \left( \begin{matrix} x_2 & 0 & \cdots & y_2 \\ \vdots & & & \vdots \\ 0 & 0 & \cdots & y_{K+1} \end{matrix} \right)=y_1x_2\ldots x_K y_{K+1}$$ since the remaining matrix is upper triangular. Works analogously for $X_2,\ldots,X_K$, but watch the signs.

Well yes, the answer provided in the other question should help you a lot. Assuming that the $x_i$ are not zero, you can use Gaussian elimination to turn your matrix into a triangular matrix and then read off the determinant.

If $x_i$ is zero for some $i$, a Laplace expansion using the $i$-th row or column should help you to reduce the problem.

$$\def\m#1{\left[\begin{array}{r}#1\end{array}\right]}$$Given a block matrix $$X = \m{A&B\\C&D}$$ the determinant is $$\det(X) = \det\left(D-CA^{-1}B\right)\cdot\det(A)$$ For the current problem, this results in $$\det(X) = \left(y_{K+1}-\sum_{i=1}^K\frac{y^2_i}{x_i}\right)\cdot \left(\prod_{\ell=1}^K x_\ell\right)$$