Protip: Don’t come home at 4am, decide not to go bed and instead write some code…it might look like this: http://pastebin.java-gaming.org/a71aa0c1f6a. That code is totally broken…I didn’t even check that the min-max method hadn’t converged. But, now a few hours later I realize that it doesn’t really matter. The point of throwing that together was to be able to do a side-by-side comparison of a polynomial of a given degree with table based in Riven’s microbench marks as data points…so only the form and number of term really matters. All of these are formulated in Horner, so no attempt to break up dependency chains (thankfully I can’t image what that might have ended up looking like).
What I see using 64 bit build 1.7.0_21-b11, with: -X:MaxInlineSize=100 -XX:CompileThreshold=1000. I set the first because it might be why Riven is seeing a slowdown when breaking dependency chains and you probably do want to use a higher value than the default in general (39 is what I think it is and the number is the count of java bytecodes). The second option is to be mostly avoided as it will cut short collecting of profiling information and cause routines that probably don’t been to be compiled to be, well, compiled.
bad_sin_0 is just an equivalent to Riven’s original power series (minus doubles and nested) and is slightly faster than “half”.
bad_sin_3 is about the mid-point of full and half. This form on +/-{pi, pi/2, pi/4} have relative error values of ~{.0000167044, 5.3134810-9 , 4.5408410-12}
bad_sin_5 is about the same speed as “full”. This form on +/-{pi, pi/2, pi/4} have relative error values of ~{.0194862, .000108162, 1.5071*10-6}
Well, assuming I didn’t screw up again.