Updated June 26, 2023

## Introduction to Trigonometric Functions in Python

The real functions used to relate the angle of a right-angled triangle to the ratios of the two sides lengths are called trigonometric functions. Scientists apply trigonometric functions in fields such as navigation, solid mechanics, celestial mechanics, and geodesy, all of which are related to geometry. The standard module in Python is the math module and is always available. To use the various mathematical functions of the math module, import it using the command “import math.” This module does not support complex data types. The Cmath module supports complex data.

The math module in Python contains built-in functions that can perform trigonometric calculations. You can minimize the number of lines in your code with the Python math module. We can import the math module or use the dot operator with a math library to use trigonometric functions.

- To import the math module,

`Import math`

- To reference the math library with the dot operator,

`Math.function_name(parameter)`

**Note:**All the trigonometric functions in Python consider the input angle regarding radians.

Two helper methods can convert the values in radians to degrees and degrees to radians. They are:

- degrees(value)

This method converts the passed value in radians to degrees.

- radians(value)

This method converts the passed value in degrees to radians.

### Top Trigonometric Functions in Python

There are several trigonometric functions in Python. They are:

#### 1. sin(x) Function

This function returns the sine of the value passed as an argument. Here x is passed as an argument. The input value x should be in radians to represent an angle.

**Code:**

```
import math
x = 1
print(math.sin(x));
```

**Output:**

#### 2. cos(x) Function

The function returns the cosine of the value passed as an argument. Here x is passed as an argument. The input value x must represent an angle in radians.

**Code:**

```
import math
x = 1
print(math.cos(x));
```

**Output:**

#### 3. tan(x) Function

The function returns the tangent of the value (i.e., sine/cosine) passed as an argument. Here x is passed as an argument. The input value x needs to represent an angle using radians.

**Code:**

```
import math
x = 1
print(math.tan(x));
```

**Output:**

#### 4. asin(x) Function

This function returns the inverse sine of a given value. The inverse of the sine is also called the arc sine of the complex number. You must express the input value x as an angle in terms of radians. The input should be within the range of -1 to 1. The output is returned as a floating-point number.

**Code:**

```
import math
print(math.asin(1))
```

**Output:**

#### 5. acos(x) Function

Using this function returns the inverse of the cosine. The inverse of the cosine is also called the arc cosine of the complex number. The input value x must be an angle expressed in terms of radians. The input should be within the range of -1 to 1. The function returns the output as a floating-point number.

**Code:**

```
import math
print(math.acos(1))
```

**Output:**

#### 6. atan(x) Function

This function returns the inverse of the tangent. A complex number arc tangent can also refer to the inverse of cosine. The input value x must represent an angle in radians. The input should be within the range of -1 to 1. The function returns the output as a floating-point number.

**Code:**

```
import math
print(math.atan(1))
```

**Output:**

#### 7. sin(x) Function

The function receives a complex number as an argument, denoted by “x. This method returns the hyperbolic sine of the angle corresponding to the value passed as an argument.

**Code:**

```
import cmath
a = 1.0
b = 1.0
c = complex(a,b)
print("The value of hyperbolic sine is",cmath.sinh(c))
```

**Output:**

#### 8. cosh(x) Function

You must pass a complex number named “x” as an argument to the function. This method returns the hyperbolic cosine of the angle of the value passed as an argument.

**Code:**

```
import cmath
a = 1.0
b = 1.0
c = complex(a,b)
print("The value of hyperbolic sine is",cmath.cosh(c))
```

**Output:**

#### 9. tanh(x) Function

The function takes a complex number, x, as an argument. This method returns the hyperbolic tangent of the angle of the value passed as an argument.

**Code:**

```
import cmath
a = 1.0
b = 1.0
c = complex(a,b)
print("The value of hyperbolic sine is",cmath.tanh(c))
```

**Output:**

#### 10. asinh(x) Function

The inverse of the hyperbolic sine of the complex number is returned.

**Code:**

```
import cmath
a = 1.0
b = 1.0
c = complex(a,b)
print("The value of inverse hyperbolic sine is",cmath.asinh(c))
```

**Output:**

#### 11. acosh(x) Function

The function returns the inverse hyperbolic cosine of the complex number.

**Code:**

```
import cmath
a = 1.0
b = 1.0
c = complex(a,b)
print("The value of inverse hyperbolic sine is",cmath.acosh(c))
```

**Output:**

#### 12. atanh(x) Function

The function returns the inverse hyperbolic tangent of the complex number.

**Code:**

```
import cmath
a = 1.0
b = 1.0
c = complex(a,b)
print("The value of inverse hyperbolic sine is",cmath.atanh(c))
```

**Output:**

### Recommended Articles

This is a guide to Trigonometric Functions in Python. Here we discuss the basic concept, the top 12 trigonometric functions in PPython, and code implementation. You may also look at the following articles to learn more-