Find a vector perpendicular to two other vectors and with a certain sum. Explanation.

46 Views Asked by At

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.

2

There are 2 best solutions below

1
On BEST ANSWER

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.

0
On

Hint.

The lagrangian

$$ L(z,\lambda) = \frac 12||z||^2+\lambda\left(A z - b\right) $$

has the stationary points given by

$$ \nabla L = \cases{z + A^{\dagger}\lambda^{\dagger}=0\\ A z - b = 0} $$

and solving for $z,\lambda$ we have

$$ \lambda^{\dagger} = - \left(A A^{\dagger}\right)^{-1}b\\ z = A\left(A A^{\dagger}\right)^{-1}b $$