by vegesm on 3/7/24, 6:59 PM with 163 comments
by staplung on 3/8/24, 12:20 AM
If you're interested, you can peruse the C code that was used to generate the tables. Here's the file for sine/cosine:
https://github.com/RandalLinden/DOOM-FX/blob/master/source/m...
by warpech on 3/7/24, 7:30 PM
E.g. I would assume that Math.sin(x) returns the same thing in NodeJS on Windows and Mac/M1, but it turns out it is necessarily so. https://stackoverflow.com/questions/74074312/standard-math-f...
by jxy on 3/7/24, 8:05 PM
Plan 9: https://9p.io/sources/plan9/sys/src/libc/port/sin.c
Freebsd: https://cgit.freebsd.org/src/tree/lib/msun/src/k_sin.c
by microtherion on 3/7/24, 7:34 PM
by toolslive on 3/7/24, 11:18 PM
by tails4e on 3/7/24, 7:22 PM
by eska on 3/7/24, 7:46 PM
"Finding the BEST sine function for Nintendo 64"
by eh_why_not on 3/8/24, 12:11 AM
The degree-9 polynomial, said to be a thousand times better than the original Taylor approximation in maximum error, also appears to be very close to the Taylor series in the first place.
Rounding the Taylor coefficients to 6 digits after the decimal:
1/3! = 0.166667
1/5! = 0.008333
1/7! = 0.000198
1/9! = 0.000027(56)
The first 2 are exact, the third is 5 digits only (so 0.000190), and the fourth is more different starting from the 6th digit (0.000026019).
The delta in the 9-th order is expected if you were to truncate the Taylor series starting from the 11th order to infinity (+ x^11 / 11! - x^13/13! ...).
by azhenley on 3/7/24, 8:51 PM
by dboreham on 3/7/24, 7:38 PM
by duped on 3/7/24, 7:12 PM
by convolvatron on 3/7/24, 7:24 PM
by aidenn0 on 3/8/24, 11:12 PM
If you use cos(x) = 1 then you are still accurate to within 1%
[edit]
I think I also found an error in TFA? It seems like picking the "best" N would allow r to be in the range -pi/32 < r < pi/32, which makes the 3rd order Taylor series have an error of 4e-12, significantly better than the error range for 0 < r < pi/16
by vardump on 3/7/24, 7:39 PM
by Tade0 on 3/8/24, 9:23 AM
Couldn't wrap my head around the concept until the topic was revisited in college, but idea was there and helped me understand the tradeoffs brought by "fast math" libraries I was using during high school.
by t-3 on 3/7/24, 7:21 PM
by mettamage on 3/8/24, 2:16 AM
I’m brushing up my math basics (I graduated CS while dodging the math requirements) and it frustrates me that in trig I need to remember values at all. The values such as sqrt(2)/2 make sense but how hard is it to calculate sin(5 degrees) by hand?
by sema4hacker on 3/8/24, 4:55 AM
I wonder what the first program was that ever used a precomputed trig table.
by simonblack on 3/8/24, 1:35 AM
Any calculating job can be undertaken by a proper Turing machine. You just have to keep in mind the old triangle of usage: Cost, capability and speed.
If a human can calculate a sine, so can any full-blown computer.
by demondemidi on 3/8/24, 12:02 AM
by perihelions on 3/7/24, 8:00 PM
by deepthaw on 3/7/24, 8:38 PM
Given the ridiculous number of transistors and so on we can use in CPUs and GPUs nowadays how feasible is a relatively huge trig lookup table burned into rom?
by Solvency on 3/8/24, 12:32 AM
by paulpauper on 3/7/24, 7:05 PM
by amelius on 3/7/24, 7:23 PM