Your formulas for calculating x, y, and z are significantly different from what I’ve always used which is based off of various websites that mention D, V, and W. So what’s worked for me is this:
(Source: this topic)
But maybe part of the issue you’re having is that the level of precision calculated may not be enough to register for small movements. See Haversine Formulas (Or ACOS/COS/SINor SQT) Not functioning with Sensor Location - #17 by manyone.