Can such a matrix be singular?

I found: $$ \begin{pmatrix} 15 & 0 \\ 0 & 15 \\ 11 & 11 \end{pmatrix} \cdot \begin{pmatrix} 14 & 1 & 11 \\ 1 & 14 & 11 \\ \end{pmatrix} = \begin{pmatrix} 210 & 15 & 165 \\ 15 & 210 & 165 \\ 165 & 165 & 242 \end{pmatrix} $$ The general idea is to start with a product of rank-$(n-1)$ matrices and to get the configuration of odd and even numbers. This looks like the following, assuming that $1$ represents odd and $0$ represents even: $$ \begin{pmatrix} 1 & 0 & \cdots & 0 & 0 \\ 0 & 1 & \cdots & 0 & 0\\ \vdots & \vdots & \ddots & \vdots & \vdots \\ 0 & 0 & \cdots & 1 & 0 \\ 0 & 0 & \cdots & 0 & 1 \\ 1 & 1 & \cdots & 1 & 1 \\ \end{pmatrix} \cdot \begin{pmatrix} 0 & 1 & \cdots & 1 & 1 & 1 \\ 1 & 0 & \cdots & 1 & 1 & 1\\ \vdots & \vdots & \ddots & \vdots & \vdots & \vdots \\ 1 & 1 & \cdots & 0 & 1 & 1\\ 1 & 1 & \cdots & 1 & 0 & 1 \end{pmatrix} $$ Then we observe that the row vectors of the first matrix should point approximately in the same direction as the column vectors of the second matrix, all the vectors should have approximately the same length, and two row vectors of the first matrix (two column vectors of the second matrix) should enclose an angle that is as close as possible to the right angle - in order to keep the non-diagonal elements as small as possible.

In the end, we have to ensure that the resulting matrix is symmetric.

So we can use the following

$$ \begin{pmatrix} a+n-2 & 0 & \cdots & 0 & 0 \\ 0 & a+n-2 & \cdots & 0 & 0\\ \vdots & \vdots & \ddots & \vdots & \vdots \\ 0 & 0 & \cdots & a+n-2 & 0 \\ 0 & 0 & \cdots & 0 & a+n-2 \\ b & b & \cdots & b & b \\ \end{pmatrix} \cdot \begin{pmatrix} a & 1 & \cdots & 1 & 1 & b \\ 1 & a & \cdots & 1 & 1 & b\\ \vdots & \vdots & \ddots & \vdots & \vdots & \vdots \\ 1 & 1 & \cdots & a & 1 & b\\ 1 & 1 & \cdots & 1 & a & b \end{pmatrix} $$ and adjust $a$ and $b$ with an even $a$ and an odd $b$ such that all conditions are fulfilled.


Yes, $A$ can be singular. Let $n\ge3$ be odd. Consider $$ A=\left[\begin{array}{cccc|c}a&b&\cdots&b&d\\ b&a&\ddots&\vdots&\vdots\\ \vdots&\ddots&\ddots&b&\vdots\\ b&\cdots&b&a&d\\ \hline d&\cdots&\cdots&d&c\end{array}\right] =\begin{bmatrix}(a-b)I_{n-1}+bee^T&de\\ de^T&c\end{bmatrix} $$ where $a,c$ are even, $b,d$ are odd, $\max(b,d)<\min(a,c)$ and $e=(1,1,\ldots,1)^T\in\mathbb R^{n-1}$. Using Schur complement, $A$ is congruent to $B=\left[(a-b)I_{n-1}+(b-\frac{d^2}{c})ee^T\right]\oplus c$. The eigenvalues of $B$ are $a+(n-2)b-\frac{d^2}{c}(n-1),\,a-b$ and $c$. The latter two are odd integers. Hence $B$ and $A$ are singular if and only if $$ [a+(n-2)b]c=(n-1)d^2. $$ When $n\ge5$ is odd, we can always pick $(b,c,d)=(1,n-1,n-2)$ and $a=d^2-d=(n-2)(n-3)$. Note that we do have $\max(b,d)=d<d^2-d=\min(a,c)$ in this case.

When $n=3$, the above choice of $(a,b,c,d)$ does not work (because $d$ becomes zero), but a brute-force search gives a solution $(a,b,c,d)=(16,9,18,15)$, i.e. $$ A=\begin{bmatrix}16&9&15\\ 9&16&15\\ 15&15&18\end{bmatrix}. $$