1

What is the trigonometic functions optimization performance gain over standard methods in Java? Here for example : Fast transcendent / trigonometric functions for Java I've found some of the methods and libraries to perform similar tasks.

Community
  • 1
  • 1
luke1985
  • 2,281
  • 1
  • 21
  • 34
  • if you don't understand how it works, it is extremely unlikely that you require these functions. the built-in functions are likely better documented and maintained. – Kent Dec 16 '13 at 13:56
  • @Builder_K I would like first to consider the performance gains so I know if it is even worth to get in depth with this topic at all. – luke1985 Dec 16 '13 at 14:05

1 Answers1

1

It is also depend on JDK implementation, functions in StrictMath are native.

One of approach is to use some function derived from Taylor series subset.

I remembered the another interesting approach to function calculation. Let say you need to have 3d rotating and all arguments are in limited integer subset (0..180)/PI. So you build precalculated table of values and next use it.

double[]result=new double[180];
for(int i=0; i<180; i++) results[i]=Math.sin(i/Math.PI);//end of init
double sin(int value){return result[i];}
Sergei Chicherin
  • 2,031
  • 1
  • 18
  • 24
  • Great, but this doesn't answer the question: what were the performance gains? – luke1985 Dec 16 '13 at 14:02
  • gains from which method? You can use CPU sin - performance gain from direct single call to CPU , use another approximation, performance gain from less number of arithmetic operations, use the pre-calculated values, performance gain from direct memory call instead of calculation. – Sergei Chicherin Dec 16 '13 at 14:07
  • Elaborate. I guess you have some practical experience doing this, so you can post your observations. – luke1985 Dec 16 '13 at 14:11