1c = 1 + 2j # or c = complex(1, 2)
2print(c) # (1+2j)
3print(type(c)) # <class 'complex'>
4print(c.real()) # 1.0
5print(c.imag()) # 2.0
6print(c + complex(3, -5)) # (4-3j)
7
1cmath.acos(x) Returns the arc cosine value of x
2cmath.acosh(x) Returns the hyperbolic arc cosine of x
3cmath.asin(x) Returns the arc sine of x
4cmath.asinh(x) Returns the hyperbolic arc sine of x
5cmath.atan(x) Returns the arc tangent value of x
6cmath.atanh(x) Returns the hyperbolic arctangent value of x
7cmath.cos(x) Returns the cosine of x
8cmath.cosh(x) Returns the hyperbolic cosine of x
9cmath.exp(x) Returns the value of Ex, where E is Euler's number (approximately 2.718281...), and x is the number passed to it
10cmath.isclose() Checks whether two values are close, or not
11cmath.isfinite(x) Checks whether x is a finite number
12cmath.isinf(x) Check whether x is a positive or negative infinty
13cmath.isnan(x) Checks whether x is NaN (not a number)
14cmath.log(x[, base]) Returns the logarithm of x to the base
15cmath.log10(x) Returns the base-10 logarithm of x
16cmath.phase() Return the phase of a complex number
17cmath.polar() Convert a complex number to polar coordinates
18cmath.rect() Convert polar coordinates to rectangular form
19cmath.sin(x) Returns the sine of x
20cmath.sinh(x) Returns the hyperbolic sine of x
21cmath.sqrt(x) Returns the square root of x
22cmath.tan(x) Returns the tangent of x
23cmath.tanh(x) Returns the hyperbolic tangent of x
1# It is best to represent the complex part of your equation this way:
2c = 1j
3# rather than using
4complex(x,y)
5# which can sometimes cause "issues"
1
2c = 1 + 2j
3print(type(c))
4print(c)
5
6c1 = complex(2, 4)
7print(type(c1))
8print(c1)
9