Skip to content

Commit fbd8fe9

Browse files
authored
Adding tutorial
1 parent f44ddfc commit fbd8fe9

File tree

1 file changed

+2
-97
lines changed

1 file changed

+2
-97
lines changed

README.md

Lines changed: 2 additions & 97 deletions
Original file line numberDiff line numberDiff line change
@@ -14,103 +14,8 @@ Use the package manager [pip](https://pypi.org/project/cmpx/) to install cmpx.
1414
pip install cmpx
1515
```
1616

17-
## Usage
18-
### Importing Complex class
19-
```python
20-
from cmpx import Complex
21-
```
22-
### Different instanciations of Complex class
23-
```python
24-
# Instanciation 1
25-
number = Complex() # --> Real = 0, Imaginary = 0
26-
print(number)
27-
# Instanctiation 2
28-
number = Complex(42) # --> Real = 42, Imaginary = 0
29-
print(number)
30-
# Instanciation 3
31-
number = Complex(12, -3.2) # --> Real = 12, Imaginary = -3.2
32-
print(number)
33-
# Instanciation 4
34-
number = Complex(im=13.2, re=5) # --> Real = 5, Imaginary = 13.2
35-
print(number)
36-
# Instanciation 5
37-
number = Complex(re=3, im=-2.4, restore=False) # restore argument is by default True, whenever an error occurs on operation, the last result will be restored to the object, else if it is False then the object will be simply None.
38-
# Instanciation 6
39-
number = Complex.fromComplex(4 - 3j - 2) # Real = 2, Imaginary = -3
40-
# Keep in mind that the imaginary part 'j' must be always multiplied with a coefficient as follows
41-
number = Complex.fromComplex(1 - 1j)
42-
```
43-
### Basic operations
44-
```python
45-
num1 = Complex(re=3, im=-2.5)
46-
num2 = Complex(re=4.2, im=13.2)
47-
# Summation
48-
print('({}) + ({}) = {}'.format(num1, num2, num1 + num2))
49-
# Substraction
50-
print('({}) - ({}) = {}'.format(num1, num2, num1 - num2))
51-
# Multiplication
52-
print('({}) * ({}) = {}'.format(num1, num2, num1 * num2))
53-
# Division
54-
print('({}) / ({}) = {}'.format(num1, num2, num1 / num2))
55-
# Floor division
56-
print('({}) // ({}) = {}'.format(num1, num2, num1 // num2))
57-
## Affecting the result directly on the number
58-
# Summation
59-
print('({}) += ({})'.format(num1, 2), end=' --> ')
60-
num1 += 2
61-
print(num1)
62-
# Substraction
63-
print('({}) -= ({})'.format(num1, num2), end=' --> ')
64-
num1 -= num2
65-
print(num1)
66-
# Multiplication
67-
print('({}) *= ({})'.format(num1, 2), end=' --> ')
68-
num1 *= 2
69-
print(num1)
70-
# Division
71-
print('({}) /= ({})'.format(num1, num2), end=' --> ')
72-
num1 /= num2
73-
print(num1)
74-
# Floor division
75-
print('({}) //= ({})'.format(num1, 2), end=' --> ')
76-
num1 /= 2
77-
print(num1)
78-
# Congugated of a complex number
79-
print('con({}) = {}'.format(num2, num2.con()))
80-
# Module of a complex number
81-
print('mod({}) = {}'.format(num2, num2.mod()))
82-
# You can also make basic operations with non instanciated complex numbers like this
83-
num1 *= (1 - 1j)
84-
print(num1)
85-
```
86-
### Comparisons of Complex numbers
87-
```python
88-
num1 = Complex(im=3.1, re=-5)
89-
num2 = Complex(im=-1.5, re=0.6)
90-
# Greater than
91-
if(num1 > num2): print('({}) > ({})'.format(num1, num2))
92-
# Greater or equal
93-
if(num1 >= num2): print('({}) >= ({})'.format(num1, num2))
94-
# Less than
95-
if(num1 < num2): print('({}) < ({})'.format(num1, num2))
96-
# Less or equal
97-
if(num1 <= num2): print('({}) <= ({})'.format(num1, num2))
98-
# Equal
99-
if(num1 == num2): print('({}) == ({})'.format(num1, num2))
100-
# Not equal
101-
if(num1 != num2): print('({}) != ({})'.format(num1, num2))
102-
# You can also make comparisons with non instanciated complex numbers like this
103-
if(num1 > (1 - 3j)): print('({}) != ({})'.format(num1, (1 - 3j)))
104-
```
105-
### Solving linear equation and second degree equation
106-
#### Importing solve function
107-
```python
108-
from cmpx.equations import solve
109-
```
110-
#### Solving equations
111-
```
112-
solutions = solve(-1,2,3) # It will return a tuple of solutions
113-
```
17+
## Tutorial
18+
You can follow this [tutorial](https://github.com/Omar-Belghaouti/PythonComplex/blob/master/cmpx%20tutorial.ipynb) to learn more about this package.
11419

11520
## Contributing
11621
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

0 commit comments

Comments
 (0)