Page 105 - CA_Blue( J )_Class10
P. 105
You will get the following output:
6.1.14 Trigonometric Methods
There are three different trigonometric methods that are used in Java. They are:
• Math.sin( ): It returns the trigonometric sine of an angle. The value of the angle should be in radian.
• Math.cos( ): It returns the trigonometric cosine of an angle. The value of the angle should be in radian.
• Math.tan( ): It returns the trigonometric tangent of an angle. The value of the angle should be in radian.
The output of these methods is of double data type. To convert degree to radian, we use the following formula:
radian = (π * degree - given)/180.0;
If degree = 30, then radian is:
radian = (22.0/7.0*30)/180.0;
double r = Math.sin(radian); // Output: 0.5
double r = Math.cos(radian); // Output: 0.865
double r = Math.tan(radian); // Output: 0.5776
Function Description Return Data Type Syntax
min(a,b) Returns the smaller number between a and b int/long/float/double Math.min(a,b);
max(a,b) Returns the greater number between a and b int/long/float/double Math.max(a,b);
sqrt(a) Returns the square root of a positive number. double Math sqrt(a):
cbrt(a) Returns the cube root of a number. double Math.cbrt(a);
pow(a,b) Returns the value ab. double Math.pow(a,b);
abs(a) Returns the absolute value (magnitude) of any number. int/long/float/double Math.abs(a):
round(a) Returns the rounded value up to the nearest integer. int/long Math.round(a):
floor(a) Returns the rounded value down to the nearest integer. double Math.floor(a);
Returns the whole number greater than or equal to the
ceil(a) double Math.ceil(a);
number.
rint(a) Returns the truncated value number. double Math.rint(a);
random() Returns a random number between 0 and 1. double Math.random();
log(a) Returns the value of natural logarithm of a number. double Math.log(a):
exp(a) Returns an exponent value, i.e., e double Math.exp(a);
sin(a) Math.sin(a);
cos(a) Returns the Sine/Cosine/Tangent of an angle a (expressed double Math.cos(a):
tan(a) in radians). Math.tan(a):
103
Mathematical Library Methods 103

