Solution (source code)

= Solution

Take $B$ to be linear in its first argument and conjugate-linear in its second, with $\bar a=a^q$. For a <Hermitian form over a quadratic finite field>, $B(v,v)\in\mathbb F_q$. We first establish the <quadratic finite-field norm and trace surjectivity> needed for <orthonormalization of a finite-field Hermitian form>. The <field norm> $N(a)=a^{q+1}$ maps $\mathbb F_{q^2}^*$ onto $\mathbb F_q^*$ because the <multiplicative group of a finite field is cyclic> of order $q^2-1$. The <field trace> $\operatorname{Tr}(a)=a+a^q$ is an $\mathbb F_q$-linear map into $\mathbb F_q$. It is nonzero: a nonzero polynomial of degree $q$ cannot vanish at all $q^2$ elements. It is therefore onto, including in characteristic two.

There must be $v$ with $B(v,v)\ne0$. Otherwise, for any $v,w,a$, expanding the diagonal value gives
$$
0=B(v+aw,v+aw)=\operatorname{Tr}(\bar a B(v,w)).
$$
If $B(v,w)\ne0$, varying $a$ contradicts the surjectivity of the <field trace>. Thus all pairings would vanish, contrary to nondegeneracy. Choose $a$ with $N(a)=B(v,v)^{-1}$; then $v_1=av$ has norm one. Every $w$ decomposes uniquely as
$$
w=B(w,v_1)v_1+\bigl(w-B(w,v_1)v_1\bigr),\qquad V=\mathbb F_{q^2}v_1\oplus v_1^\perp.
$$
The restricted <Hermitian form over a quadratic finite field> on the <orthogonal complement for a sesquilinear form> is nondegenerate: a vector there orthogonal to that complement is also orthogonal to $v_1$, hence to all of $V$, and is zero. Induction produces an <orthonormal basis> $v_1,\ldots,v_n$.

The <unitary group over a finite field> is the <group> of invertible $\mathbb F_{q^2}$-linear maps preserving $B$. In the <orthonormal basis> just constructed, its concise description is
$$
\boxed{U_n(q^2)=\{g\in GL_n(\mathbb F_{q^2}):\bar g^{\mathsf T}g=I_n\}.}
$$
The notation here uses the size of the matrix field; it is also frequently written $U_n(q)$. There is no determinant-one condition in this definition.