Professional Documents
Culture Documents
Python
Python
Some of the most popular mathematical functions are defined in the math module. These
include trigonometric functions, representation functions, logarithmic functions, angle
conversion functions, etc. In addition, some mathematical constants are also defined in this
module. To use mathematical functions under this module, you have to import the module using import
math.
Here is the list of all the functions and attributes defined in math module with a brief explanation of what
they do.
Function Description
lgamma(x) Returns the natural logarithm of the absolute value of the Gamma function at x
circle constant equal to 2π, the ratio of a circle’s circumference to its radius.
of float('nan').
import math
x=5
y=-10
z=10
a=[5,10,15,20,25,30,35,40,45,50]
b=10.5
#1
print("1 : ",math.ceil(x))
#2
print("2 : ",math.copysign(x,y))
#3
print("3 : ",math.fabs(y))
#4
print("4 : ",math.factorial(x))
#5
print("5 : ",math.floor(y))
#6
print("6 : ",math.fmod(z,x))
#7
print("7 : ",math.frexp(x))
#8
print("8 : ",math.fsum(a))
#9
print("9 : ",math.isfinite(y))
#10
print("10 : ",math.isinf(x))
#11
print("11 : ",math.isnan(y))
#12
print("12 : ",math.ldexp(x,2))
#13
print("13 : ",math.modf(b))
#14
print("14 : ",math.trunc(y))
#15
print("15 : ",math.exp(x))
#16
print("16 : ",math.expm1(y))
#17
print("17 : ",math.log(x,))
#18
print("18 : ",math.log1p(x))
#19
print("19 : ",math.log2(x))
#20
print("20 : ",math.log2(x))
#21
print("21 : ",math.pow(x,z))
#22
print("22 : ",math.sqrt(x))
#23
print("23 : ",math.acos(0.5))
#24
print("24 : ",math.asin(1))
#25
print("25 : ",math.atan(-0.7))
#26
print("26 : ",math.atan2(-0.7,0.9))
#27
print("27 : ",math.cos(69))
#28
print("28 : ",math.sin(69))
#29
print("29 : ",math.tan(69))
#30
print("30 : ",math.hypot(x,z))
#31
print("31 : ",math.radians(180))
#32
print("32 : ",math.degrees(3.141592653589793))
#33
print("33 : ",math.acosh(3.141592653589793))
#34
print("34 : ",math.asinh(3.141592653589793))
#35
print("35 : ",math.atanh(0.99))
#36
print("36 : ",math.cosh(69))
#37
print("37 : ",math.sinh(69))
#38
print("38 : ",math.tanh(69))
#39
print("39 : ",math.erf(x))
#40
print("40 : ",math.erfc(x))
#41
print("41 : ",math.gamma(z))
#42
print("42 : ",math.lgamma(z))
#43
print("43 : ",math.pi)
#44
print("44 : ",math.e)
#45
print("45 : ",math.tau)
#46
print("46 : ",math.inf)
#47
print("47 : ",math.nan)
OUTPUT
1: 5
2 : -5.0
3 : 10.0
4 : 120
5 : -10
6 : 0.0
7 : (0.625, 3)
8 : 275.0
9 : True
10 : False
11 : False
12 : 20.0
13 : (0.5, 10.0)
14 : -10
15 : 148.4131591025766
16 : -0.9999546000702375
17 : 1.6094379124341003
18 : 1.791759469228055
19 : 2.321928094887362
20 : 2.321928094887362
21 : 9765625.0
22 : 2.23606797749979
23 : 1.0471975511965979
24 : 1.5707963267948966
25 : -0.6107259643892086
26 : -0.6610431688506868
27 : 0.9933903797222716
28 : -0.11478481378318722
29 : -0.11554854579453279
30 : 11.180339887498949
31 : 3.141592653589793
32 : 180.0
33 : 1.811526272460853
34 : 1.8622957433108482
35 : 2.6466524123622457
36 : 4.6268908627938936e+29
37 : 4.6268908627938936e+29
38 : 1.0
39 : 0.9999999999984626
40 : 1.537459794428035e-12
41 : 362880.0
42 : 12.801827480081467
43 : 3.141592653589793
44 : 2.718281828459045
45 : 6.283185307179586
46 : inf
47 : nan