This module provides access to mathematical functions for complex numbers. We have used the cmath.sqrt(), cmath is actually a header file that contains different functions including the square root. The program directly tells the root since there is no particular condition we need to define.
![solve this quadratic equation solve this quadratic equation](https://i.ytimg.com/vi/dqmyaNiaCIY/maxresdefault.jpg)
In the program, we have taken input from the user for all the three variables a, b, and c. The Quadratic Equation is of form ax2 + bx+ c Print("The Quadratic Equation is of form ax2 + bx+ c\n") #Python program to solve quadratic equation using math module Hence, we are now going to use one of the powerful modules which is cmath. Solving Quadratic Equation using the Complex math ModuleĪs we know, Python is filled with different libraries, functions, and modules. If you want to know more about the math module, you can click here.ģ. The function roots_of_equation has been defined to calculate the Discriminant value and to check the conditions after the Discriminant value has been calculated. In the above program, we have set the value of a, b, and c, instead, we can also take the value from the user. Print("Input correct Quadratic Equation")
![solve this quadratic equation solve this quadratic equation](https://cdn.numerade.com/ask_previews/17e302b-82bb-bc35-df64-bd0835108855_large.jpg)
# If a is given 0, then Equation is incorrect # We can ask the user for value for a, b, c If D = 0, then the roots are real and equal.If D > 0, then the roots are real and distinct.The discriminant of the quadratic equation is D = b 2 – 4ac.The form ax 2 + bx + c = 0 will be followed, as this is the standard form.
![solve this quadratic equation solve this quadratic equation](https://classroom-images.cdn.askfilo.com/classroom/1708511831421_ujxelzmg_4623439.jpg)
Some of the important points which should be followed for solving the quadratic equations are: