I have two vectors $\vec{x} = [x_1,\dots,x_n]$ and $\vec{y} = [y_1,\dots,y_n]$. I need to find a vector $\vec{z}$ such that $\vec{z}\cdot[1,\dots,1] = S$.
I was proposed with a solution which i would like to understand. Could you please help me with it? The solution is the following:
$$\mathbf{A} = \begin{bmatrix}\vec{x}\\\vec{y}\\\vec{1}\end{bmatrix}.$$
$$\vec{z} = \mathbf{A}^T(\mathbf{A}\mathbf{A}^T)^{-1}\begin{bmatrix}0\\0\\S\end{bmatrix}.$$
It has a lot of similarity with least squares, but it is different.
The conditions you want $z$ to satisfy are equivalent to saying that
$$Az = \begin{bmatrix}0\\0\\S\end{bmatrix}$$
which, for $n>3$, is an underdetermined system, so this is exactly least squares. In fact, the solution provided is exactly the least squares solution to the problem.