If the discriminant of a quadratic equation is 0, then the equation has

A discriminant is a value calculated from a quadratic equation. It use it to 'discriminate' between the roots (or solutions) of a quadratic equation. 

A quadratic equation is one of the form: ax2 + bx + c

The discriminant, D = b2 - 4ac

Note: This is the expression inside the square root of the quadratic formula

There are three cases for the discriminant;

Case 1:

b2 - 4ac > 0

If the discriminant is greater than zero, this means that the quadratic equation has two real, distinct (different) roots.

Example

x2 - 5x + 2 = 0

a = 1, b = -5, c = 2

Discriminant, D = b2 - 4ac

                         = (-5)2 - 4 * (1) * (2)

                         = 17

Therefore, there are two real, distinct roots to the quadratic equation 

x2 - 5x + 2.

Case 2:

b2 - 4ac < 0

If the discriminant is greater than zero, this means that the quadratic equation has no real roots.

Example

3x2 + 2x + 1 = 0

a = 3, b = 2, c = 1

Discriminant, D = b2 - 4ac

                         = (2)2 - 4 * (3) * (1)

                         = - 8

Therefore, there are no real roots to the quadratic equation 3x2 + 2x + 1.

Case 3:

b2 - 4ac = 0

If the discriminant is equal to zero, this means that the quadratic equation has two real, identical roots.

The quadratic formula was covered in the module Algebra review. This formula gives solutions to the general quadratic equation \(ax^2+bx+c=0\), when they exist, in terms of the coefficients \(a,b,c\). The solutions are

\[ x = \dfrac{-b+\sqrt{b^2-4ac}}{2a}, \qquad x = \dfrac{-b-\sqrt{b^2-4ac}}{2a}, \]

provided that \(b^2-4ac \geq 0\).

The quantity \(b^2-4ac\) is called the discriminant of the quadratic, often denoted by \(\Delta\), and should be found first whenever the formula is being applied. It discriminates between the types of solutions of the equation:

  • \(\Delta > 0 \) tells us the equation has two distinct real roots
  • \(\Delta = 0 \) tells us the equation has one (repeated) real root
  • \(\Delta < 0 \) tells us the equation has no real roots.

Screencast of interactive 2,  Interactive 2

Exercise 4

For what values of \(k\) does the equation \((4k+1)x^2-2(k+1)x+(1-2k)=0\) have one real solution? For what values of \(k\), if any, is the quadratic negative definite?

Write a C program to find all roots of a quadratic equation using if else. How to find all roots of a quadratic equation using if else in C programming. Logic to find roots of quadratic equation in C programming.

Example
Input

Input a: 8
Input b: -4
Input c: -2

Output

Root1: 0.80
Root2: -0.30

Required knowledge

Basic C programming, Relational operators, If else

Quadratic equation

Wikipedia states, in elementary algebra a quadratic equation is an equation in the form of

If the discriminant of a quadratic equation is 0, then the equation has
If the discriminant of a quadratic equation is 0, then the equation has

Solving quadratic equation

A quadratic equation can have either one or two distinct real or complex roots depending upon nature of discriminant of the equation. Where discriminant of the quadratic equation is given by

If the discriminant of a quadratic equation is 0, then the equation has
If the discriminant of a quadratic equation is 0, then the equation has

Depending upon the nature of the discriminant, formula for finding roots is be given as.

  • Case 1: If discriminant is positive. Then there are two real distinct roots given by.
    If the discriminant of a quadratic equation is 0, then the equation has
    If the discriminant of a quadratic equation is 0, then the equation has
  • Case 2: If discriminant is zero then, it has exactly one real root given by.
    If the discriminant of a quadratic equation is 0, then the equation has
    If the discriminant of a quadratic equation is 0, then the equation has
  • Case 3: If discriminant is negative then, it has two distinct complex roots given by.
    If the discriminant of a quadratic equation is 0, then the equation has
    If the discriminant of a quadratic equation is 0, then the equation has

Logic to find all roots of a quadratic equation

Based on the above formula let us write step by step descriptive logic to find roots of a quadratic equation.

  1. Input coefficients of quadratic equation from user. Store it in some variable say a, b and c.
  2. Find discriminant of the given equation, using formula discriminant = (b*b) - (4*a*c).

    Learn - Program to find power of a number.

  3. Compute roots based on the nature of discriminant.
  4. If discriminant > 0 then,
    root1 = (-b + sqrt(discriminant)) / (2*a) and
    root2 = (-b - sqrt(discriminant)) / (2*a).

    Learn - Program to find square root of a number using sqrt() function.

  5. If discriminant == 0 then, root1 = root2 = -b / (2*a).
  6. Else if discriminant < 0 then, there are two distinct complex roots where
    Root1: 0.80
    Root2: -0.30
    0 and
    Root1: 0.80
    Root2: -0.30
    1.

    Imaginary part of the root is given by

    Root1: 0.80
    Root2: -0.30
    2.

After this much reading let us finally code the solution of this program.

Program to find roots of quadratic equation

/**
 * C program to find all roots of a quadratic equation
 */

#include <stdio.h>
#include <math.h> /* Used for sqrt() */

int main()
{
    float a, b, c;
    float root1, root2, imaginary;
    float discriminant;
    
    printf("Enter values of a, b, c of quadratic equation (aX^2 + bX + c): ");
    scanf("%f%f%f", &a, &b, &c);
    
    /* Find discriminant of the equation */
    discriminant = (b * b) - (4 * a * c);
    
   
    /* Find the nature of discriminant */
    if(discriminant > 0)
    {
        root1 = (-b + sqrt(discriminant)) / (2*a);
        root2 = (-b - sqrt(discriminant)) / (2*a);

        printf("Two distinct and real roots exists: %.2f and %.2f", root1, root2);
    }
    else if(discriminant == 0)
    {
        root1 = root2 = -b / (2 * a);

        printf("Two equal and real roots exists: %.2f and %.2f", root1, root2);
    }
    else if(discriminant < 0)
    {
        root1 = root2 = -b / (2 * a);
        imaginary = sqrt(-discriminant) / (2 * a);

        printf("Two distinct complex roots exists: %.2f + i%.2f and %.2f - i%.2f", 
                root1, imaginary, root2, imaginary);
    }

    return 0;
}

Before you move on to next exercise. It is recommended to learn this program using another approach using

Root1: 0.80
Root2: -0.30
3.

When the discriminant is zero What is the equation?

If the discriminant is equal to zero, this means that the quadratic equation has two real, identical roots. Therefore, there are two real, identical roots to the quadratic equation x2 + 2x + 1. D > 0 means two real, distinct roots.

When discriminant of the quadratic equation is 0 then equal roots are given by?

If the discriminant is equal to zero (b2 – 4ac = 0), a, b, c are real numbers, a≠0, then the roots of the quadratic equation ax2 + bx + c = 0, are real and equal. In this case, the roots are x = -b/2a.

How many solutions does a 0 discriminant have?

If the discriminant is equal to 0, the quadratic equation has 1 real solution. If the discriminant is less than 0, the quadratic equation has 0 real solutions.

How many real solutions if the discriminant of quadratic equation is 0?

If the discriminant value is zero, the quadratic equation has only one solution or two real and equal solutions. If the discriminant value is negative, the quadratic equation has no real solutions.