# Python Trigonometric Functions

Before jumping right into the functions and how to use them we need to know what do trigonometric functions mean and how many functions does python has.

## What are Trigonometric functions?

Trigonometric functions are the functions of an angle of a triangle. These trigonometric functions definite connection between the angles of a triangle.

## Trigonometric Functions in Python

Python math module (it comprises of the mathematical functions) has plenty of trigonometric functions. Trigonometric functions can be used by using “import math”.

`math.function_name(parameter)# or import the math moduleImport math`

Degrees(value): This method helps convert the value into degrees from radians.

Example:

`import mathprint(math.degrees((math.pi/2)))`

Output

`90.0`

Example:

`import mathprint(math.radians(60))`

Output:

`1.0471975511965976`

Types of Functions in python

1. Sin(x) Function

Sin(x) returns sine value which is passed as an argument.

2. Cos(x) Function

Cos(x) returns cosine value which is passed as an argument.

3. Tan(x) Function

Tan(x) returns a tangent value of the parameter which is passed, that is angle of sine/cosine .” X” should be an angle represented as a radian.

Example :

`import mathprint(math.sin(math.pi/3))print(math.tan(math.pi/3))print(math.cos(math.pi/6))`

Output:

`0.86602540378443861.73205080756887670.8660254037844387`

Note: Input in trigonometric functions in python are represented in radians.

1. asin(X) Function

asin(X) returns the inverse value of sine, called as “arc sine of a complex number”. -1 to 1 should be the range and represented in radians. Output a floating-point number.

2. acos(x) Function

acos(x) Function returns the inverse value of cosine, called “arc cosine of a complex number”. -1 to 1 should be the range and represented in radians. Output is a floating-point number.

3. atan(x) Function

atan(x) Function returns the inverse value of tan, called as “arc tangent of the complex number”. -1 to 1 should be the range and represented as

(math.sin(math.pi / 4)) / (math.cos(math.pi / 4)). Output is floating point number.

Example:

`import mathprint(math.asin(1))print(math.acos(0))print(math.atan(1))`

Output:

`1.57079632679489661.57079632679489660.7853981633974483`

1. sinh(x) Function

sinh(x) returns the “hyperbolic sine of the angle” of the input.

2. cosh(x) Function

The cosh(x) returns the “hyperbolic cosine of the angle” of the input.

3. tanh(x) Function

tanh(x) returns the “hyperbolic tangent of the angle” of the input.

Example:

`import cmathx = 1.0y = 1.0z = complex(x,y)print (cmath.sinh(z))print (cmath.cosh(z)) print (cmath.tanh(z))`

Output:

`(0.6349639147847361+1.2984575814159773j)(0.8337300251311491+0.9888977057628651j)(1.0839233273386946+0.2717525853195118j)`

Note: cmath module comprises a set of methods and constants. Used when the user uses complex numbers for mathematical operations.

1. asinh(x) Function

asinh(x) returns the “inverse of hyperbolic sine of the angle” of the number.

2. acosh(x) Function

acosh(x) returns the “inverse of hyperbolic cosine of the angle” of the number.

3. atanh(x) Function

atanh(x) returns the “inverse of the hyperbolic tangent of the angle” of the number.

Example:

`import cmatha = 1.0b = 1.0c = complex(a,b)print (cmath.asinh(c))print (cmath.acosh(c)) print (cmath.atanh(c))`

Output:

`(1.0612750619050357+0.6662394324925153j)(1.0612750619050357+0.9045568943023813j)(0.40235947810852507+1.0172219678978514j)`

1. atan2(y, x) Function

This function means atan2(y/x). Y and X are both numeric values. This function returns a value that falls between -pi and pi.

Example:

`print(math.atan2(1.2,1.3))`

Output:

`0.7454194762741583`

2. hypot(x, y) Function

in-built function in python in math module that returns Euclidean norm, Syntax :

`hypot(x, y)`

Parameters :

` x and y are numeric values`

Returns :

`Returns a float value having Euclidean norm, sqrt(x*x + y*y).`

Error :

`When two  or more arguments arepassed, it returns a TypeError.`

Note: When values will be compared to numeric values .decimal places might be different and can be ignored.

Can we get errors?

Yes, you can get errors and there are two kinds of errors.

1. TypeError: when a non-numeric value is passed to the trigonometric methods.
2. ValueError: when an invalid value is passed to trigonometric methods.

## Conclusion

In this article, we learned about how we can use various trigonometric methods in python by importing mat module by using “Import math”. Just remember not to pass invalid parameters to trigonometric methods. Pass values in degrees to convert in radians and vice-versa.