Built-in Elementary Math Functions
Elementary math functions for use in methods are available in the Java math library. Some examples:
double a = Math.PI;       // the mathematical constant pi
double b = Math.sin(3*a); // trigonometric sine function
double c = Math.cos(4*a); // trigonometric cosine function
double d = Math.random(); // random number uniformly distributed in [0,1)
double e = Math.exp(2*a); // exponential function
double f = Math.log(1+e); // natural base e logarithm
double g = Math.pow(10,3); // power function
double h = Math.log10(2.5); // base 10 logarithm
double k = Math.sqrt(81.0); // square root
There are several more math functions available in the Java math library. For additional information, see any Java book or online resource.