Closed form solution to: Find $x, y \in \mathcal{R}^n$ to minimize $||x||_2$ while $Ax + By = c$? I came across an interesting problem today:
I need to find two vectors, $x \in \mathcal{R}^n$ and $y \in \mathcal{R}^n$. They need to satisfy the linear equation $Ax + By = c$, where $c \in \mathcal{R}^m$, and $A, B \in \mathcal{R}^{m \times n}$. Subject to that constraint, I want to minimize the two-norm of $x$ while allowing $y$ to float freely.
So I have:
Find $x, y$ 
Minimizing $||x||_2$ 
Such That $Ax + By = c$
Obviously this is convex and I can brute force this by gradient descent, but can anyone think of a way to do it in closed form, just for fun? I feel like there might be something clever involving the pseudoinverse of $A$, but I can't put my finger on it.
 A: Not a complete solution, but an idea.
Let $V=A(\mathbb R^n)\cap B(\mathbb R^n).$ That is, the intersection of the ranges of $A,B.$ Then, starting with a particular solution $Ax_0+By_0=c,$ any other solution $(x_1,y_1)$ has $A(x_1-x_0)=B(y_0-x_1).$ So the space of vectors $Ax$ with a orresponding $y$ has dimension equal to the dimension of $V.$
There won't always be a starting solution. If $A(\mathbb R^n)+B(\mathbb R^n)\neq\mathbb R^{m}$ then there will be $c$ so that there is no solution.
Let $W=A^{-1}(V).$ Let $p(x)$ be the orthogonal projection of $x$ onto the subspace $W.$ Then the answer is $x_0-p(x_0).$ This is the point on the hyperspace $x_0+W$ nearest to $0.$
So this requires us to understand $W$ and have an example $x_0.$
Another way to define $W$ is as $A^{-1}(B(\mathbb R^n)).$
There's no particular reason for $A$ and $B$ to have the same dimension. If $B$ is $p\times m$ it still only depends on the $B(\mathbb R^p)$ and $A.$
So you can rephrase this as:

If $V\subseteq \mathbb R^n$ is a subspace, and $c\in\mathbb R^m$ find $x$ such that $c-Ax\in V$ which minimizes $\|x\|.$

