Linear algebra, Approximation and fundamental theorem of linear algebra For a given $m\times n$ matrix $A$ and $\vec{x} \in \mathbb{R}^n$ find $\vec{y} \in \mathbb{R}^n$ which is a solution to $A\vec{y}=0$ and is a minimum distance from $\vec{x}$.
Show that for $\vec{y}$ such that $A\vec{y}=0$ and $\left \| \vec{x}-\vec{y} \right \|$ is as small as possible, then $\vec{x}-\vec{y}$ is in the $Row(A)$.
I am very close to this, can someone help me clear my thoughts a bit?
Here is my process,
because $A\vec{y}=0$ and $\vec{y}$ is in $R^n$  so $\vec{y}$ is in the Null(A),
x-ay=x-projection of x onto Col(A), which is equal to perp ColA (x) – Logan 6 mins ago
So $\vec{x}-A\vec{y}$ is in the complement of Row space of A, using "the fundamental theorem of linear algebra" again.
How do you go from there? Please help me!!!!
 A: There are some mistakes in what you've written, but you essentially have the idea for the second question.
We are looking for the point $\vec y$ in the nullspace of $A$ that is as close to $\vec x$ as possible, which is in other words the projection of $\vec x$ onto the nullspace of $A$. By the properties of orthogonal projection, such a $\vec y$ has the property that $\vec x - \vec y$ lies in the orthogonal complement to the nullspace of $A$.
By the fundamental theorem, this is the same as saying that $\vec x - \vec y$ lies in the row space of $A$.

As for how to compute this vector: note that the matrix that projects onto the row space of $A$ is given by $A^T(AA^T)^{-1}A$ (assuming the rows of $A$ are linearly independent). It follows that the projection onto the nullspace has the matrix
$$
P = I - A^T(AA^T)^{-1}A.
$$
The vector that we are after is the projection of $\vec x$ onto the nullspace, which will simply be $\vec y = P \vec x$.

If the rows of $A$ are not linearly independent, we can proceed as follows. The projection of $\vec x$ onto the row-space of $A$ is the vector $A^T \vec z$, where $\vec z$  is the least squares solution to the equation $A^T \vec z = \vec x$. In other words, if $\vec z$ is any solution to the equation
$$
AA^T \vec z = A \vec x,
$$
then $A^T \vec z$ is the projection of $\vec x$ onto the row space. It follows that the desired vector $\vec y$ is equal to $\vec y = \vec x - A^T\vec z$.
