라벨이 cmath인 게시물 표시

파이썬[Python]: cmath - polar 함수

cmath 모듈 - polar 함수(function) /// 설명 극좌표계에서의 x 를 표현하며, (거리, 각도) 를 반환합니다.(abs(x), phase(x)) 참고: cmath.phase() ※ 형식 cmath.polar(x) reference https://docs.python.org/3/library/cmath.html#module-cmath /// 예제 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 import  cmath   print (cmath.polar(complex( 1 ,  0 )))   # (1.0, 0) print (cmath.polar(complex( 1 ,  1 )))   # (1.4142135623730951, 0.7853981633974483) print (cmath.polar(complex( 0 ,  1 )))   # (1.0, 1.5707963267948966) print (cmath.polar(complex( - 1 ,  1 )))   # (1.4142135623730951, 2.356194490192345) print (cmath.polar(complex( - 1 ,  0 )))   # (1.0, 3.141592653589793) print (cmath.polar(complex( - 1 ,  - 1 )))   # (1.4142135623730951, -2.356194490192345) print (cmath.polar(complex( 0 ,  - 1 )))   # (1.0, -1.5707963267948966) print (cmath.polar(complex( 1 ,  - 1 )))   # (1.4142135623730951, -0.7853981633974483)   # polar coordinates: https://ko.wikipedia.org/wiki/%EA%B7%B9%EC%A2%8C%ED%91%9C%EA%B3%84 # tuple = ( distance, an

파이썬[Python]: cmath - phase 함수

cmath 모듈 - phase 함수(function) /// 설명 복소수 x 의 위상(phase)을 반환합니다. math.atan2(x.imag, x.real) 과 동일합니다. ※ 형식 cmath.phase(x) reference https://docs.python.org/3/library/cmath.html#module-cmath /// 예제 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 import  cmath   print (cmath.phase(complex( 0. 0 ,  0. 0 )))   # 0.0 print (cmath.phase(complex( 1. 0 ,  0. 0 )))   # 0.0 print (cmath.phase(complex( - 0. 0 ,  1. 0 )))   # 1.5707963267948966 print (cmath.phase(complex( - 1. 0 ,  1. 0 )))   # 2.356194490192345 print (cmath.phase(complex( 0. 0 ,  - 0. 0 )))   # -0.0 print (cmath.phase(complex( 1. 0 ,  - 0. 0 )))   # -0.0 print (cmath.phase(complex( - 0. 0 ,  - 1. 0 )))   # -1.5707963267948966 print (cmath.phase(complex( - 1. 0 ,  - 1. 0 )))   # -2.356194490192345     # phase : an angle-like quantity - https://ko.wikipedia.org/wiki/%EC%9C%84%EC%83%81 # # equivalent to math.atan2(x.imag, x.real) #               math.atan2(   y  ,   x   ) (x=0, y=0, undefined) # # 0, pi/2, pi, 3*p