feat: task2.py konverstion arithmeitsche/trigonometrische Form komplexer Zahlen
This commit is contained in:
parent
6d1b64c6c7
commit
cb48ca8509
54
src/lineare_algebra/task2.py
Normal file
54
src/lineare_algebra/task2.py
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
#%%
|
||||||
|
import numpy as np
|
||||||
|
|
||||||
|
#%%
|
||||||
|
# liste mit gegebenen Komplexen Zahlen
|
||||||
|
komplexe_zahlen = [
|
||||||
|
[4, np.pi/2],
|
||||||
|
[2, -np.pi/3],
|
||||||
|
[3, np.pi/4],
|
||||||
|
[2, 3*np.pi],
|
||||||
|
[1/2, np.radians(75)],
|
||||||
|
[np.sqrt(2), np.radians(-105)]
|
||||||
|
]
|
||||||
|
|
||||||
|
print("----------------------------------------------------------------------")
|
||||||
|
print("Aufgabe 7. Konversion in die arithmetische Form")
|
||||||
|
print(__file__)
|
||||||
|
print("----------------------------------------------------------------------")
|
||||||
|
|
||||||
|
for r, phi in komplexe_zahlen:
|
||||||
|
# Berechnung
|
||||||
|
z = r * (np.cos(phi) + 1j*np.sin(phi))
|
||||||
|
|
||||||
|
# Arithmetische Form
|
||||||
|
print(f"z={r:.3f}*cis({phi/np.pi:.3f}pi) = {z:.3f}")
|
||||||
|
print("----------------------------------------------------------------------")
|
||||||
|
|
||||||
|
#%%
|
||||||
|
# liste mit gegebenen Komplexen Zahlen
|
||||||
|
komplexe_zahlen = [
|
||||||
|
3 + 0j,
|
||||||
|
-5 + 0j,
|
||||||
|
0 + 2j,
|
||||||
|
0 - 3j,
|
||||||
|
3 - 4j,
|
||||||
|
-12 + 5j
|
||||||
|
]
|
||||||
|
|
||||||
|
print("----------------------------------------------------------------------")
|
||||||
|
print("Aufgabe 7. Konversion in die trigonometrische Form")
|
||||||
|
print(__file__)
|
||||||
|
print("----------------------------------------------------------------------")
|
||||||
|
|
||||||
|
for z in komplexe_zahlen:
|
||||||
|
# Betrag
|
||||||
|
r = np.abs(z)
|
||||||
|
|
||||||
|
# Argument
|
||||||
|
phi = np.angle(z)
|
||||||
|
|
||||||
|
# Trigonometrische Form
|
||||||
|
print(f"z={z} = {r} * cis({phi/np.pi:.3f}pi)")
|
||||||
|
|
||||||
|
print("----------------------------------------------------------------------")
|
||||||
Loading…
x
Reference in New Issue
Block a user