Given a quadratic equation the task is solve the equation or find out the roots of the equation. Standard form of quadratic equation is – ax2 + bx + c where, a, b, and c are coefficient and real numbers and also a ≠ 0. If a is equal to 0 that equation is not valid quadratic equation. Examples: Input :a = 1, b = 2, c = 1 Output : Roots are real and same -1.0 Input :a = 2, b = 2, c = 1 Output : Roots are complex -0.5 + i 2.0 -0.5 - i 2.0 Input :a = 1, b = 10, c = -24 Output : Roots are real and different 2.0 -12.0 Method 1: Using the direct formula Using the below quadratic formula we can find the root of the quadratic equation. There are following important cases. If b*b < 4*a*c, then roots are complex (not real). For example roots of x2 + x + 1, roots are -0.5 + i1.73205 and -0.5 - i1.73205 If b*b == 4*a*c, then roots are real and both roots are same. For example, roots of x2 - 2x + 1 are 1 and 1 If b*b > 4*a*c, then roots are real and different. For example, roots of x2 - 7x - 12 are 3 and 4
Input :a = 1, b = 2, c = 1 Output : Roots are real and same -1.0 Input :a = 2, b = 2, c = 1 Output : Roots are complex -0.5 + i 2.0 -0.5 - i 2.0 Input :a = 1, b = 10, c = -24 Output : Roots are real and different 2.0 -12.00 Input :a = 1, b = 2, c = 1 Output : Roots are real and same -1.0 Input :a = 2, b = 2, c = 1 Output : Roots are complex -0.5 + i 2.0 -0.5 - i 2.0 Input :a = 1, b = 10, c = -24 Output : Roots are real and different 2.0 -12.01 Input :a = 1, b = 2, c = 1 Output : Roots are real and same -1.0 Input :a = 2, b = 2, c = 1 Output : Roots are complex -0.5 + i 2.0 -0.5 - i 2.0 Input :a = 1, b = 10, c = -24 Output : Roots are real and different 2.0 -12.02
Input :a = 1, b = 2, c = 1 Output : Roots are real and same -1.0 Input :a = 2, b = 2, c = 1 Output : Roots are complex -0.5 + i 2.0 -0.5 - i 2.0 Input :a = 1, b = 10, c = -24 Output : Roots are real and different 2.0 -12.04 Input :a = 1, b = 2, c = 1 Output : Roots are real and same -1.0 Input :a = 2, b = 2, c = 1 Output : Roots are complex -0.5 + i 2.0 -0.5 - i 2.0 Input :a = 1, b = 10, c = -24 Output : Roots are real and different 2.0 -12.05 Input :a = 1, b = 2, c = 1 Output : Roots are real and same -1.0 Input :a = 2, b = 2, c = 1 Output : Roots are complex -0.5 + i 2.0 -0.5 - i 2.0 Input :a = 1, b = 10, c = -24 Output : Roots are real and different 2.0 -12.04 Input :a = 1, b = 2, c = 1 Output : Roots are real and same -1.0 Input :a = 2, b = 2, c = 1 Output : Roots are complex -0.5 + i 2.0 -0.5 - i 2.0 Input :a = 1, b = 10, c = -24 Output : Roots are real and different 2.0 -12.07 Input :a = 1, b = 2, c = 1 Output : Roots are real and same -1.0 Input :a = 2, b = 2, c = 1 Output : Roots are complex -0.5 + i 2.0 -0.5 - i 2.0 Input :a = 1, b = 10, c = -24 Output : Roots are real and different 2.0 -12.08 Input :a = 1, b = 2, c = 1 Output : Roots are real and same -1.0 Input :a = 2, b = 2, c = 1 Output : Roots are complex -0.5 + i 2.0 -0.5 - i 2.0 Input :a = 1, b = 10, c = -24 Output : Roots are real and different 2.0 -12.09 If b*b < 4*a*c, then roots are complex (not real). For example roots of x2 + x + 1, roots are -0.5 + i1.73205 and -0.5 - i1.73205 If b*b == 4*a*c, then roots are real and both roots are same. For example, roots of x2 - 2x + 1 are 1 and 1 If b*b > 4*a*c, then roots are real and different. For example, roots of x2 - 7x - 12 are 3 and 40 Input :a = 1, b = 2, c = 1 Output : Roots are real and same -1.0 Input :a = 2, b = 2, c = 1 Output : Roots are complex -0.5 + i 2.0 -0.5 - i 2.0 Input :a = 1, b = 10, c = -24 Output : Roots are real and different 2.0 -12.09 If b*b < 4*a*c, then roots are complex (not real). For example roots of x2 + x + 1, roots are -0.5 + i1.73205 and -0.5 - i1.73205 If b*b == 4*a*c, then roots are real and both roots are same. For example, roots of x2 - 2x + 1 are 1 and 1 If b*b > 4*a*c, then roots are real and different. For example, roots of x2 - 7x - 12 are 3 and 42 If b*b < 4*a*c, then roots are complex (not real). For example roots of x2 + x + 1, roots are -0.5 + i1.73205 and -0.5 - i1.73205 If b*b == 4*a*c, then roots are real and both roots are same. For example, roots of x2 - 2x + 1 are 1 and 1 If b*b > 4*a*c, then roots are real and different. For example, roots of x2 - 7x - 12 are 3 and 43 If b*b < 4*a*c, then roots are complex (not real). For example roots of x2 + x + 1, roots are -0.5 + i1.73205 and -0.5 - i1.73205 If b*b == 4*a*c, then roots are real and both roots are same. For example, roots of x2 - 2x + 1 are 1 and 1 If b*b > 4*a*c, then roots are real and different. For example, roots of x2 - 7x - 12 are 3 and 40 If b*b < 4*a*c, then roots are complex (not real). For example roots of x2 + x + 1, roots are -0.5 + i1.73205 and -0.5 - i1.73205 If b*b == 4*a*c, then roots are real and both roots are same. For example, roots of x2 - 2x + 1 are 1 and 1 If b*b > 4*a*c, then roots are real and different. For example, roots of x2 - 7x - 12 are 3 and 45 If b*b < 4*a*c, then roots are complex (not real). For example roots of x2 + x + 1, roots are -0.5 + i1.73205 and -0.5 - i1.73205 If b*b == 4*a*c, then roots are real and both roots are same. For example, roots of x2 - 2x + 1 are 1 and 1 If b*b > 4*a*c, then roots are real and different. For example, roots of x2 - 7x - 12 are 3 and 40 If b*b < 4*a*c, then roots are complex (not real). For example roots of x2 + x + 1, roots are -0.5 + i1.73205 and -0.5 - i1.73205 If b*b == 4*a*c, then roots are real and both roots are same. For example, roots of x2 - 2x + 1 are 1 and 1 If b*b > 4*a*c, then roots are real and different. For example, roots of x2 - 7x - 12 are 3 and 47 Input :a = 1, b = 2, c = 1 Output : Roots are real and same -1.0 Input :a = 2, b = 2, c = 1 Output : Roots are complex -0.5 + i 2.0 -0.5 - i 2.0 Input :a = 1, b = 10, c = -24 Output : Roots are real and different 2.0 -12.04 If b*b < 4*a*c, then roots are complex (not real). For example roots of x2 + x + 1, roots are -0.5 + i1.73205 and -0.5 - i1.73205 If b*b == 4*a*c, then roots are real and both roots are same. For example, roots of x2 - 2x + 1 are 1 and 1 If b*b > 4*a*c, then roots are real and different. For example, roots of x2 - 7x - 12 are 3 and 49 Input :a = 1, b = 2, c = 1 Output : Roots are real and same -1.0 Input :a = 2, b = 2, c = 1 Output : Roots are complex -0.5 + i 2.0 -0.5 - i 2.0 Input :a = 1, b = 10, c = -24 Output : Roots are real and different 2.0 -12.08 real and different roots 2.0 -12.01 real and different roots 2.0 -12.02 real and different roots 2.0 -12.03 real and different roots 2.0 -12.04 Input :a = 1, b = 2, c = 1 Output : Roots are real and same -1.0 Input :a = 2, b = 2, c = 1 Output : Roots are complex -0.5 + i 2.0 -0.5 - i 2.0 Input :a = 1, b = 10, c = -24 Output : Roots are real and different 2.0 -12.04 real and different roots 2.0 -12.06 Input :a = 1, b = 2, c = 1 Output : Roots are real and same -1.0 Input :a = 2, b = 2, c = 1 Output : Roots are complex -0.5 + i 2.0 -0.5 - i 2.0 Input :a = 1, b = 10, c = -24 Output : Roots are real and different 2.0 -12.04 real and different roots 2.0 -12.08 real and different roots 2.0 -12.09 The roots are (-3.414213562373095+0j) (-0.5857864376269049+0j)0 The roots are (-3.414213562373095+0j) (-0.5857864376269049+0j)1 The roots are (-3.414213562373095+0j) (-0.5857864376269049+0j)2 The roots are (-3.414213562373095+0j) (-0.5857864376269049+0j)3 The roots are (-3.414213562373095+0j) (-0.5857864376269049+0j)4 The roots are (-3.414213562373095+0j) (-0.5857864376269049+0j)5 The roots are (-3.414213562373095+0j) (-0.5857864376269049+0j)6 The roots are (-3.414213562373095+0j) (-0.5857864376269049+0j)2 The roots are (-3.414213562373095+0j) (-0.5857864376269049+0j)3 The roots are (-3.414213562373095+0j) (-0.5857864376269049+0j)9 If b*b < 4*a*c, then roots are complex (not real). For example roots of x2 + x + 1, roots are -0.5 + i1.73205 and -0.5 - i1.73205 If b*b == 4*a*c, then roots are real and both roots are same. For example, roots of x2 - 2x + 1 are 1 and 1 If b*b > 4*a*c, then roots are real and different. For example, roots of x2 - 7x - 12 are 3 and 42 Input :a = 1, b = 2, c = 1 Output : Roots are real and same -1.0 Input :a = 2, b = 2, c = 1 Output : Roots are complex -0.5 + i 2.0 -0.5 - i 2.0 Input :a = 1, b = 10, c = -24 Output : Roots are real and different 2.0 -12.09 # Python program to find roots of quadratic equation 2 # Python program to find roots of quadratic equation 3# Python program to find roots of quadratic equation 4The roots are (-3.414213562373095+0j) (-0.5857864376269049+0j)4 # Python program to find roots of quadratic equation 6 If b*b < 4*a*c, then roots are complex (not real). For example roots of x2 + x + 1, roots are -0.5 + i1.73205 and -0.5 - i1.73205 If b*b == 4*a*c, then roots are real and both roots are same. For example, roots of x2 - 2x + 1 are 1 and 1 If b*b > 4*a*c, then roots are real and different. For example, roots of x2 - 7x - 12 are 3 and 40 # Python program to find roots of quadratic equation 8The roots are (-3.414213562373095+0j) (-0.5857864376269049+0j)2 The roots are (-3.414213562373095+0j) (-0.5857864376269049+0j)3 The roots are (-3.414213562373095+0j) (-0.5857864376269049+0j)9 If b*b < 4*a*c, then roots are complex (not real). For example roots of x2 + x + 1, roots are -0.5 + i1.73205 and -0.5 - i1.73205 If b*b == 4*a*c, then roots are real and both roots are same. For example, roots of x2 - 2x + 1 are 1 and 1 If b*b > 4*a*c, then roots are real and different. For example, roots of x2 - 7x - 12 are 3 and 42 Input :a = 1, b = 2, c = 1 Output : Roots are real and same -1.0 Input :a = 2, b = 2, c = 1 Output : Roots are complex -0.5 + i 2.0 -0.5 - i 2.0 Input :a = 1, b = 10, c = -24 Output : Roots are real and different 2.0 -12.09 If b*b < 4*a*c, then roots are complex (not real). For example roots of x2 + x + 1, roots are -0.5 + i1.73205 and -0.5 - i1.73205 If b*b == 4*a*c, then roots are real and both roots are same. For example, roots of x2 - 2x + 1 are 1 and 1 If b*b > 4*a*c, then roots are real and different. For example, roots of x2 - 7x - 12 are 3 and 42 # Python program to find roots of quadratic equation 3# Python program to find roots of quadratic equation 4The roots are (-3.414213562373095+0j) (-0.5857864376269049+0j)4 # Python program to find roots of quadratic equation 6 If b*b < 4*a*c, then roots are complex (not real). For example roots of x2 + x + 1, roots are -0.5 + i1.73205 and -0.5 - i1.73205 If b*b == 4*a*c, then roots are real and both roots are same. For example, roots of x2 - 2x + 1 are 1 and 1 If b*b > 4*a*c, then roots are real and different. For example, roots of x2 - 7x - 12 are 3 and 40 # Python program to find roots of quadratic equation 8real and different roots 2.0 -12.04 Input :a = 1, b = 2, c = 1 Output : Roots are real and same -1.0 Input :a = 2, b = 2, c = 1 Output : Roots are complex -0.5 + i 2.0 -0.5 - i 2.0 Input :a = 1, b = 10, c = -24 Output : Roots are real and different 2.0 -12.04 math 3 Input :a = 1, b = 2, c = 1 Output : Roots are real and same -1.0 Input :a = 2, b = 2, c = 1 Output : Roots are complex -0.5 + i 2.0 -0.5 - i 2.0 Input :a = 1, b = 10, c = -24 Output : Roots are real and different 2.0 -12.07 Input :a = 1, b = 2, c = 1 Output : Roots are real and same -1.0 Input :a = 2, b = 2, c = 1 Output : Roots are complex -0.5 + i 2.0 -0.5 - i 2.0 Input :a = 1, b = 10, c = -24 Output : Roots are real and different 2.0 -12.08 Input :a = 1, b = 2, c = 1 Output : Roots are real and same -1.0 Input :a = 2, b = 2, c = 1 Output : Roots are complex -0.5 + i 2.0 -0.5 - i 2.0 Input :a = 1, b = 10, c = -24 Output : Roots are real and different 2.0 -12.08 The roots are (-3.414213562373095+0j) (-0.5857864376269049+0j)0 The roots are (-3.414213562373095+0j) (-0.5857864376269049+0j)1 The roots are (-3.414213562373095+0j) (-0.5857864376269049+0j)2 The roots are (-3.414213562373095+0j) (-0.5857864376269049+0j)3 The roots are (-3.414213562373095+0j) (-0.5857864376269049+0j)4 2The roots are (-3.414213562373095+0j) (-0.5857864376269049+0j)6 The roots are (-3.414213562373095+0j) (-0.5857864376269049+0j)2 The roots are (-3.414213562373095+0j) (-0.5857864376269049+0j)3 The roots are (-3.414213562373095+0j) (-0.5857864376269049+0j)4 If b*b < 4*a*c, then roots are complex (not real). For example roots of x2 + x + 1, roots are -0.5 + i1.73205 and -0.5 - i1.73205 If b*b == 4*a*c, then roots are real and both roots are same. For example, roots of x2 - 2x + 1 are 1 and 1 If b*b > 4*a*c, then roots are real and different. For example, roots of x2 - 7x - 12 are 3 and 42 Input :a = 1, b = 2, c = 1 Output : Roots are real and same -1.0 Input :a = 2, b = 2, c = 1 Output : Roots are complex -0.5 + i 2.0 -0.5 - i 2.0 Input :a = 1, b = 10, c = -24 Output : Roots are real and different 2.0 -12.09 # Python program to find roots of quadratic equation 4 The roots are (-3.414213562373095+0j) (-0.5857864376269049+0j)4 # Python program to find roots of quadratic equation 6 If b*b < 4*a*c, then roots are complex (not real). For example roots of x2 + x + 1, roots are -0.5 + i1.73205 and -0.5 - i1.73205 If b*b == 4*a*c, then roots are real and both roots are same. For example, roots of x2 - 2x + 1 are 1 and 1 If b*b > 4*a*c, then roots are real and different. For example, roots of x2 - 7x - 12 are 3 and 40 # Python program to find roots of quadratic equation 8real and different roots 2.0 -12.04 Input :a = 1, b = 2, c = 1 Output : Roots are real and same -1.0 Input :a = 2, b = 2, c = 1 Output : Roots are complex -0.5 + i 2.0 -0.5 - i 2.0 Input :a = 1, b = 10, c = -24 Output : Roots are real and different 2.0 -12.04 6Input :a = 1, b = 2, c = 1 Output : Roots are real and same -1.0 Input :a = 2, b = 2, c = 1 Output : Roots are complex -0.5 + i 2.0 -0.5 - i 2.0 Input :a = 1, b = 10, c = -24 Output : Roots are real and different 2.0 -12.04 8 9The roots are (-3.414213562373095+0j) (-0.5857864376269049+0j)2 The roots are (-3.414213562373095+0j) (-0.5857864376269049+0j)3 The roots are (-3.414213562373095+0j) (-0.5857864376269049+0j)4 Input :a = 1, b = 2, c = 1 Output : Roots are real and same -1.0 Input :a = 2, b = 2, c = 1 Output : Roots are complex -0.5 + i 2.0 -0.5 - i 2.0 Input :a = 1, b = 10, c = -24 Output : Roots are real and different 2.0 -12.003 The roots are (-3.414213562373095+0j) (-0.5857864376269049+0j)6 The roots are (-3.414213562373095+0j) (-0.5857864376269049+0j)2 The roots are (-3.414213562373095+0j) (-0.5857864376269049+0j)3 The roots are (-3.414213562373095+0j) (-0.5857864376269049+0j)4 If b*b < 4*a*c, then roots are complex (not real). For example roots of x2 + x + 1, roots are -0.5 + i1.73205 and -0.5 - i1.73205 If b*b == 4*a*c, then roots are real and both roots are same. For example, roots of x2 - 2x + 1 are 1 and 1 If b*b > 4*a*c, then roots are real and different. For example, roots of x2 - 7x - 12 are 3 and 42 Input :a = 1, b = 2, c = 1 Output : Roots are real and same -1.0 Input :a = 2, b = 2, c = 1 Output : Roots are complex -0.5 + i 2.0 -0.5 - i 2.0 Input :a = 1, b = 10, c = -24 Output : Roots are real and different 2.0 -12.09 # Python program to find roots of quadratic equation 4 The roots are (-3.414213562373095+0j) (-0.5857864376269049+0j)4 # Python program to find roots of quadratic equation 6 If b*b < 4*a*c, then roots are complex (not real). For example roots of x2 + x + 1, roots are -0.5 + i1.73205 and -0.5 - i1.73205 If b*b == 4*a*c, then roots are real and both roots are same. For example, roots of x2 - 2x + 1 are 1 and 1 If b*b > 4*a*c, then roots are real and different. For example, roots of x2 - 7x - 12 are 3 and 40 Input :a = 1, b = 2, c = 1 Output : Roots are real and same -1.0 Input :a = 2, b = 2, c = 1 Output : Roots are complex -0.5 + i 2.0 -0.5 - i 2.0 Input :a = 1, b = 10, c = -24 Output : Roots are real and different 2.0 -12.014 Input :a = 1, b = 2, c = 1 Output : Roots are real and same -1.0 Input :a = 2, b = 2, c = 1 Output : Roots are complex -0.5 + i 2.0 -0.5 - i 2.0 Input :a = 1, b = 10, c = -24 Output : Roots are real and different 2.0 -12.015 Input :a = 1, b = 2, c = 1 Output : Roots are real and same -1.0 Input :a = 2, b = 2, c = 1 Output : Roots are complex -0.5 + i 2.0 -0.5 - i 2.0 Input :a = 1, b = 10, c = -24 Output : Roots are real and different 2.0 -12.016 The roots are (-3.414213562373095+0j) (-0.5857864376269049+0j)2 The roots are (-3.414213562373095+0j) (-0.5857864376269049+0j)3 The roots are (-3.414213562373095+0j) (-0.5857864376269049+0j)4 If b*b < 4*a*c, then roots are complex (not real). For example roots of x2 + x + 1, roots are -0.5 + i1.73205 and -0.5 - i1.73205 If b*b == 4*a*c, then roots are real and both roots are same. For example, roots of x2 - 2x + 1 are 1 and 1 If b*b > 4*a*c, then roots are real and different. For example, roots of x2 - 7x - 12 are 3 and 42 Input :a = 1, b = 2, c = 1 Output : Roots are real and same -1.0 Input :a = 2, b = 2, c = 1 Output : Roots are complex -0.5 + i 2.0 -0.5 - i 2.0 Input :a = 1, b = 10, c = -24 Output : Roots are real and different 2.0 -12.09 # Python program to find roots of quadratic equation 4 The roots are (-3.414213562373095+0j) (-0.5857864376269049+0j)4 # Python program to find roots of quadratic equation 6 If b*b < 4*a*c, then roots are complex (not real). For example roots of x2 + x + 1, roots are -0.5 + i1.73205 and -0.5 - i1.73205 If b*b == 4*a*c, then roots are real and both roots are same. For example, roots of x2 - 2x + 1 are 1 and 1 If b*b > 4*a*c, then roots are real and different. For example, roots of x2 - 7x - 12 are 3 and 40 Input :a = 1, b = 2, c = 1 Output : Roots are real and same -1.0 Input :a = 2, b = 2, c = 1 Output : Roots are complex -0.5 + i 2.0 -0.5 - i 2.0 Input :a = 1, b = 10, c = -24 Output : Roots are real and different 2.0 -12.014 Input :a = 1, b = 2, c = 1 Output : Roots are real and same -1.0 Input :a = 2, b = 2, c = 1 Output : Roots are complex -0.5 + i 2.0 -0.5 - i 2.0 Input :a = 1, b = 10, c = -24 Output : Roots are real and different 2.0 -12.027 Input :a = 1, b = 2, c = 1 Output : Roots are real and same -1.0 Input :a = 2, b = 2, c = 1 Output : Roots are complex -0.5 + i 2.0 -0.5 - i 2.0 Input :a = 1, b = 10, c = -24 Output : Roots are real and different 2.0 -12.016
Input :a = 1, b = 2, c = 1 Output : Roots are real and same -1.0 Input :a = 2, b = 2, c = 1 Output : Roots are complex -0.5 + i 2.0 -0.5 - i 2.0 Input :a = 1, b = 10, c = -24 Output : Roots are real and different 2.0 -12.030 If b*b < 4*a*c, then roots are complex (not real). For example roots of x2 + x + 1, roots are -0.5 + i1.73205 and -0.5 - i1.73205 If b*b == 4*a*c, then roots are real and both roots are same. For example, roots of x2 - 2x + 1 are 1 and 1 If b*b > 4*a*c, then roots are real and different. For example, roots of x2 - 7x - 12 are 3 and 45 Input :a = 1, b = 2, c = 1 Output : Roots are real and same -1.0 Input :a = 2, b = 2, c = 1 Output : Roots are complex -0.5 + i 2.0 -0.5 - i 2.0 Input :a = 1, b = 10, c = -24 Output : Roots are real and different 2.0 -12.08 Input :a = 1, b = 2, c = 1 Output : Roots are real and same -1.0 Input :a = 2, b = 2, c = 1 Output : Roots are complex -0.5 + i 2.0 -0.5 - i 2.0 Input :a = 1, b = 10, c = -24 Output : Roots are real and different 2.0 -12.033 Input :a = 1, b = 2, c = 1 Output : Roots are real and same -1.0 Input :a = 2, b = 2, c = 1 Output : Roots are complex -0.5 + i 2.0 -0.5 - i 2.0 Input :a = 1, b = 10, c = -24 Output : Roots are real and different 2.0 -12.09 Input :a = 1, b = 2, c = 1 Output : Roots are real and same -1.0 Input :a = 2, b = 2, c = 1 Output : Roots are complex -0.5 + i 2.0 -0.5 - i 2.0 Input :a = 1, b = 10, c = -24 Output : Roots are real and different 2.0 -12.08 Input :a = 1, b = 2, c = 1 Output : Roots are real and same -1.0 Input :a = 2, b = 2, c = 1 Output : Roots are complex -0.5 + i 2.0 -0.5 - i 2.0 Input :a = 1, b = 10, c = -24 Output : Roots are real and different 2.0 -12.036 Input :a = 1, b = 2, c = 1 Output : Roots are real and same -1.0 Input :a = 2, b = 2, c = 1 Output : Roots are complex -0.5 + i 2.0 -0.5 - i 2.0 Input :a = 1, b = 10, c = -24 Output : Roots are real and different 2.0 -12.037 Input :a = 1, b = 2, c = 1 Output : Roots are real and same -1.0 Input :a = 2, b = 2, c = 1 Output : Roots are complex -0.5 + i 2.0 -0.5 - i 2.0 Input :a = 1, b = 10, c = -24 Output : Roots are real and different 2.0 -12.08 If b*b < 4*a*c, then roots are complex (not real). For example roots of x2 + x + 1, roots are -0.5 + i1.73205 and -0.5 - i1.73205 If b*b == 4*a*c, then roots are real and both roots are same. For example, roots of x2 - 2x + 1 are 1 and 1 If b*b > 4*a*c, then roots are real and different. For example, roots of x2 - 7x - 12 are 3 and 42 Input :a = 1, b = 2, c = 1 Output : Roots are real and same -1.0 Input :a = 2, b = 2, c = 1 Output : Roots are complex -0.5 + i 2.0 -0.5 - i 2.0 Input :a = 1, b = 10, c = -24 Output : Roots are real and different 2.0 -12.040
Input :a = 1, b = 2, c = 1 Output : Roots are real and same -1.0 Input :a = 2, b = 2, c = 1 Output : Roots are complex -0.5 + i 2.0 -0.5 - i 2.0 Input :a = 1, b = 10, c = -24 Output : Roots are real and different 2.0 -12.042 real and different roots 2.0 -12.08 If b*b < 4*a*c, then roots are complex (not real). For example roots of x2 + x + 1, roots are -0.5 + i1.73205 and -0.5 - i1.73205 If b*b == 4*a*c, then roots are real and both roots are same. For example, roots of x2 - 2x + 1 are 1 and 1 If b*b > 4*a*c, then roots are real and different. For example, roots of x2 - 7x - 12 are 3 and 45 Input :a = 1, b = 2, c = 1 Output : Roots are real and same -1.0 Input :a = 2, b = 2, c = 1 Output : Roots are complex -0.5 + i 2.0 -0.5 - i 2.0 Input :a = 1, b = 10, c = -24 Output : Roots are real and different 2.0 -12.08 Input :a = 1, b = 2, c = 1 Output : Roots are real and same -1.0 Input :a = 2, b = 2, c = 1 Output : Roots are complex -0.5 + i 2.0 -0.5 - i 2.0 Input :a = 1, b = 10, c = -24 Output : Roots are real and different 2.0 -12.08 The roots are (-3.414213562373095+0j) (-0.5857864376269049+0j)0 The roots are (-3.414213562373095+0j) (-0.5857864376269049+0j)1 The roots are (-3.414213562373095+0j) (-0.5857864376269049+0j)2 The roots are (-3.414213562373095+0j) (-0.5857864376269049+0j)3 The roots are (-3.414213562373095+0j) (-0.5857864376269049+0j)4 Input :a = 1, b = 2, c = 1 Output : Roots are real and same -1.0 Input :a = 2, b = 2, c = 1 Output : Roots are complex -0.5 + i 2.0 -0.5 - i 2.0 Input :a = 1, b = 10, c = -24 Output : Roots are real and different 2.0 -12.052 The roots are (-3.414213562373095+0j) (-0.5857864376269049+0j)6
Input :a = 1, b = 2, c = 1 Output : Roots are real and same -1.0 Input :a = 2, b = 2, c = 1 Output : Roots are complex -0.5 + i 2.0 -0.5 - i 2.0 Input :a = 1, b = 10, c = -24 Output : Roots are real and different 2.0 -12.04 Input :a = 1, b = 2, c = 1 Output : Roots are real and same -1.0 Input :a = 2, b = 2, c = 1 Output : Roots are complex -0.5 + i 2.0 -0.5 - i 2.0 Input :a = 1, b = 10, c = -24 Output : Roots are real and different 2.0 -12.058 Output: real and different roots 2.0 -12.0 Method 2: Using the complex math module First, we have to calculate the discriminant and then find two solution of quadratic equation using cmath module. Input :a = 1, b = 2, c = 1 Output : Roots are real and same -1.0 Input :a = 2, b = 2, c = 1 Output : Roots are complex -0.5 + i 2.0 -0.5 - i 2.0 Input :a = 1, b = 10, c = -24 Output : Roots are real and different 2.0 -12.059
Input :a = 1, b = 2, c = 1 Output : Roots are real and same -1.0 Input :a = 2, b = 2, c = 1 Output : Roots are complex -0.5 + i 2.0 -0.5 - i 2.0 Input :a = 1, b = 10, c = -24 Output : Roots are real and different 2.0 -12.061
If b*b < 4*a*c, then roots are complex (not real). For example roots of x2 + x + 1, roots are -0.5 + i1.73205 and -0.5 - i1.73205 If b*b == 4*a*c, then roots are real and both roots are same. For example, roots of x2 - 2x + 1 are 1 and 1 If b*b > 4*a*c, then roots are real and different. For example, roots of x2 - 7x - 12 are 3 and 45 Input :a = 1, b = 2, c = 1 Output : Roots are real and same -1.0 Input :a = 2, b = 2, c = 1 Output : Roots are complex -0.5 + i 2.0 -0.5 - i 2.0 Input :a = 1, b = 10, c = -24 Output : Roots are real and different 2.0 -12.08 Input :a = 1, b = 2, c = 1 Output : Roots are real and same -1.0 Input :a = 2, b = 2, c = 1 Output : Roots are complex -0.5 + i 2.0 -0.5 - i 2.0 Input :a = 1, b = 10, c = -24 Output : Roots are real and different 2.0 -12.033 Input :a = 1, b = 2, c = 1 Output : Roots are real and same -1.0 Input :a = 2, b = 2, c = 1 Output : Roots are complex -0.5 + i 2.0 -0.5 - i 2.0 Input :a = 1, b = 10, c = -24 Output : Roots are real and different 2.0 -12.09 Input :a = 1, b = 2, c = 1 Output : Roots are real and same -1.0 Input :a = 2, b = 2, c = 1 Output : Roots are complex -0.5 + i 2.0 -0.5 - i 2.0 Input :a = 1, b = 10, c = -24 Output : Roots are real and different 2.0 -12.08 If b*b < 4*a*c, then roots are complex (not real). For example roots of x2 + x + 1, roots are -0.5 + i1.73205 and -0.5 - i1.73205 If b*b == 4*a*c, then roots are real and both roots are same. For example, roots of x2 - 2x + 1 are 1 and 1 If b*b > 4*a*c, then roots are real and different. For example, roots of x2 - 7x - 12 are 3 and 43 Input :a = 1, b = 2, c = 1 Output : Roots are real and same -1.0 Input :a = 2, b = 2, c = 1 Output : Roots are complex -0.5 + i 2.0 -0.5 - i 2.0 Input :a = 1, b = 10, c = -24 Output : Roots are real and different 2.0 -12.037 Input :a = 1, b = 2, c = 1 Output : Roots are real and same -1.0 Input :a = 2, b = 2, c = 1 Output : Roots are complex -0.5 + i 2.0 -0.5 - i 2.0 Input :a = 1, b = 10, c = -24 Output : Roots are real and different 2.0 -12.08 # Python program to find roots of quadratic equation 6
Input :a = 1, b = 2, c = 1 Output : Roots are real and same -1.0 Input :a = 2, b = 2, c = 1 Output : Roots are complex -0.5 + i 2.0 -0.5 - i 2.0 Input :a = 1, b = 10, c = -24 Output : Roots are real and different 2.0 -12.073 Input :a = 1, b = 2, c = 1 Output : Roots are real and same -1.0 Input :a = 2, b = 2, c = 1 Output : Roots are complex -0.5 + i 2.0 -0.5 - i 2.0 Input :a = 1, b = 10, c = -24 Output : Roots are real and different 2.0 -12.07 Input :a = 1, b = 2, c = 1 Output : Roots are real and same -1.0 Input :a = 2, b = 2, c = 1 Output : Roots are complex -0.5 + i 2.0 -0.5 - i 2.0 Input :a = 1, b = 10, c = -24 Output : Roots are real and different 2.0 -12.08 Input :a = 1, b = 2, c = 1 Output : Roots are real and same -1.0 Input :a = 2, b = 2, c = 1 Output : Roots are complex -0.5 + i 2.0 -0.5 - i 2.0 Input :a = 1, b = 10, c = -24 Output : Roots are real and different 2.0 -12.076 If b*b < 4*a*c, then roots are complex (not real). For example roots of x2 + x + 1, roots are -0.5 + i1.73205 and -0.5 - i1.73205 If b*b == 4*a*c, then roots are real and both roots are same. For example, roots of x2 - 2x + 1 are 1 and 1 If b*b > 4*a*c, then roots are real and different. For example, roots of x2 - 7x - 12 are 3 and 40 If b*b < 4*a*c, then roots are complex (not real). For example roots of x2 + x + 1, roots are -0.5 + i1.73205 and -0.5 - i1.73205 If b*b == 4*a*c, then roots are real and both roots are same. For example, roots of x2 - 2x + 1 are 1 and 1 If b*b > 4*a*c, then roots are real and different. For example, roots of x2 - 7x - 12 are 3 and 40 # Python program to find roots of quadratic equation 6Input :a = 1, b = 2, c = 1 Output : Roots are real and same -1.0 Input :a = 2, b = 2, c = 1 Output : Roots are complex -0.5 + i 2.0 -0.5 - i 2.0 Input :a = 1, b = 10, c = -24 Output : Roots are real and different 2.0 -12.080 If b*b < 4*a*c, then roots are complex (not real). For example roots of x2 + x + 1, roots are -0.5 + i1.73205 and -0.5 - i1.73205 If b*b == 4*a*c, then roots are real and both roots are same. For example, roots of x2 - 2x + 1 are 1 and 1 If b*b > 4*a*c, then roots are real and different. For example, roots of x2 - 7x - 12 are 3 and 42 The roots are (-3.414213562373095+0j) (-0.5857864376269049+0j)4 If b*b < 4*a*c, then roots are complex (not real). For example roots of x2 + x + 1, roots are -0.5 + i1.73205 and -0.5 - i1.73205 If b*b == 4*a*c, then roots are real and both roots are same. For example, roots of x2 - 2x + 1 are 1 and 1 If b*b > 4*a*c, then roots are real and different. For example, roots of x2 - 7x - 12 are 3 and 43 If b*b < 4*a*c, then roots are complex (not real). For example roots of x2 + x + 1, roots are -0.5 + i1.73205 and -0.5 - i1.73205 If b*b == 4*a*c, then roots are real and both roots are same. For example, roots of x2 - 2x + 1 are 1 and 1 If b*b > 4*a*c, then roots are real and different. For example, roots of x2 - 7x - 12 are 3 and 40 If b*b < 4*a*c, then roots are complex (not real). For example roots of x2 + x + 1, roots are -0.5 + i1.73205 and -0.5 - i1.73205 If b*b == 4*a*c, then roots are real and both roots are same. For example, roots of x2 - 2x + 1 are 1 and 1 If b*b > 4*a*c, then roots are real and different. For example, roots of x2 - 7x - 12 are 3 and 45 If b*b < 4*a*c, then roots are complex (not real). For example roots of x2 + x + 1, roots are -0.5 + i1.73205 and -0.5 - i1.73205 If b*b == 4*a*c, then roots are real and both roots are same. For example, roots of x2 - 2x + 1 are 1 and 1 If b*b > 4*a*c, then roots are real and different. For example, roots of x2 - 7x - 12 are 3 and 40 Input :a = 1, b = 2, c = 1 Output : Roots are real and same -1.0 Input :a = 2, b = 2, c = 1 Output : Roots are complex -0.5 + i 2.0 -0.5 - i 2.0 Input :a = 1, b = 10, c = -24 Output : Roots are real and different 2.0 -12.087
Input :a = 1, b = 2, c = 1 Output : Roots are real and same -1.0 Input :a = 2, b = 2, c = 1 Output : Roots are complex -0.5 + i 2.0 -0.5 - i 2.0 Input :a = 1, b = 10, c = -24 Output : Roots are real and different 2.0 -12.089 Input :a = 1, b = 2, c = 1 Output : Roots are real and same -1.0 Input :a = 2, b = 2, c = 1 Output : Roots are complex -0.5 + i 2.0 -0.5 - i 2.0 Input :a = 1, b = 10, c = -24 Output : Roots are real and different 2.0 -12.090 Input :a = 1, b = 2, c = 1 Output : Roots are real and same -1.0 Input :a = 2, b = 2, c = 1 Output : Roots are complex -0.5 + i 2.0 -0.5 - i 2.0 Input :a = 1, b = 10, c = -24 Output : Roots are real and different 2.0 -12.08 The roots are (-3.414213562373095+0j) (-0.5857864376269049+0j)4 If b*b < 4*a*c, then roots are complex (not real). For example roots of x2 + x + 1, roots are -0.5 + i1.73205 and -0.5 - i1.73205 If b*b == 4*a*c, then roots are real and both roots are same. For example, roots of x2 - 2x + 1 are 1 and 1 If b*b > 4*a*c, then roots are real and different. For example, roots of x2 - 7x - 12 are 3 and 42 Input :a = 1, b = 2, c = 1 Output : Roots are real and same -1.0 Input :a = 2, b = 2, c = 1 Output : Roots are complex -0.5 + i 2.0 -0.5 - i 2.0 Input :a = 1, b = 10, c = -24 Output : Roots are real and different 2.0 -12.09 If b*b < 4*a*c, then roots are complex (not real). For example roots of x2 + x + 1, roots are -0.5 + i1.73205 and -0.5 - i1.73205 If b*b == 4*a*c, then roots are real and both roots are same. For example, roots of x2 - 2x + 1 are 1 and 1 If b*b > 4*a*c, then roots are real and different. For example, roots of x2 - 7x - 12 are 3 and 42 Input :a = 1, b = 2, c = 1 Output : Roots are real and same -1.0 Input :a = 2, b = 2, c = 1 Output : Roots are complex -0.5 + i 2.0 -0.5 - i 2.0 Input :a = 1, b = 10, c = -24 Output : Roots are real and different 2.0 -12.096 # Python program to find roots of quadratic equation 4The roots are (-3.414213562373095+0j) (-0.5857864376269049+0j)4 # Python program to find roots of quadratic equation 6 If b*b < 4*a*c, then roots are complex (not real). For example roots of x2 + x + 1, roots are -0.5 + i1.73205 and -0.5 - i1.73205 If b*b == 4*a*c, then roots are real and both roots are same. For example, roots of x2 - 2x + 1 are 1 and 1 If b*b > 4*a*c, then roots are real and different. For example, roots of x2 - 7x - 12 are 3 and 40 If b*b < 4*a*c, then roots are complex (not real). For example roots of x2 + x + 1, roots are -0.5 + i1.73205 and -0.5 - i1.73205 If b*b == 4*a*c, then roots are real and both roots are same. For example, roots of x2 - 2x + 1 are 1 and 1 If b*b > 4*a*c, then roots are real and different. For example, roots of x2 - 7x - 12 are 3 and 401 If b*b < 4*a*c, then roots are complex (not real). For example roots of x2 + x + 1, roots are -0.5 + i1.73205 and -0.5 - i1.73205 If b*b == 4*a*c, then roots are real and both roots are same. For example, roots of x2 - 2x + 1 are 1 and 1 If b*b > 4*a*c, then roots are real and different. For example, roots of x2 - 7x - 12 are 3 and 402 Input :a = 1, b = 2, c = 1 Output : Roots are real and same -1.0 Input :a = 2, b = 2, c = 1 Output : Roots are complex -0.5 + i 2.0 -0.5 - i 2.0 Input :a = 1, b = 10, c = -24 Output : Roots are real and different 2.0 -12.08 The roots are (-3.414213562373095+0j) (-0.5857864376269049+0j)4 If b*b < 4*a*c, then roots are complex (not real). For example roots of x2 + x + 1, roots are -0.5 + i1.73205 and -0.5 - i1.73205 If b*b == 4*a*c, then roots are real and both roots are same. For example, roots of x2 - 2x + 1 are 1 and 1 If b*b > 4*a*c, then roots are real and different. For example, roots of x2 - 7x - 12 are 3 and 42 Input :a = 1, b = 2, c = 1 Output : Roots are real and same -1.0 Input :a = 2, b = 2, c = 1 Output : Roots are complex -0.5 + i 2.0 -0.5 - i 2.0 Input :a = 1, b = 10, c = -24 Output : Roots are real and different 2.0 -12.09 # Python program to find roots of quadratic equation 2 Input :a = 1, b = 2, c = 1 Output : Roots are real and same -1.0 Input :a = 2, b = 2, c = 1 Output : Roots are complex -0.5 + i 2.0 -0.5 - i 2.0 Input :a = 1, b = 10, c = -24 Output : Roots are real and different 2.0 -12.096 # Python program to find roots of quadratic equation 4The roots are (-3.414213562373095+0j) (-0.5857864376269049+0j)4 # Python program to find roots of quadratic equation 6 If b*b < 4*a*c, then roots are complex (not real). For example roots of x2 + x + 1, roots are -0.5 + i1.73205 and -0.5 - i1.73205 If b*b == 4*a*c, then roots are real and both roots are same. For example, roots of x2 - 2x + 1 are 1 and 1 If b*b > 4*a*c, then roots are real and different. For example, roots of x2 - 7x - 12 are 3 and 40 If b*b < 4*a*c, then roots are complex (not real). For example roots of x2 + x + 1, roots are -0.5 + i1.73205 and -0.5 - i1.73205 If b*b == 4*a*c, then roots are real and both roots are same. For example, roots of x2 - 2x + 1 are 1 and 1 If b*b > 4*a*c, then roots are real and different. For example, roots of x2 - 7x - 12 are 3 and 401 |