Re:Implementing Cosine in C from Scratch (2020)
by lifthrasiir on Tuesday March 29, 2022 @03:36PM
(#30847338)
Yeah, sine and cosine are not as sensitive (but note that many libms target 1 or 1.5 ulp error for them, so a 0.5 ulp error might still be significant). For tangent however you definitely need more accurate range reduction.
Re:Implementing Cosine in C from Scratch (2020)
by adgjlsfhk1 on Tuesday March 29, 2022 @03:31PM
(#30847267)
Double rounding can still bite you. You are forced to incur up to half an ulp of error from your polynomial, so taking another half ulp in your reduction can lead to a total error of about 1 ulp.
Also, in case of confusion, I was specifically commenting on the function over the [-pi/4, pi/4] domain in https://github.com/ifduyue/musl/blob/master/src/math/__cos.c , which the comment in https://news.ycombinator.com/item?id=30846546 was presumably about.