Mathematical operations in Java: java.util.Math

The table below shows the relative performance of various functions provided by the Math class, based on measurements made on an Intel Pentium.

MethodOperationApprox time
(compared to floating point addition)
Math.exp(x)ex9
Math.log(x)log2 x27
Math.sqrt(x)x10
Math.sin(x)sin x16
Math.cos(x)cos x20
Math.pow(x, y)xy15 or 150
Math.exp(y * Math.log(x))90