# Mathematical Functions

• Introduction

• Java has provided many useful Mathematical functions in its library.

• We will learn how to use some of these functions...

• Java's Math class

• Java's Math class contains many Mathematical functions, such as methods like sqrt (square root) and pow (power)

• To compute xn,   you write:

 ``` Math.pow(x, n) ```

• To take the square root of a number x,   you write:

 ``` Math.sqrt(x) ```

• To express the "a,b,c-formula" (for solving a quadratic equation) in Java:

We can write:

 ``` ( -b + Math.sqrt(b * b - 4 * a * c)) / (2 * a) ```

Here is how to read the Java expression:

• A partial list of Mathematical function in the Math class

• Here are some commonly used Math. functions that can be found in the Math class:

 Math.sqrt(x) square root Math.pow(x, y) power xy Math.exp(x) ex Math.log(x) natural log Math.sin(x), Math.cos(x), Math.tan(x) sine, cosine, tangent (x in radian) Math.round(x) closest integer to x Math.min(x, y), Math.max(x, y) minimum, maximum

• Self Check

• What is the value of
```	Math.sqrt(Math.pow(x, 2) + Math.pow(y, 2))
```
in mathematical notation?