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
?
The Math. cos() function returns the cosine of a number in radians.
In Python, math module contains a number of mathematical operations, which can be performed with ease using the module. math. cos() function returns the cosine of value passed as argument. The value passed in this function should be in radians.
The cosine is equal to the ratio of the side adjacent to the angle and the hypotenuse of the right-angled triangle they define. The angle must be measured in radians.
The Math. cos() method is used to return the cosine of a number. The Math. cos() method returns a numeric value between -1 and 1, which represents the cosine of the angle given in radians.
Math.cos()
expects the parameter to be in radians. This will return the result you need:
Math.cos(Math.toRadians(50));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With