Find a Point from 3 or 4 distances with errors I have 3 reference points in a 3d space, P1, P2, P3, with known coordinates. P1, P2 and P3 are at different positions to each other.
I have a fourth point, P0, which I need to locate, and I have a distance measurement from P0 to each of the known reference points P1, P2, P3, which we can call D1, D2, D3. Each distance measurement has a potential error, which we can call E1, E2, E3 (a maximum amount it might be wrong, though that might be in either direction, eg true distance between P0 and P1 is between D1-E1 and D1+E1).
How can I work out the position of P0?
I know that the location could best be described as a shape which is the intersection or near intersection of three spherical shells, each centered on the points P1-P3, with thickness equivalent to 2xE1 (or E2 or E3). Ideally, I would like a way to calculate a specific 'best guess' location, perhaps by assuming the errors are zero, or at the center of the intersectional shape, or something - I'm not sure what would be best - and also calculate the possible error in that point. At the least, I need a 'best guess' single point.
I know this is possible as GPS uses a similar calculation.
I found https://www.maa.org/sites/default/files/pdf/cms_upload/Thompson07734.pdf which suggests a fourth reference point is required. That would be acceptable if so (call it P4, with E4. But I get stuck at the formula at the top of page 265.
I also found https://inside.mines.edu/~whereman/papers/Murphy-Hereman-Trilateration-MCS-07-1995.pdf but I get really lost in that.
Ideally I'm looking for a formula, or algorithm, or code.
If the above is too difficult, my backup question would be would be to assume P1, P2 and P3 are on one of the axes (and an optional P4 at the origin if needed) - P1 is on the X axis, distance o1 from the origin, P2 is on the Y axis, distance o2 from the origin, P3 is on the Z axis, distance o3 from the origin (and P4 is at the origin). Please specify if your answer is based on this.
 A: The three reference points define a plane which contains them.
So we can take a reference system having that plane as, e.g., the $x-y$ plane, and a $z$ axis normal to it.
Then, visually speaking, you have to construct a "tent" ($3$-D simplex) based on the three points, with three poles of length given by the measured distances and determine the vertex.
The problem is that you can construct the same tent also in the negative $z$ direction: that's why you shall need a fourth reference point to determine on which side of the $z$ axis $P_0$ is (unless you know that a priori).
In any case this is a problem to be solved in terms of Barycentric Coordinates, which is a well known and utilized method: in the cited article you can find the basics to convert to/from barycentric and euclidean coordinates.
A: I would first set $P_i$ to be at $(x_i,y_i,z_i)$ for easy reference.
Then using the distance formula we have
$$\left(D_i-E_i\right)^2\le(x_0-x_i)^2+(y_0-y_i)^2+(z_0-z_i)^2\le\left(D_i+E_i\right)^2$$
which is a region between two spheres centred at $P_i$ with the smaller one of radius $D_i-E_i$ and the larger one of radius $D_i+E_i$.
Eventually, you can form three of these inequalities (or equations if you take $E_i=0$) and solve for the locus/coordinates of the point $P_0$. This is very easily done with a help of a graphic software (e.g. GeoGebra, which is full-featured and free). Here is an example I just made in Geogebra assuming $E_i=0$.
The inequality above is also actually equivalent to the equations in page 265. It's just a matter of notational differences.
