Algorithm and Flowchart to find all the Roots of a Quadratic Equation

[843 views]


What are Quadratic Equations?

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.

Algorithm to find all the roots of a quadratic equation:

Step 1. Start Step 2. Read the coefficients of the equation, a, b and c from the user. Step 3. Calculate discriminant = (b * b) – (4 * a * c) Step 4. If discriminant > 0: 4.1: Calculate root1 = ( -b + sqrt(discriminant)) / (2 * a) 4.2: Calculate root2 = ( -b - sqrt(discriminant)) / (2 * a) 4.3: Display “Roots are real and different” 4.4: Display root1 and root2 Step 5: Else if discriminant = 0: 5.1: Calculate root1 = -b / (2 *a) 5.2: root2 = root1 5.3: Display “Root are real and equal” 5.4: Display root1 and root2 Step 6. Else: 6.1: Calculate real = -b / (2 * a) 6.2:Calculate imaginary = sqrt(-discriminant) / (2 * a) 6.3: Display “Roots are imaginary” 6.4: Display real, “±” , imaginary, “i” Step 7. Stop

Explanation:

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?

Flowchart to find all the roots of a quadratic equation:

Flowchart to find all the roots of a quadratic equation
Remove WaterMark from Above Flowchart
        

Struggling to Understand Algorithm and Flowchart? Try our Notes



Want to Test Your Knowledge on Algorithm and Flowchart?



Comments



Search
Recommended Deals End in

Top Java Interview Questions PDF Guide with 30+ Pages



Online Games
Play 2048 Game Online and Relax.
Play 2048 Game Online

Quiz to Test Your Skills
Search Tags

    Find Roots of a Quadratic Equation Algorithm

    Find Roots of a Quadratic Equation Flowchart

    Quadratic Equation Pseudocode