In Python, we can easily do trigonometry with the many trig functions from the Python math module. In this article, you will learn about all the trigonometric functions that you can use in Python to perform trigonometry easily.
In Python, we can easily use trigonometric functions with the Python math module. The Python math module allows us to perform trigonometry easily.
In this article, we are going to go over all of the trig functions you can use in Python and give examples of how to use each one.
Below is a list of each of the trigonometric functions you can use in Python. If you want, you can keep scrolling or click on one of the links below to go to a section directly.
- pi in Python
- Python radians() Function
- Python degrees() Function
- Python sin() Function
- Python cos() Function
- Python tan() Function
- Python asin() Function
- Python acos() Function
- Python atan() Function
- Python atan2() Function
- Python sinh() Function
- Python cosh() Function
- Python tanh() Function
- Python asinh() Function
- Python acosh() Function
- Python atanh() Function
How We Can Use Pi in Python
When doing trigonometry, the most fundamental number is pi.
To get the value of pi in Python, the easiest way is use the Python math module constant pi. math.pi returns the value 3.141592653589793.
import math
print(math.pi)
#Output:
3.141592653589793
How to Convert Degrees to Radians with radians() Function in Python
When working with angles, it’s important to be able to convert between radians and degrees easily. We can convert degrees to radians using the Python math module radians() function from the math module.
The radians() function multiplies the degrees by pi divides by 180.
Below are some examples of how we can use the radians() function to convert degrees to radians in Python.
import math
print(math.radians(0))
print(math.radians(30))
print(math.radians(60))
print(math.radians(90))
#Output:
0.0
0.5235987755982988
1.0471975511965976
1.5707963267948966
How to Convert Radians to Degrees with degrees() Function in Python
When working with angles, it’s important to be able to convert between radians and degrees easily. We can convert radians to degrees using the Python math module degrees() function from the math module.
The degrees() function multiplies the radians by 180 and divides by pi.
Below are some examples of how we can use the degrees() function to convert radians to degrees in Python.
import math
print(math.degrees(0))
print(math.degrees(math.pi/6))
print(math.degrees(math.pi/3))
print(math.degrees(math.pi/2))
#Output:
0.0
29.999999999999996
59.99999999999999
90.0
How to Find Sine of Number with sin() Function in Python
To find the sine of a number, in radians, we use the Python sin() function.
The input to the sin() function must be a numeric value. The return value will be a numeric value between -1 and 1.
Below are a few examples of how to use the Python sin() function to find the sine of a number.
import math
print(math.sin(math.pi/3))
print(math.sin(0))
print(math.sin(math.pi/2))
#Output:
0.8660254037844386
0.0
1.0
How to Find Cosine of Number with cos() Function in Python
To find the cosine of a number, in radians, we use the Python cos() function.
The input to the cos() function must be a numeric value. The return value will be a numeric value between -1 and 1.
Below are a few examples of how to use the Python cos() function to find the cosine of a number.
import math
print(math.cos(math.pi/3))
print(math.cos(0))
print(math.cos(math.pi/2))
#Output:
0.5000000000000001
1.0
6.123233995736766e-17
How to Find Tangent of Number with tan() Function in Python
To find the tangent of a number, or the sine divided by the cosine of an angle, in radians, we use the Python tan() function.
The input to the tan() function must be a numeric value. The return value will be a numeric value between negative infinity and infinity.
Below are a few examples of how to use the Python tan() function to find the tangent of a number.
import math
print(math.tan(math.pi/3))
print(math.tan(0))
print(math.tan(math.pi/2))
#Output:
1.7320508075688767
0.0
1.633123935319537e+16
How to Find Arcsine of Number with asin() Function in Python
To find the arcsine of a number, we use the Python asin() function.
The input to the asin() function must be a numeric value between -1 and 1. The return value will be a numeric value between -pi/2 and pi/2 radians.
Below are a few examples of how to use the Python asin() function to find the arcsine of a number.
import math
print(math.asin(0.5))
print(math.asin(0))
print(math.asin(-0.75))
#Output:
0.5235987755982989
0.0
-0.848062078981481
How to Find Arccosine of Number with acos() Function in Python
To find the arccosine of a number, we use the Python acos() function.
The input to the acos() function must be a numeric value between -1 and 1. The return value will be a numeric value between 0 and pi radians.
Below are a few examples of how to use the Python acos() function to find the arccosine of a number.
import math
print(math.acos(0.5))
print(math.acos(0))
print(math.acos(-0.75))
#Output:
1.0471975511965979
1.5707963267948966
2.4188584057763776
How to Find Arctangent of Number with atan() Function in Python
To find the arctangent of a number, we use the Python atan() function.
The input to the atan() function must be a numeric value. The return value will be a numeric value between -pi/2 and pi/2 radians.
Below are a few examples of how to use the Python atan() function to find the arctangent of a number.
import math
print(math.atan(5))
print(math.atan(0))
print(math.atan(-3))
#Output:
1.373400766945016
0.0
-1.2490457723982544
How to Find Arctangent of the Quotient of Two Numbers with atan2() Function in Python
Python gives us the ability to find the arctangent of the quotient of two numbers, where the two numbers represents the coordinates of a point (x,y). To find the arctangent of a the quotient of two numbers, we use the Python atan2() function.
The inputs to the atan2() function must be a numeric values. The return value will be a numeric value between -pi and pi radians.
Below are a few examples of how to use the Python atan2() function to find the arctangent of the quotient of two numbers.
import math
print(math.atan2(5,1))
print(math.atan2(0,0))
print(math.atan2(-3,7))
#Output:
1.373400766945016
0.0
-0.40489178628508343
How to Find Hyperbolic Sine of Number with sinh() Function in Python
To find the hyperbolic sine of a number, we can use the Python sinh() function from the math module.
The input to the sinh() function must be a numeric value. The return value will be a numeric value.
Below are a few examples of how to use the Python sinh() function to find the hyperbolic sine of a number.
import math
print(math.sinh(100))
print(math.sinh(0))
print(math.sinh(-50))
#Output:
1.3440585709080678e+43
0.0
-2.592352764293536e+21
How to Find Hyperbolic Cosine of Number with cosh() Function in Python
To find the hyperbolic cosine of a number, we can use the Python cosh() function from the math module.
The input to the cosh() function must be a numeric value. The return value will be a numeric value greater than or equal to 1.
Below are a few examples of how to use the Python cosh() function to find the hyperbolic cosine of a number.
import math
print(math.cosh(100))
print(math.cosh(0))
print(math.cosh(-50))
#Output:
1.3440585709080678e+43
1.0
2.592352764293536e+21
How to Find Hyperbolic Tangent of Number with tanh() Function in Python
To find the hyperbolic tangent of a number, we can use the Python tanh() function from the math module.
The input to the tanh() function must be a numeric value. The return value will be a numeric value between -1 and 1.
Below are a few examples of how to use the Python tanh() function to find the hyperbolic tangent of a number.
import math
print(math.tanh(20))
print(math.tanh(0))
print(math.tanh(-10))
#Output:
1.0
0.0
-0.9999999958776927
How to Find Hyperbolic Arcsine of Number with asinh() Function in Python
To find the hyperbolic arcsine of a number, we can use the Python asinh() function from the math module.
The input to the asinh() function must be a numeric value. The return value will be a numeric value.
Below are a few examples of how to use the Python asinh() function to find the hyperbolic arcsine of a number.
import math
print(math.asinh(10))
print(math.asinh(0))
print(math.asinh(-5.32))
#Output:
2.99822295029797
0.0
-2.3733388650599814
How to Find Hyperbolic Arccosine of Number with acosh() Function in Python
To find the hyperbolic arccosine of a number, we can use the Python acosh() function from the math module.
The input to the acosh() function must be a numeric value greater than or equal to 1. The return value will be a numeric value.
Below are a few examples of how to use the Python acosh() function to find the hyperbolic arccosine of a number.
import math
print(math.acosh(5.23))
print(math.acosh(1.2))
print(math.acosh(100))
#Output:
2.3382907483329896
0.6223625037147786
5.298292365610484
How to Find Hyperbolic Arctangent of Number with atanh() Function in Python
To find the hyperbolic arctangent of a number, we can use the Python atanh() function from the math module.
The input to the atanh() function must be a numeric value between -1 and 1. The return value will be a numeric value.
Below are a few examples of how to use the Python atanh() function to find the hyperbolic arctangent of a number.
import math
print(math.atanh(0.5))
print(math.atanh(0))
print(math.atanh(-0.75))
#Output:
0.5493061443340549
0.0
-0.9729550745276566
Hopefully this article has been useful for you to learn how to use the math module trig functions in Python for trigonometry.
Leave a Reply