No project description provided
Project description
complexNumbers
Use complex numbers in python.
1 Initial Complex
z = Complex(value)
value can be 5 different datatypes:
intfloatcomplexstrComplex
1.1 int, float
They are used when a real number should be become a complex number. (no imaginary part)
1.2 complex
Standard complex numbers also can be initialed. (e.g.: 1+1j)
1.3 str
With a string there can be entered complex numbers in the cartesian and polar form.
1.3.1 cartesian form
should be entered like this: "x+yj"
1.3.2 polar form
Modulus and argument are separated by e^. (e.g.: 1e^1)
1.4 Complex
Value can also be the same type as the own class.
2 Variables
The class has following __self__ variables.
real: real part of the cartesian formimaginary: imaginary part of the cartesian formmodulus: modulus of the polar formargument: argument of the polar form in the range [0; 2Pi[
3 Methods
The class can be used with the following methods:
__add__ , __radd__ , __iadd__equals+ , +=__sub__ , __rsub__ , __isub__equals- , -=__mul__ , __rmul__ , __imul__equals* , *=__truediv__ , __rtruediv__ , __itruediv__equals/ , /=__pow__equals**ATTENTION: only real numbers can be used aspowerand when used to get a root only one solution returns.__eq__equals==__ne__equals!=__abs__equalsabs()returns the modulus__str__equalsstr()returns the number in cartesian form (e.g.:"1+1j")root(n)returns a list with all possible roots of the complex number.nis the power of the root (e.g.: n = 2 ... square root)
4 Example
>>> a = Complex("1+1j")
>>> b = Complex("1e^1")
>>> print(a.modulus)
1.4142135623730951
>>> print(a.argument)
0.7853981633974483
>>> print(b.real)
0.5403023058681398
>>> print(b.imaginary)
0.8414709848078965
>>> print(a+b)
1.5403023058681398+1.8414709848078965j
>>> print(a-b)
0.45969769413186023+0.1585290151921035j
>>> print(a*b)
-0.30116867893975674+1.3817732906760363j
>>> print(a/b)
1.3817732906760363-0.30116867893975674j
>>> print(a**2)
1.2246467991473535e-16+2.0000000000000004j
>>> print(b**0.5)
0.8775825618903728+0.479425538604203j
>>> print(b.root())
[0.8775825618903728+0.479425538604203j, -0.8775825618903728-0.4794255386042029j]
>>> print(abs(b)
1.0
>>> print(a == a)
True
>>> print(a != b)
True
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file complexNumbers-0.0.1.tar.gz.
File metadata
- Download URL: complexNumbers-0.0.1.tar.gz
- Upload date:
- Size: 3.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4eb71a47bd13571354b091895e75c6bf5c79dd157ee9610197ba1235df3f1cc9
|
|
| MD5 |
217a83dfde0beb6ee7d9b684b4a1c3f3
|
|
| BLAKE2b-256 |
36f84278091eeaf0c3998372992f2fe20dde4438bb7cb42c788a74f20f633279
|
File details
Details for the file complexNumbers-0.0.1-py3-none-any.whl.
File metadata
- Download URL: complexNumbers-0.0.1-py3-none-any.whl
- Upload date:
- Size: 3.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
534e2efa5a862bfbb72d3d656838d234c3fd6b36f3e4bd40cc632f6b02c33e16
|
|
| MD5 |
751bea3cb71aee01a6b5144eb6e8ab63
|
|
| BLAKE2b-256 |
e3a42e1543a02c7130df82a95908633adb2a3cf98ecc130c1ce6214744ec0254
|