Python의 복소수 | 세트 2(중요 기능 및 상수)

파이썬 복소수 소개: Python의 복소수 | 세트 1(소개) 이 문서에서는 몇 가지 더 중요한 함수와 상수에 대해 설명합니다. 복소수 연산 : 1. 특급() :- 이 함수는 멱지수 인수에 언급된 복소수입니다. 2. 로그(xb) :- 이 함수는 b를 밑으로 하는 x의 로그 값 both mentioned in its arguments. If base is not specified natural log of x is returned. Python
   # Python code to demonstrate the working of    # exp() log()   # importing 'cmath' for complex number operations   import   cmath   import   math   # Initializing real numbers   x   =   1.0   y   =   1.0   # converting x and y into complex number   z   =   complex  (  x     y  );   # printing exponent of complex number   print   (  'The exponent of complex number is : '     end  =  ''  )   print   (  cmath  .  exp  (  z  ))   # printing log form of complex number   print   (  'The log(base 10) of complex number is : '     end  =  ''  )   print   (  cmath  .  log  (  z    10  ))   
Output:
The exponent of complex number is : (1.4686939399158851+2.2873552871788423j) The log(base 10) of complex number is : (0.15051499783199057+0.3410940884604603j)  
  3.로그10() :- 이 함수는 로그베이스 10 복소수의. 4. sqrt() :- 이것은 다음을 계산합니다. 제곱근 of a complex number. Python
   # Python code to demonstrate the working of    # log10() sqrt()   # importing 'cmath' for complex number operations   import   cmath   import   math   # Initializing real numbers   x   =   1.0   y   =   1.0   # converting x and y into complex number   z   =   complex  (  x     y  );   # printing log10 of complex number   print   (  'The log10 of complex number is : '     end  =  ''  )   print   (  cmath  .  log10  (  z  ))   # printing square root form of complex number   print   (  'The square root of complex number is : '     end  =  ''  )   print   (  cmath  .  sqrt  (  z  ))   
Output:
The log10 of complex number is : (0.15051499783199057+0.3410940884604603j) The square root of complex number is : (1.09868411346781+0.45508986056222733j)  
  5. 무한() :- 반품 실수부와 허수부가 모두 참인 경우 복소수는 한정된 그렇지 않으면 false를 반환합니다. 6. 당신을 위해() :- 반품 실수부나 허수부인 경우 참 복소수의 는/이다 무한 그렇지 않으면 false를 반환합니다. 7. 이스난() :- 다음의 경우 true를 반환합니다. 실수 부분이든 허수 부분이든 복소수는 NaN else returns false. Python
   # Python code to demonstrate the working of    # isnan() isinf() isfinite()   # importing 'cmath' for complex number operations   import   cmath   import   math   # Initializing real numbers   x   =   1.0   y   =   1.0   a   =   math  .  inf   b   =   math  .  nan   # converting x and y into complex number   z   =   complex  (  x    y  );   # converting x and a into complex number   w   =   complex  (  x    a  );   # converting x and b into complex number   v   =   complex  (  x    b  );   # checking if both numbers are finite   if   cmath  .  isfinite  (  z  ):   print   (  'Complex number is finite'  )   else   :   print   (  'Complex number is infinite'  )   # checking if either number is/are infinite   if   cmath  .  isinf  (  w  ):   print   (  'Complex number is infinite'  )   else   :   print   (  'Complex number is finite'  )   # checking if either number is/are infinite   if   cmath  .  isnan  (  v  ):   print   (  'Complex number is NaN'  )   else   :   print   (  'Complex number is not NaN'  )   
Output:
Complex number is finite Complex number is infinite Complex number is NaN  
  상수 cmath 모듈에는 두 개의 상수가 정의되어 있습니다. '파이' 이는 pi의 숫자 값을 반환합니다. 두 번째는 '그리고' which returns the numerical value of exponent. Python
   # Python code to demonstrate the working of    # pi and e    # importing 'cmath' for complex number operations   import   cmath   import   math   # printing the value of pi    print   (  'The value of pi is : '     end  =  ''  )   print   (  cmath  .  pi  )   # printing the value of e   print   (  'The value of exponent is : '     end  =  ''  )   print   (  cmath  .  e  )   
Output:
The value of pi is : 3.141592653589793 The value of exponent is : 2.718281828459045  
Python의 복소수 | 세트 3(삼각함수 및 쌍곡선 함수)