-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfunctions.py
80 lines (57 loc) · 1.94 KB
/
functions.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
import cmath
import numpy as np
def z_1(z: list[complex]) -> dict[complex, complex]:
result = {}
for c in z:
try:
result[c] = ((1 / 2) * c) - (3 / (5 - c))
if result[c] == 0:
print(f"Zero point at {c}")
except:
result[c] = 0
print(f"Definition gap at {c}!")
continue
return result
def z_2(z: list[complex]) -> dict[complex, complex]:
return {c: c ** 2 for c in z}
def z_3(z: list[complex], x: float) -> int | dict[complex, complex]:
if x == 0:
return 0
return {c: (c ** x) / x * c for c in z}
def z_4(z: list[complex], x: float) -> int | dict[complex, complex]:
if x == 0:
return 0
return {c: c / x for c in z}
def z_5(z: list[complex], x: float) -> dict[complex, complex]:
return {c: complex(c * x) for c in z}
def z_6(z: list[complex]) -> dict[complex, complex]:
return {c: cmath.sin(c) for c in z}
def z_7(z: list[complex]) -> dict[complex, complex]:
return {c: cmath.cos(c) for c in z}
def z_8(z: list[complex]) -> dict[complex, complex]:
result = {}
for c in z:
result[c] = (cmath.tan(c))
return result
def z_9(z: list[complex]) -> dict[complex, complex]:
return {c: 1 / c for c in z if c != 0}
def z_10(z: list[complex]) -> dict[complex, complex]:
result = {}
for c in z:
try:
result[c] = ((c ** 3) / cmath.sqrt(c)) - 3j / (5j - c)
if result[c] == 0:
print(f"Zero point at {c}")
except:
result[c] = 0
print(f"Definition gap at {c}!")
continue
return result
def of_range(start: complex, end: complex, step: float) -> list[complex]:
complexes = []
re = np.arange(start.real, end.real, step)
im = np.arange(start.imag, end.imag, step)
for r in range(len(re)):
for i in range(len(im)):
complexes.append(complex(re[r], im[i]))
return complexes