파이썬 math 모듈에 포함된 함수
import math
# math 모듈이 필요 없는 수학 함수
print(" 2**3 : "+ str( 2**3 )) # 8
print(" abs(-25) : " + str ( abs(-25) ) ) # 25
print(" round(1.5) : " + str( round(1.5))) # 2
print(" round(1.1234567, 1) : " + str( round(1.1234567, 1))) # 1.1
print(" sum([1,2,3,4]) : "+ str( sum([1,2,3,4]))) # 10
print(" max([1,2,3,4]) : "+ str( max([1,2,3,4]))) # 4
print(" min([1,2,3,4]) : "+ str( min([1,2,3,4]))) # 1
print(" pow(2,3) : "+ str(pow(2,3)) ) # 8
print(" divmod(5,2) "+ str( divmod(5,2))) # (2,1)
# 여기서부터는 math 모듈이 필요함
print("pi:"+ str ( math.pi ) ) # 3.141592653589793
print("e:"+ str ( math.e ) ) # 2.718281828459045
print(" math.ceil(3.14) : "+ str( math.ceil(3.14))) # 4
print(" math.floor(3.14) : "+ str( math.floor(3.14))) # 3
print(" math.trunc(2.3) : "+ str( math.trunc(2.3))) # 2
print(" math.factorial(4) : "+ str( math.factorial(4))) # 24
print(" math.pow(2,3) "+ str( math.pow(2,3))) # 8
print(" math.sqrt(9) "+ str( math.sqrt(9))) # 3
print(" math.copysign(1.5, -1.3) : "+ str(math.copysign(1.5, -1.3))) # -1.5
print(" math.fabs(-2.7) : "+ str(math.fabs(-2.7))) # 2.7
print(" math.fmod(-13.2, 3) : "+ str(math.fmod(-13.2,3))) # -1.1999999999999993
print(" math.fsum([1,2,3]) : "+ str( math.fsum([1,2,3]))) # 6.0
print(" math.modf(2.718) : "+ str( math.modf(2.7))) # (0.7000000000000002, 2.0)
print(" math.exp(2) : "+ str( math.exp(2))) # 7.38905609893065
# 삼각함수
print(" math.degrees(math.pi) : "+ str( math.degrees(math.pi))) # 180.0
print(" math.radians(180) : "+ str( math.radians(180))) # pi
rad = math.pi/2 # 90 deg
sinv = math.sin(rad)
cosv = math.cos(rad)
tanv = math.tan(rad)
# 역삼각함수
math.asin(sinv)
math.acos(cosv)
math.atan(tanv)
math.atan2(sinv, cosv)
# 쌍곡선 함수
sinhv = math.sinh(rad)
coshv = math.cosh(rad)
tanhv = math.tanh(rad)
# 역쌍곡선 함수
math.asinh(sinhv)
math.acosh(coshv)
math.atanh(tanhv)
# 밑을 지정하는 일반로그
print(" math.log(8,2) "+ str( math.log(8,2))) # 3.0
# 밑이 자연상수(e)인 자연로그
val = math.pow( math.e, 3 )
print(" math.log("+str(val)+") "+ str( math.log(val))) # 3.0
# 밑이 10인 상용로그
print(" math.log10(100) "+ str( math.log10(100))) # 2.0
# 복소수
comp1 = 2 + 3j
comp2 = 3 + 4j
comp3 = comp1 + comp2
print(comp3) # 5 + 7j