ComplexNumber
ComplexNumber class to perform complex operations.
You can take a look at the source code here.
Installation
pip install complex-number
Usage example
from complex_number import ComplexNumber
import math
z1 = Complex(1, 2)
z2 = Complex.from_polar(2, math.pi)
print(z1)
z2.print(4)
z2.print_polar(4)
print(z1.real)
z1.real = 5
print(z1.imag)
z1.imag = -3
print(z1.modulus)
z1.modulus = 4
print(z1.argument)
z1.argument = math.pi / 2
Math operations
print(z1 + z2)
z1 += z2
print(z1 - z2)
z1 -= z2
print(z1 * z2)
z1 *= z2
print(z1 / z2)
z1 /= z2
print(z1 ** 3)
z1 **= 3
print(z1.root())
print(z1.root(3))
print(+z1)
print(-z1)
Additional Operations
print(z1.conjugate())
print(z1.polar())
print(ComplexNumber.to_cartesian(modulus=2, argument=math.pi))
Check for Equality
print(z1 == z2)