How many orthogonal matrices are there over a given finite ring or field? I want to know how many $2\times 2$ orthogonal matrices exist over the ring $\mathbb{Z}_n$ or the field $\mathbf{F}_p$. And how many $2\times 1$ orthogonal vectors exist over the ring $\mathbb{Z}_n$ or the field $\mathbf{F}_p$.
 A: If by orthogonal vectors you mean a collection $S$ of non-zero vectors such that all pairs of distinct vectors $(a,b)$ and $(c,d)$ from the set $S$ satisfy the relation $ac+bd=0$, then the question is a bit subtle, because it is possible for a vector to be `perpendicular to itself'. In $F_p^2$ this happens, iff $p\equiv 1\pmod{4}$, because the equation 
$$a^2+b^2=0\Leftrightarrow (a/b)^2=-1 $$ has non-trivial ($ab\neq0$) solutions, iff $-1$ has a square root in $F_p$. In those cases we can include all (non-zero) multiples of such a vector to get a total of $p-1$ non-zero vectors with pairwise vanishing inner products. This is also the maximum.
A way to see this is as follows: if an orthogonal set contains a (non-zero) vector $\vec{v}$ perpendicular to itself, then all the vectors $\perp\vec{v}$ must be scalar multiples of $\vec{v}$. This is because $\vec{v}$ cannot be orthogonal to the entire space, so the subspace $\langle\vec{v}\rangle^\perp$ has dimension one, and must be spanned by $\vec{v}$. If the orthogonal set has no such vectors as elements, then it is linearly *IN*dependent by the usual proof for "orthogonality $\Rightarrow$ linear independence", and has size at most 2.
If $p\equiv3 \pmod 4$, then all the non-zero vectors of $F_p^2$ have non-zero inner products with themselves, and again, the set is linearly independent.
If we start varying the (non-degenerate) bilinear form, then the answers vary, but in a 2-dimensional space these are the basic cases.
If you mean something else, please edit your question accordingly. I don't know what happens with the ring $\mathbf{Z}_n$. In line with the comments by Arturo and Gerry, I think that CRT will help in the case of a square-free $n$.
