0

There is a piece of code I've found in the other topic (Multilateration of GPS Coordinates), that is supposed to solve a matrix by SVD method. I was using it but now I have to be able to explain the mechanism of the code and I can't find the mathematical reason for its simplicity:

    A = np.array(A)
    (_,_,v) = np.linalg.svd(A)
    # Get the minimizer
    w = v[3,:]
    w /= w[3]

Yet, it works in my case. Here's an example of one of my matrices and solutions:

Matrix A
[[ 0.01944444 -0.91680556  0.4567078 ]
 [ 0.         -0.93430556  0.47549222]]

Matrix v
[[-0.00927192  0.89308049 -0.44980137]
 [-0.91093059  0.1779953   0.37218697]
 [ 0.41245545  0.41318872  0.81188398]]

Solution:
0.508022647987   0.508925817052

The two columns on the left are the matrix A and the column on the right is the matrix b in the matrix of a form Ax = b, but the code combines them into one matrix for some reason. I know there is the least squares method but after testing it, it's not so robust and accurate when the matrix is overdetermined.

  • Have you looked at what [np.linalg.svd](https://docs.scipy.org/doc/numpy-1.13.0/reference/generated/numpy.linalg.svd.html#numpy.linalg.svd) is doing? Perhaps your answer is there. – Gabriel Apr 10 '18 at 12:29
  • Yes, I've looked at svd based method of solving matrices but all of them are much more complex than taking one row of matrix and dividing it by the last element of the row. Unless my matrices are a special case. – romdamia2000 Apr 10 '18 at 12:35
  • Can you clean up the example and give code that works on it? I'm having a hard time understanding which is the A vs b vs x in your `A . x = b`. The code is grabbing the 4th right singular vector (likely because it's building the null space of A, to solve it), but your examples aren't 4-dimensional. Make an [MCVE](https://stackoverflow.com/help/mcve) to show what's happening so we can be sure we understand. – Ahmed Fasih Apr 18 '18 at 02:12

0 Answers0