Find a basis for the orthogonal complement of a matrix 
Let $S \subset \mathbb{R}^4$ be the vectors whose components satisy $x_1 + x_2 - x_3 + x_4 = 0$
Find the dimension of S and then find a basis for the orthogonal complement of S

So to find the dimension, i understand I am looking for the nullity as the equation equals 0, so setting $x_4=r$ $x_3=t$ and $x_2=s$ and having $x_1=-x_2+x_3-x_4$ so you get
$\begin{bmatrix}
-2+t-r \\
s\\
t\\
r
\end{bmatrix} = s\begin{bmatrix}
-1 \\
1\\
0\\
0
\end{bmatrix}+t\begin{bmatrix}
1 \\
0\\
1\\
0
\end{bmatrix}+r\begin{bmatrix}
-1 \\
0\\
0\\
1
\end{bmatrix}$ therefore giving dim(S)=3
However I am now stuck on how to find the orthogonal complement? 
 A: Short answer: you can read a basis for $S^\perp$ directly from the equation that defines $S$.
Longer answer: Since $\dim(S)=3$, we know that $\dim(S^\perp)=1$, so we just need to find any vector $\mathbf v$ that’s orthogonal to all of $S$, and $S^\perp$ will consist of all scalar multiples of that vector. I.e., if $\mathbf x =(x_1,x_2,x_3,x_4)^T\in S$, we need to solve $\mathbf v\cdot\mathbf x=\sum_{i=1}^4v_ix_i=0$. But you’ve already got an equation of this form that holds for all $\mathbf x\in S$, namely, $x_1+x_2-x_3+x_4=0$, so the coefficients of this give us the vector we seek: $(1,1,-1,1)^T$.
A: The subspace $S$ is the null space of the matrix
$$
A=\begin{bmatrix}1 & 1 & -1 & 1\end{bmatrix}
$$
so the orthogonal complement is the column space of $A^T$. Thus $S^\perp$ is generated by
$$
\begin{bmatrix}1 \\ 1 \\ -1 \\ 1\end{bmatrix}
$$
It is a general theorem that, for any matrix $A$, the column space of $A^T$ and the null space of $A$ are orthogonal complements of each other (with respect to the standard inner product).
To wit, consider $x\in N(A)$ (that is $Ax=0$) and $y\in C(A^T)$ (the column space of $A^T$). Then $y=A^Tz$, for some $z$, and
$$
y^Tx=(A^Tz)^Tx=z^TAx=0
$$
so $x$ and $y$ are orthogonal. In particular, $C(A^T)\cap N(A)=\{0\}$. Let $A$ be $m\times n$ and let $k$ be the rank of $A$. Then
$$
\dim C(A^T)+\dim N(A)=k+(n-k)=n
$$
and so $C(A^T)\oplus N(A)=\mathbb{R}^n$, thereby proving the claim.
