Roots of Quadratic Equations

Theory

Quadratic equations are the equations where polynomial has the degree two. Quadratic equations are the equations of type ax2 + bx + c = 0
where x is unknown and a, b, c are known real numbers and a should not be zero. If a=0 then the equation will not remain quadratic,it will be
then linear as a=0 will eliminate x2 term. As the quadratic equation has the highest degree two, so this equation has two roots, or we can say that we will find two values of x for a quadratic equation.


Nature of roots

The nature of roots depends on the discriminant of the quadratic equation. The discriminant of a quadratic equation is given by b2 – 4ac. It is so because in quadratic formula square root of discriminant is there.

Root 1: If b2 – 4ac > 0 roots are real and different. As the discriminant is >0 then the square root of it will not be imaginary. It has two cases.

If b2 – 4ac is a perfect square then roots are rational. As the discriminant is a perfect square, so we will have an integer as a square root of the discriminant. Hence, the roots are rational numbers.

An if else statement in programming is a conditional statement that runs a different set of statements depending on whether an expression is true or false. A typical if else statement would appear similar to the one below (this example is JavaScript, and would be very similar in other C-style languages).

var x = 1;
if (x === 1) {
window.alert("The expression is true!");
}
else {
window.alert("The expression is false!");
}
In this case, with the variable x being equal to the number 1, the statement in the first set of curly braces {} is executed. You would receive a pop-up "The expression is true!" alert message. If you were to change the first line of the above code to var x = 42;, you would receive a pop-up alert message with the text "The expression is false!"




Example: Let the quadratic equation be x2 -5x+6=0.

Then the discriminant of the given equation is b2 – 4ac=(-5)2 – 4*1*6 = 25-24 = 1
According to Shridharacharaya formula
x = [-b±√(b2 -4ac)]/2a = x = [-(-5) ± √1]/2
x1 = [-(-5) + √1]/2 = 6/2 = 3
x2 = [-(-5) – √1]/2 = 4/2 = 2
Therefore, the roots are 3,2. Both are rational and different.
If b2 – 4ac is not a perfect square then the square root of discriminant is irrational hence roots are irrational and occurs in pair.

Example:

main (){
float a,b,c,r1,r2,d;
printf (“enter the values of a b c”);
scanf (“ %f %f %f”, &a, &b, &c);
d= b*b – 4*a*c;
if (d>0){
r1 = -b+sqrt (d) / (2*a);
r2 = -b-sqrt (d) / (2*a);
printf (“The real roots = %f %f”, r1, r2);
}
else if (d= =0){
r1 = -b/(2*a);
r2 = -b/(2*a);
printf (“roots are equal =%f %f”, r1, r2);
}
else
printf(“Roots are imaginary”);
getch ();
}