logoalt Hacker News

tails4etoday at 5:13 PM2 repliesview on HN

How does this compare to CORDIC for sin/cos generation? Which is more accurate, etc ?


Replies

yoan9224today at 5:35 PM

Good question! CORDIC and HAKMEM Item 149 are both hardware-friendly, but have different trade-offs:

CORDIC: - Iterative algorithm (needs multiple clock cycles) - Accuracy improves with more iterations - Generates both magnitude and phase - Typical hardware implementation: 12-16 iterations for decent precision

HAKMEM (Item 149): - Single-cycle computation (just two adds per step) - Uses the recurrence: x' = x - εy, y' = y + εx - Accuracy depends on word width and epsilon choice - Numerically stable in exact arithmetic if ε² < 2

a1k0ntoday at 5:34 PM

CORDIC is more accurate, but takes as many iterations as you have bits of precision in your angle. Another demo called Warp in this contest used pipelined CORDIC to do atan2 on every pixel to create a tunnel, which is super impressive.

https://www.youtube.com/watch?v=K9mu3getxhU&t=780s