importmathdefsolve_quadratic(a,b,c):"""
Résout une équation quadratique de la forme ax^2 + bx + c = 0.
"""# Calcul du discriminant
delta=b**2-4*a*c# Affichage du discriminant
print("Discriminant (Delta) =",delta)# Vérification des cas en fonction de Delta
ifdelta>0:# Deux solutions réelles distinctes
x1=(-b-math.sqrt(delta))/(2*a)x2=(-b+math.sqrt(delta))/(2*a)print("Deux solutions réelles distinctes :")print("x1 =",x1)print("x2 =",x2)elifdelta==0:# Une solution réelle unique
x1=-b/(2*a)print("Une solution réelle unique :")print("x =",x1)else:# Deux solutions complexes
real_part=-b/(2*a)imaginary_part=math.sqrt(-delta)/(2*a)print("Deux solutions complexes :")print("x1 =",complex(real_part,-imaginary_part))print("x2 =",complex(real_part,imaginary_part))# Exemple d'utilisation
# Coefficients de l'équation ax^2 + bx + c = 0
a=1b=-3c=2solve_quadratic(a,b,c)
During your visit to our site, NumWorks needs to install "cookies" or use other technologies to collect data about you in order to:
Ensure the proper functioning of the site (essential cookies); and
Track your browsing to send you personalized communications if you have created a professional account on the site and can be contacted (audience measurement cookies).
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.