Bifalgorithm post · Computer science one · Program Structure

How are common mathematical functions used in Java?

How are common mathematical functions used in Java? (Computer science one · Program Structure) — "There are many other important classes and packages provided…

Ideas in this flowchart

  • La clase Math del JDK proporciona funciones matemáticas comunes.
  • El JDK también proporciona muchas otras clases y paquetes importantes, que se examinan según sea necesario.
  • La biblioteca Math agrupa funciones matemáticas como la raíz cuadrada y el logaritmo natural.
  • Math.abs(x) calcula el valor absoluto y tiene una versión para cada tipo numérico, con el mismo nombre.
  • Math.ceil(x) calcula el techo y Math.floor(x) calcula el piso.
  • Math.cos(x), Math.sin(x) y Math.tan(x) calculan funciones trigonométricas.
  • Las funciones trigonométricas reciben valores en radianes, no en grados.
  • Math.exp(x), Math.log(x) y Math.log10(x) calculan funciones exponenciales y logarítmicas.
  • El argumento de las funciones logarítmicas debe ser positivo: x > 0.
  • Math.pow(x,y) calcula potencias y Math.sqrt(x) calcula raíces cuadradas.
  • Los métodos se invocan usando el nombre de la clase y el operador punto.
  • Por ejemplo, Math.sqrt(x) asigna √1.5 a y y Math.sin(x) asigna sin(1.5) a z cuando x vale 1.5.
  • El valor de x se pasa a la función, que calcula y devuelve un resultado para asignarlo a otra variable.
Feed/

How are common mathematical functions used in Java?

No cover

Channel

Computer science one

1 page

"There are many other important classes and packages provided by the standard JDK that we’ll examine as needed. Of immediate interest is the Math class and its library of common mathematical functions such as the square root and the natural logarithm. Several methods defined in the Java Math library include Math.abs(x) for the absolute value, Math.ceil(x) for the ceiling function, Math.floor(x) for the floor function, Math.cos(x) for the cosine function, Math.sin(x) for the sine function, Math.tan(x) for the tangent function, Math.exp(x) for the exponential function, Math.log(x) for the natural logarithm, Math.log10(x) for the logarithm base 10, Math.pow(x,y) for the power function, and Math.sqrt(x) for the square root function. There are several versions of the absolute value method, one for each numeric type but all with the same name. All trigonometric functions assume input is in radians, not degrees. The input for the logarithm functions is assumed to be positive, x > 0. To use these methods, invoke them by using the class name and dot operator. For example: double x = 1.5; double y, z; y = Math.sqrt(x); // y now has the value √x = √1.5; z = Math.sin(x); // z now has the value sin(x) = sin(1.5). In both of the method calls above, the value of the variable x is “passed” to the math function which computes and “returns” the result which then gets assigned to another variable."

Flowchart preview
👍
0
0 comments0 shares

Sign in to view and post comments.