Two subspaces $S, T \subset \R ^n$ are
orthogonal if
\[
x^\tp y = 0 \text{ for all } x \in S, y \in T.
\] \[
S^\perp = \Set{x \in \R ^n}{x^\top y = 0 \text{ for all }
y \in S}.
\]
Notice that $S^\perp $ is always a subspace. If $x \in S^\perp $, then $x^\top y = 0$ for all $y \in S$. So then $(\alpha x)^\top y = \alpha (x^\top y) = 0$ for all $\alpha \in \R $ and $y \in S$. We conclude $\alpha x \in S^\perp $ for all $\alpha \in \R $. In other words, $S^\perp $ is closed under scalar multiplication. If $x, z \in S^\perp $, then $(x+z)^\top y = x^\top y + z^\top y = 0 + 0 = 0$. We conclude that $x + z \in S^\perp $ for all $x, z \in S^\perp $. In other words, $S^\perp $ is closed under vector addition. Consequently, $S^\perp $ is a subspace.