Find determinant for a matrix with $x$ on the diagonal Find determinant for a matrix with $x$ on the diagonal and $-1$ at the end of the first row and $-1$ at first of the last row other elements are $0$.
{ x  0 0 -1 
  0  x 0  0 
  .  0 x 
  .  0 0  x 
  -1 0 .  .  x 
}

$$
\pmatrix{x &amp; 0 &amp; \cdots &amp; 0 &amp; -1\\
0 &amp; x &amp; \ddots &amp; \vdots &amp; 0\\
\vdots &amp; \ddots &amp; \ddots &amp; 0 &amp;\vdots\\
0&amp; \cdots &amp; 0 &amp; x&amp;0\\
-1&amp;0&amp;\cdots &amp; 0 &amp; x}
$$
I know if i add 1/xR1 to R2 the determinat will be $(x^{n-1})(x-1/x)$. I asked my professor she said what if $x$ is zero. Now i don't know what to do.
Your approach is perfectly fine. What you have shown is that in the case that $x \neq 0$, Your matrix $M$ satisfies
$$
\det M = x^{n-1}(x - 1/x) = x^{n-2}(x^2 - 1).
$$
All that remains is to show that this equation holds for $x = 0$ as well.
There are a few approaches to handle the case of $x = 0$. One is to note that $\det(M)$ must be a polynomial over $x$; since $\det(M) = x^{n-2}(x^2 - 1)$ holds for all $x \neq 0$ and polynomials are continuous, the equation must hold for $x = 0$ as well.
Alternatively, we can simply plug in $x = 0$. For the case of $n=2$, we have
$$
\det(M) = \det \pmatrix{0&amp;-1\\-1&amp;0} = 0^2 - (-1)^2 = -1,
$$
which agrees with the result of plugging $x = 0$ into $x^{2-2}(x^2 - 1) = x^2 - 1$, since $0^2 - 1 = -1$. For the case of $n &gt; 2$, we see that $x = 0$ leads to a second row of zeros, which means that the determinant of $M$ is zero. This agrees with the result $x^{n-2}(x^2 - 1) = 0^{n-2}(0^2 - 1) = 0$.

One fast approach is to use the W-A (AKA Sylvester) identity. This matrix can be written as $M = xI + AB$, where
$$
A = \pmatrix{1&amp;0\\0&amp;0\\ \vdots &amp; \vdots \\ 0&amp;0\\0&amp;1}, \quad B = -\pmatrix{0&amp;0&amp;\cdots &amp; 0&amp; 1\\1 &amp; 0 &amp; \cdots &amp; 0 &amp; 0}.
$$
For all $x \neq 0$, we have
$$
\begin{align}
\det(M) &amp;= \det(xI_n + AB) = x^n \det(I_n + x^{-1}AB)
\\ &amp;  = x^n \det(I_2 + x^{-1}BA)
\\ &amp; = x^{n-2} \det(x I_2 + BA) = x^{n-2} \det \pmatrix{x &amp; -1\\-1 &amp; x}
= x^{n-2} (x^2 - 1).
\end{align}
$$
If $x=0$, then the determinant will be zero ( cause there is 1 row with all elements are zeros )