This is a simple complex number python package.
Project description
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) # real, imag
z2 = Complex.from_polar(2, math.pi) # modulus, argument
print(z1)
z2.print(4) # set precision (defaults to 2)
z2.print_polar(4) # set precision (defaults to 2)
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()) # defaults to 2
print(z1.root(3))
print(+z1)
print(-z1)
Additional Operations
print(z1.conjugate())
print(z1.polar()) # returns dictionary with the keys: modulus and argument.
print(ComplexNumber.to_cartesian(modulus=2, argument=math.pi)) # returns tuple with real and imag part.
Check for Equality
print(z1 == z2) # true if real and imag parts are both equal to each other
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
complex_number-0.1.2.tar.gz
(8.4 kB
view hashes)
Built Distribution
Close
Hashes for complex_number-0.1.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a18b69229d41ac7e5e808b759093c87eef0faa9e447a279c69c49387dfb0114d |
|
MD5 | 15d10069cf83cf9aa20586c9eff016d4 |
|
BLAKE2b-256 | 00e7d40939c9db3bf94a032c8823682c12d56a9cf934dbe1b0088ba831892bf0 |