Hacker News new | ask | show | jobs
by Asooka 3417 days ago
You can use a LUT, but that's not required to define sin and cos. You can define them perfectly fine as

sin(kπ) = 0 sin(kπ + ½π) = (-1)^k cos(kπ) = (-1)^k cos(kπ + ½π) = 0 dsin/dx = -cos dcos/dx = sin

Sine and cosine are the only smooth continuous functions that are solutions to that system of equations. There are also numerous geometric ways to define them. That's what's meant by "understanding". If all you had was the LUT and no other way to compute the value of sine, then you don't really understand what sine is.

1 comments

Table lookup is a common solution when a FPU isn't available and speed is a higher priority than accuracy.

I've actually used formulas for trig functions before with IEEE double floating-point until the accuracy didn't improve.

(think it was a continued fraction or or some other technique I didn't understand, didn't -lm or something for builtin functions and worked around it lol...)

It was very slow! Makes your computer's fan spin faster, even changes the smell in the room while grinding away!