Least Square solution a1*x+b1*y=k1 a2*x+b2*y=k2 a3*x+b3*y=k3 |a1 b1| |k1| |x| B= |a2 b2| C= |k2| N= |y| |a3 b3| |k3| Bt is transpose of B Example | 3 4 | | 23 | B = | 2.2 7.2 | C = | 20 | | 9.2 6.1 | | 44 | z=(Bt*B)^(-1)*Bt*c | 3.65452 | | x | N=| 1.88069 | = | y | test of solution 3 * x + 4 * y = 18.4863 2.2 * x + 7.2 * y = 21.5809 9.2 * x + 6.1 * y = 45.0938 See http://mathworld.wolfram.com/Moore-PenroseMatrixInverse.html ======= System is underdefined Example w x y z | 2 3 4 5 | | 5 1 6 4 | -> B | 8 9 1 2 | | 40 | | 41 | -> C | 37 | Bt*(B*Bt)^(-1) *c -> N | 0.978043 | | w | N = | 2.02321 | = | x | | 3.03027 | | y | | 3.96424 | | z | 2*w + 3*x + 4*y + 5*z = 40 5*w + 1*x + 6*y + 4*z = 41 8*w + 9*x + 1*y + 2*z = 37 ===========================