Let $x, y$ be two real variables. If $A$ is any $n\times n$ matrix with all entries in the set $\{x,y\}$ then prove that \begin{equation} \det A = (x-y)^{n-1}(Px + (-1)^{n-1}Qy) \end{equation} where $P,Q$ are integers defined by \begin{equation} P = \det A\big|_{x=1,y=0} \quad Q = \det A\big|_{x=0,y=1}. \end{equation}
I tried to do this by using induction and started for $n=2.$ But I am confused about the matrix that it will form since there are more than one possibility for a $2\times 2$ matrix. For example \begin{equation} \begin{bmatrix} x & y \\ y & x \end{bmatrix}, \begin{bmatrix} x & x \\ y & x \end{bmatrix}, \begin{bmatrix} x & y \\ x & y \end{bmatrix}, \begin{bmatrix} y & y \\ y & x \end{bmatrix},... \end{equation} There are 12 more possibilities. I have checked couple of cases and the result holds but I have no idea how to prove it in generality without checking each case. I would really appreciate any help. Also if you can give me some reference from where this type of problem is taken that will also help me a lot. Thanks in advance.
It is clear that $\det A(x,y)$ is a homogeneous polynomial in $x,y$ of degree $n$. If we denote the matrix with all entries equal to $1$ by $M$, then $A=yM + (x-y)B$, with $B=A(1,0)$. Now $M$ is $n$ times a projection (on the vector with all $1$'s), so if we diagonalize, we obtain $$ S^{-1}MS = n \begin{pmatrix} 1 & 0 \\ 0 & 0_{n-1,n-1}\end{pmatrix} . $$ Thus $(x-y)^{n-1}$ indeed divides $$ \det A = \det (y S^{-1}MS + (x-y)S^{-1}BS ) , $$ because only one entry of the matrix on the RHS is not a multiple of $x-y$.
So we now know that $$ \det A = (x-y)^{n-1} (ax + by) , $$ and we then confirm that $a,b$ are as asserted by comparing values at $x=0,y=1$ and $x=1,y=0$.