Complex Numbers in Python | Set 2 (Important Functions and Constants)
Introduction to python complex numbers: Complex Numbers in Python | Set 1 (Introduction)
Some more important functions and constants are discussed in this article.
Operations on complex numbers :
1. exp() :- This function returns the exponent of the complex number mentioned in its argument.
2. log(x,b) :- This function returns the logarithmic value of x with the base b, both mentioned in its arguments. If base is not specified, natural log of x is returned.
# 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)