# How do I show that an equation has a solution orthogonal to the nullspace?

This was a question on a recent linear algebra midterm, and I had no idea where to start.

Fix an $$m\times n$$ matrix $$A$$ and a column vector $$\mathbf{b}$$ of size $$m$$. Assume that $$A\mathbf{x}=\mathbf{b}$$ is consistent. Show that $$A\mathbf{x}=\mathbf{b}$$ has a solution $$\mathbf{x}_0$$ that is orthogonal to the nullspace $$\mathbf{N}(A)$$.

Hint: start with any solution and modify it to get one orthogonal to $$\mathbf{N}(A)$$.

I thought that I should be doing something with the row space of the matrix since it's perpendicular to the nullspace, but I didn't know where to go from there, so I'm not sure if that was the right way to go. Can anyone point me in the right direction?

Start with a solution $x_0$, then write $x_0$ as $$x_0 = \hat{x_0} + z,$$ where $\hat{x_0} = \mathrm{Proj}_{Nul A} (x_0)$ is the orthogonal projection of $x_0$ to $Nul A$.

Then for any $y\in Nul A$, $$y \cdot z = 0.$$ The vector $z$ is the solution you want.

Any subspace $S \subset \mathbb{R}^n$ has an orthogonal complement $S^\bot = \{ x | \langle x,s \rangle = 0 \text{ for all } s \in S\}$, and any $x \in \mathbb{R}^n$ has a unique decomposition $x = s + o$, where $s \in S$ and $o \in S^\bot$.

Here we apply this to $S = \ker A$.

Suppose $Ax_1 = b$, then we can write $x_1 = s + x_0$ where $s \in \ker A$ and $x_0 \in (\ker A)^\bot$. Then we see that $A x_1 = A x_0 = b$.

Suppose that $\textbf{x*}$ is a normalized solution to $A\textbf{x}=0$ and $\textbf{x}_0$ is a solution to $A\textbf{x}=\textbf{b}$.

We can construct a vector $\widetilde{\textbf{x}}_0 = \textbf{x}_0 - \langle \textbf{x}_0, \textbf{x*} \rangle \textbf{x*}$

Perhaps it's a good excercise to show that $\widetilde{\textbf{x}}_0$ is orthogonal to $\textbf{x*}$

Now it remains to show that $\widetilde{\textbf{x}}_0$ is a solution to $A\textbf{x}=\textbf{b}$.

\begin{align*} A\widetilde{\textbf{x}}_0 &= A(\textbf{x}_0 - \langle \textbf{x}_0, \textbf{x*} \rangle \textbf{x*})\\ &= A\textbf{x}_0 - A\langle \textbf{x}_0, \textbf{x*} \rangle \textbf{x*}\\ &= A\textbf{x}_0 - \langle \textbf{x}_0, \textbf{x*} \rangle A\textbf{x*}\\ &= A\textbf{x}_0 - \langle \textbf{x}_0, \textbf{x*} \rangle 0\\ &= A\textbf{x}_0 \end{align*} and since $\textbf{x}_0$ is a solution to $A\textbf{x}=\textbf{b}$, we have $A\widetilde{\textbf{x}}_0=\textbf{b}$

It's pretty straight forward to extend this to the case when the nullspace has more than one basis vector.

Consider $V$ and $W$ vector spaces with inner product over $\mathbb R$. Take dim($V$)=$n$ and dim($W$)=$m$, so that the matrix in our problem becomes a linear transformation $T\in L(W,W)$. We know there exist some $z\in V$ such that $T(z)=t\in W$ fo some known $t$ (that would be the part of the system of equations).
Now take the set $\alpha =\{v_1,...,v_k\}$ an orthonormal basis of $Ker(T)$. Take now the set $\alpha \cup \{z \}$ and complete to obtain an ordered basis of $V$ of the form: $$\beta=\{v_1,...,v_k,z,u_1,...,u_l\}$$ By applying the Gram-Schmidt you can arrive to an orthonormal basis of $V$, then take the element $k+1$ in this new basis and, by fixing with some scalars, you will obtain the vector you were looking for.