How do I solve such an eqation? (I know how to solve Mx=n using gaussian elimination but I don't know how to handle 2 variables.
Thanks
How do I solve such an eqation? (I know how to solve Mx=n using gaussian elimination but I don't know how to handle 2 variables.
Thanks
It seems to me like you're trying to solve the least squares problem Mx-Ny=0, in other words find the vectors x,y that minimize the euclidean norm of the vector (Mx-Ny). Let's assume that your matrices are of dimensions M[rowsM][columnsM] and N[rowsN][columnsN],then your vectors would be of dimension x[columnsM] and y[columnsN]. Because the obvious solution to your problem is the trivial solution where y=x=0 you have to give either to x or y vector some constant value in order to compute the best approximation of the other one. This paper contains the basic about least squares approximation: Least squares approximation
Basically all you need is (assuming you initialize vector y): $\vec{x}=(M^{T}M)^{-1}M^{T}(N\vec{y})$ So by finding the inverse of $M^{T}M$ and performing some matrix computations you're done.
I presume you know either $x$ or $y$. If $M$ and $N$ are large, then you should use the conjugate gradient method. Otherwise you can directly invert (or pseudo-invert) $M$ or $N$ as appropriate.