by mockery · 3y ago · 0 comments
* since cos(x+y) ~ cos(x) - sin(x)*y
* ~ cos(x) - x*y,
For the first, maybe it's an approximate identity I'd never heard of?For the second, it seems like it relies on X being small, but in this code... Y might be small enough for sin==identity approximation, but X isn't, is it?
The second line, I believe, is not relying on x being small, but rather relying on sin(x)*y being small. The whole result of the sin(x)*y term is approximately on the order of the LSB of the result, and the relative error of approximating sin(x) using 1 is better than using 0, so this term will help produce more accurate rounding of the bottom bits.
So using the cosine of sum formula:
* cos(x + y) = cos(x) cos(y) - sin(x) sin(y)
* ~ cos(x) - x*y. cos(x+y) = cos(x)*cos(y) - sin(x)*sin(y) (always)
~ cos(x)*1 - sin(x)*y (if y small)
Can't speak for the validity of small angle assumptions though.