I know that I should use a tolerance for comparing floating point numbers. But for comparing vectors, I can think of 3 possible solutions corresponding to different distance metrics:
- Compare the components of each vector individually: the vectors are equal if all 3 are within tolerance. This option would behave like the uniform norm, giving a cube of tolerance.
- Compare the sum of all the absolute differences to some tolerance. This would behave like the taxicab norm, giving a simplex of tolerance.
- Calculate the Euclidean length of (vecA - vecB) and see if it's within tolerance. This would give the standard Euclidean norm with a sphere of tolerance.
But my main concern is numerical stability. Euclidean norm "feels like" the best option, but I'm worried that all the calculations would induce more rounding errors. To a lesser extent option 2 could also introduce errors. (For example, if the x component of the vectors is much larger than y and z, adding together all the differences could swamp any contributions from y and z.) So I'm currently leaning towards option 1.
Can anyone weigh in with an authoritative take on this problem?