Solution (source code)

= Solution

Strictly, it is the infinitesimal generators, not every <unitary matrix> with unit <determinant>, that are traceless. For a continuous one-parameter family $U(\epsilon)=\exp(i\epsilon T)$, <unitarity> requires the generator $T$ to be <Hermitian>. The <determinant> condition gives
$$
1=\det U(\epsilon)=\exp\left(i\epsilon\operatorname{tr}T\right)\quad\hbox{for every real }\epsilon.
$$
Differentiating at $\epsilon=0$ yields $\operatorname{tr}T=0$. A <Hermitian matrix> has $n$ real diagonal parameters and $n(n-1)$ real off-diagonal parameters; one real trace constraint leaves $n^2-1$ independent generators. Thus
$$
\boxed{\dim SU(n)=n^2-1}.
$$
The identity matrix supplies a concrete counterexample to interpreting the claim as one about arbitrary group elements: $I_n\in SU(n)$ but $\operatorname{tr}I_n=n$. Also, $e^{i\operatorname{tr}T}=1$ at a single parameter value only fixes the trace modulo $2\pi$; the continuous neighbourhood is essential.