I am wondering how Java finds sin(x). I looked at the Math.sin
and it doesn't really give an answer. Please don't just say it's Taylor Series, I study math so I know it's not that simple. :)
I also checked Strict Math class and since all those JVM have different algorithms, can someone give an example on one?
So far, this is my algorithm based on Taylor series :
if( (i%4) == 0)
suma = suma + Math.sin(x0) * Math.pow(x-x0, i) / faktorijal(i);
if( (i%4) == 1)
suma = suma - Math.cos(x0) * Math.pow(x-x0, i) / faktorijal(i);
if( (i%4) == 2)
suma = suma - Math.sin(x0) * Math.pow(x-x0, i) / faktorijal(i);
if( (i%4) == 3)
suma = suma + Math.cos(x0) * Math.pow(x-x0, i) / faktorijal(i);
Where x0 is the point around which I am looking for sin(x) and faktorijal is !i;