It returns a different result only when (x + 1) causes a loss of accuracy, i.e. x is many orders of magnitude greater or less than one.
But I don’t think it’s difficult or clever, I think it’s just wrong .
cos(0) = 1 but f(1) = -pi/2
cos(pi/2) = 0 but f(0) = 0
cos(pi) = -1 but f(-1) = pi/2
where f(x)is the implementation of Vincent arccos. All of them are disabled on pi/2, the linear approximation, which will get at least these three points correctly, will be
g(x) = (1 - x) * pi / 2
source
share