Page 147 - CA_Blue( J )_Class9
P. 147

9             System.out.println("Math.cbrt(-27.0)     : " + Math.cbrt(-27.0));
                  10             System.out.println("Math.pow(3,2)        : " + Math.pow(3,2));

                  11             System.out.println("Math.ceil(3.4)       : " + Math.ceil(3.4));
                  12             System.out.println("Math.floor(-5.8)     : " + Math.floor(-5.8));

                  13             System.out.println("Math.exp(2)          : " + Math.exp(2));
                  14             System.out.println("Math.abs(-4.4)       : " + Math.abs(-4.4));

                  15             System.out.println("Math.log(1)          : " + Math.log(1));
                  16             System.out.println("Math.round(3.4)      : " + Math.round(3.4));

                  17             System.out.println("Math.rint(2.5)       : " + Math.rint(2.5));
                  18             System.out.println("Math.random()        : " + Math.random());

                  19          }
                  20      }

                 You will get the following output:





























                 7.2.14 Trigonometric Functions
                 There are three different Trigonometric functions that are used in Java. They are:

                               Function Name             Syntax                    Description
                            Math.sin              Math.sin(value)      Returns the sine value of the angle
                            Math.cos              Math.cos(value)      Returns the cosine value of the angle
                            Math.tan              Math.tan(value)      Returns the tangent value of the angle

                 It returns value in double. The arguments that are passed are in Radians which is generally derived from degrees.
                 To convert degree to radian, we use the following formula:

                 Radian = (p * degree given)/180.0
                 If double degree = 30, radian;
                 radian = (22.0/7.0*30)/180.0 = 0.5238


                                                                                    Mathematical Library Methods   145
   142   143   144   145   146   147   148   149   150   151   152