In this Python Program, we will learn how to Solve Quadratic Equation.
In algebra, a quadratic equation is an equation that can be rearranged in standard form as
ax²+bx+c = 0
where x represents an unknown, and a, b, and c represent known numbers, where a ≠ 0. If a = 0, then the equation is linear, not quadratic, as there is no ax2 term. The numbers a, b, and c are the coefficients of the equation and may be distinguished by calling them, respectively, the quadratic coefficient, the linear coefficient, and the constant or free term.
A Quadratic Equation has at most two solutions, and they depend entirely upon the discriminant. If the discriminant > 0, then two distinct real roots exist for this equation. If discriminant = 0, two equal and real roots exist. Or if discriminant < 0, two distinct complex roots exist.
Here is the source code of the program to calculate the roots of a Quadratic Equation.
The solution is (3+0j) and (4+0j)
Another way to calculate the Quadratic Equation
Two Distinct Real Roots Exists: root1 = 7.50 and root2 = 6.50
In the above program, we import the cmath
module to perform complex square root.
First, we need to calculate the discriminant and then find the two solutions of the quadratic equation.
Comments