0

I'm trying to find the coordinates of a point in cartesian space knowing only how far it is from other known points. I originally tried scipy.optimize.fsolve with 3 distance formulas and quickly learned that 4 distances are necessary because 3 spheres may overlap in up to 2 different locations.

scipy.optimize.fsolve does not seem to work when I have more equations than I have variables. With fsolve, I tried:

from scipy.optimize import fsolve


def func1(C):
    func =     [(atom14[0]  - C[0])**2 + (atom14[1]  - C[1])**2 + (atom14[2]  - C[2])**2 - Cdist1**2]
    func.append((atom106[0] - C[0])**2 + (atom106[1] - C[1])**2 + (atom106[2] - C[2])**2 - Cdist2**2)
    func.append((atom125[0] - C[0])**2 + (atom125[1] - C[1])**2 + (atom125[2] - C[2])**2 - Cdist3**2)
    func.append((atom76[0]  - C[0])**2 + (atom76[1]  - C[1])**2 + (atom76[2]  - C[2])**2 - Cdist4**2)
    return func

solve = fsolve(func1, [0, 0, 0])

where atomxxx[0:3] are known x, y, z cartesian coordinates of each of the 4 other points in space and Cdist# are the distance of the desired point from each.

I am overwhelmed by the other optimization options, many of which require different syntax I am unfamiliar with (new to this library). What can I use to solve this 3 dimensional problem with at least 4 equations?

Thanks

M N
  • 1
  • 1
  • 1
    Instead of solving (which will not work in general for real world data, due to noise etc.) you look for the point that minimizes some measure of the total error in your distance measurements -- often the sum of squares of errors in distance measurements. If your measurements are exact then this will be zero at the correct location, and minimizing is equivalent to solving. – Michael Anderson Jun 23 '15 at 07:49
  • Yes, I have a special case here where I do have very precise numbers for everything, so I should find the result within the convergence criteria I am more in need of a numerical method within python / scipy to accomplish it, and a little advising as to syntax since I am unfamiliar – M N Jun 23 '15 at 08:17

0 Answers0