Using spherical coordinate to identify the longitude and latitude of a coordinate. I am trying to find out the longitude and latitude of a coordinate using spherical coordinate:
$$x=r\cos⁡(v)\cos(u),\quad\quad y=r\cos⁡(v)\sin⁡(u),\quad\quad z=r\sin⁡(v),$$
where $(v)$ indicates latitude, and $(u)$ indicates longitude, $r$ indicates radius of the Earth 6371km.
Then, using trigonometry I had find out that the longitude and latitude can be represented as:

Hence, with the coordinate $(-1800, 6001, 1196)$, I was able to find the longitude $106.70^\circ$, with latitude $10.80^\circ$.
For verifying this method works, using the calculated longitude and latitude, I was able to find out the original coordinate $(-1800, 6001, 1196)$, with the spherical coordinates.
However, with the coordinate $(-4377, 4632, 3991)$ I have calculated that the longitude is $133.38^\circ$, latitude is $10.80^\circ$, but by using this calculated longitude and latitude to find out the original coordinates, it comes out a result of $(-3410, 3609, 3991)$, which does not match with original coordinate.
May I know the reason why there is an error coordinate $(-4377, 4632, 3991)$? Thank you.
 A: None of your sets of coordinates are exactly on the surface of a sphere of radius $6371.$
For example, the coordinates $(x,y,z) = (-1800, 6001, 1196)$ are at a distance $6378.3$ from the origin.
However, the coordinates $(−4377,4632,3991)$ are really far out:
they are at a distance $7519.4$ from the origin.
The formulas you are using will preserve the $z$ coordinate in the translation to and from latitude -- the latitude is incorrect since it assumes a value of $r$ at that point much smaller than the actual value, but the error in the conversion from $z$ to latitude is exactly counteracted  by an error in the conversion from latitude to $z$ with the same wrong radius.
But when you convert the longitude of this far-out point back to $x$ and $y$ coordinates you get a point that is close to radius $6371$
(as close as you could be, or nearly so, considering that you seem to be rounding all coordinates to integers).
If you convert latitude and longitude to $(x,y,z)$ using formulas that assume a point at distance $6371$ from the origin, you will never recover the coordinates of points that are much farther from the origin or much closer to it.
