According to Wolfram Mathematica: cos(50) = 0.6427876096865394;
But this code in Java:
System.out.println(Math.cos(50));
gives 0.9649660284921133.
What is wrong with java.lang.Math
?
According to Wolfram Mathematica: cos(50) = 0.6427876096865394;
But this code in Java:
System.out.println(Math.cos(50));
gives 0.9649660284921133.
What is wrong with java.lang.Math
?
Math.cos()
expects the parameter to be in radians. This will return the result you need:Most Java trigonometric functions expects parameters to be in radians. You can use Math.toRadians() to convert:
Math.cos()
uses radians, so to get your expected result you need to doDegrees <> radians...........
For me...
returns
0.9649660284921133
0.9649660284921133
0.6427876096865394
0.6427876096865394
http://www.wolframalpha.com/input/?i=cos%2850deg%29
cos(50deg)
give same result ascos(50)
... so Wolfram is degree by default.