[Math] How to find the point closest to the origin in a system of equations

linear algebraoptimization

I have a system of equations with 4 variables and i'm trying to find the closest vector to the origin that satisfies both of the equations.

$x_1+0*x_2+2x_3-x_4 = 1$

$3x_1+x_2-2x_3+0*x_4=0$

I tried optimizing the 3D distance function for each one of those separately:

$f(x,y) = x^2 + y^2 + z^2$

But the answers I get for $x_1, x_2, x_3, x_4$ are different for each equation. I'm not sure how to proceed, any help would be much appreciated.

One suggestion I had was to put them in terms of matrices/vectors and optimize that way but i'm not sure how to do that.

EDIT: I tried a 4D distance function, but i still get different answers from each equation and I need one vector that satisfies both…

Best Answer

That would be a linear comb. of vectors $v$(1,0,2,-1) and $u$(3,1,-2,0) that satisfies both equations. $u$ and $v$ are the normal vectors of the given 3-dimensional planes, so they will be orthogonal to their intersection also. So you want the one that actually reaches that intersection and starts from the origin. Let $x=av+bu$ put it in your equations: $$(a+3b)+0(0a+b)+2(2a-2b)-(-a+0b)=1$$$$3(a+3b)+(0a+b)-2(2a-2b)+0(-a+0b)=0$$ So $a=14b$ and $14b+3b+2(28b-2b)+14b=1$ => $b=1/83$, $a=14/83$

Meaning your vector is (17/83, 1/83, 26/83, -14/83)

Related Question