complex.py

Created by mino-1289

Created on May 18, 2021

894 Bytes

Donne les informations importantes sur un nombre complexe.


from math import *
# from ion import keydown
import matplotlib.pyplot as plt

#z = x + iy
print("z = x + iy")
x = float(eval(input("x = ")).real)
y = float(eval(input("y = ")).real)

z = complex(x, y)
alge = round(z.real, 2) + round(z.imag, 2) * 1j
r = round(sqrt(x*x + y*y), 2)
theta = round((2*atan((z.imag)/(z.real + r)).real)/pi, 2)

print("\nz = {}\nConjugué de z = {}".format(alge, alge.conjugate()))
print("Forme exponentielle :\nz = {}e^i{}pi".format(r, theta))
print("\nPresse OK pour la vue graphique")

plt.scatter(alge.real, alge.imag, c="b")
plt.scatter(0, 0, c='b')
# plt.scatter(0,0,s=100000, facecolors="none", edgecolors="r")
plt.grid()
plt.plot([0, alge.real], [0, alge.imag], color="b")
plt.plot([-alge.real-1, alge.real+1], [0, 0], color="r")
plt.plot([0, 0], [-alge.imag-1, alge.imag+1], color="r")

# plt.autoscale(False)

plt.show()
# if keydown(KEY_OK):

During your visit to our site, NumWorks needs to install "cookies" or use other technologies to collect data about you in order to:

With the exception of Cookies essential to the operation of the site, NumWorks leaves you the choice: you can accept Cookies for audience measurement by clicking on the "Accept and continue" button, or refuse these Cookies by clicking on the "Continue without accepting" button or by continuing your browsing. You can update your choice at any time by clicking on the link "Manage my cookies" at the bottom of the page. For more information, please consult our cookies policy.