Quadratic equations are the polynomial equations of degree 2 in one variable of type: f(x) = ax2+ bx + c where a, b, c, ∈ R and a ≠ 0. It is the general form of a quadratic equation where 'a' is called the leading coefficient and 'c' is called the absolute term of f (x).
A quadratic equation will always have two roots. The nature of roots may be either real or imaginary.
The general form of quadratic equation: ax2+ bx + c
Example: 4x2+ 6x + 12
The roots of a quadratic equation are given by the quadratic formula:
The term b2 - 4ac is known as the discriminant of a quadratic equation. It tells the nature of the roots.
|If discriminant > 0|
|If discriminant = 0|
|If discriminant < 0|
We are going to use the above logic to solve this problem. Let us take a look at the algorithm and flowchart to have a better understanding.
The algorithm starts off by taking the coefficients of the equation, a, b and c from the user. After that the discriminant is calculated by the given formula. We will now check whether the discriminant is greater than 0. If yes, then the roots of the equation are real and different. If the discriminant is equal to 0, then the roots are real and equal. If the discriminant is less than 0, then the roots are imaginary and different.
We will compare the calculated discriminant with each of the conditions and whichever is satisfied, we will calculate the two roots by the corresponding formula and then display it.
Note: Please refer to the table at the beginning to see the corresponding formula.
For example: Let us consider the equation: 6x² + 11x - 35 = 0.
Here, discriminant = 961
Therefore, discriminant > 0; the roots are real and different.
So, root1 = 938, root2 = -81?