Question

The roots (solutions) to the quadratic equation ax2 +bx+c = 0 is given by the well-known...

The roots (solutions) to the quadratic equation ax2 +bx+c = 0 is given by the well-known formula x = 2a −b ± √b −4ac 2

Write a python program that takes the three coefficients a, b, and c as input, computes and displays the solutions according to the aforementioned formula. Note the ± in the numerator means there are two answers. But this will not apply if a is zero, so that condition must be checked separately; design your program such that: 1. If a = 0 and b = 0 and c = 0, it prints “solution is indeterminate!”. 2. If a = 0 and b = 0 but c =/ 0 ,it prints “there is no solution”. 3. If a = 0 but b =/ 0 and c =/ 0 , it prints “equation is linear”, computes the solution as x = −c/b and display it. The above formula also fails to work (for real numbers) if the expression under the square root is negative. That expression b ac is called the discriminant of the 2 − 4 quadratic. Define that as a separate variable d and check its sign: 1. If d > 0 then there are two real roots given by the formula above. 2. If d = 0 then the roots are loaded and equal to −b/2a. 3. If d < 0 then there is no real solution (roots are complex numbers).

Consider the following inputs/outputs for your test cases. Input Output a b c 1 -1 -2 There are two real roots. x = 2 and -1 0 -1 -2 The equation is linear. x = -2 0 0 -2 There is no solution. 0 0 0 Solution is indeterminate! 2 4 2 Roots are loaded. x = -1 5 2 1 there is no real solution.

Homework Answers

Answer #1
Code (Intedentation is important So I am giving screenshot also)
a=int(input("Enter a: "))
b=int(input("Enter b: "))
c=int(input("Enter c: "))
if(a==0):
   if(b==0 and c==0):#1st condition
       print("Solution Indeterminate")
   elif(b==0 and c!=0):#2nd condition
       print("No Solution")
   elif(b!=0 and c!=0):# 3rd condition
       print("Equation is linear")
       x=(-c/b)
       print("x = ",x)#Printing root for linear
else:  
   d=((b*b)-(4*a*c)) # finding condition of roots
   if(d<0):#Complex roots
       print("No real solution")
   elif(d==0):#Equal roots
       print("Roots are loaded")
       x=(-b/(2*a))
       print("x = ",x)
   else:#Real roots
       print("Real Roots")
       x1=(-b+(d)**0.5)/(2*a)
       x2=   (-b-(d)**0.5)/(2*a)
       print("x1 = ",x1)#printing root1
       print("x2 = ",x2)#printing root2

Output:-

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Given r_1 and r_2 are the roots of the quadratic equation ax^2 + bx + c...
Given r_1 and r_2 are the roots of the quadratic equation ax^2 + bx + c = 0, express (b^2?4ac)/2a in terms of r_1 and r_2. Re-write the quadratic formula in terms of r_1 + r_2 and and r_1 ? r_2.
Write a C++ programming code for a non-zero, discuss the roots of the quadratic equation as...
Write a C++ programming code for a non-zero, discuss the roots of the quadratic equation as follows: a) D =0; the equation has a double solution.      x1 = x2 = -b/2a b) D>0; the question has two different solutions x1 and x2.      x1= (-b-sqrt(D))/2a      x2= (-b+sqrt(D))/2a c) if D<0; the equation has no real solution
Use the discriminant to determine whether the quadratic equation has two unequal real​ solutions, a repeated...
Use the discriminant to determine whether the quadratic equation has two unequal real​ solutions, a repeated real​ solution, or no real​ solution, without solving the equation. 5x^2−9x+6=0 Choose the sentence that describes the number of real solutions to the quadratic equation. A.There are two unequal real solutions.There are two unequal real solutions B.There is no real solution.There is no real solution. C.There is a repeated solution.
1). Consider the quadratic equation x^2+ 100 x + 1 = 0 (i) Compute approximate roots...
1). Consider the quadratic equation x^2+ 100 x + 1 = 0 (i) Compute approximate roots by solving x^2 -100 x = 0 (ii) Use the quadratic formula to compute the roots of equation (iii) Repeat the computation of the roots but use 3 digit precision.
1) Solve the given quadratic equation by using Completing the Square procedure and by Quadratic formula...
1) Solve the given quadratic equation by using Completing the Square procedure and by Quadratic formula ( you must do it both ways). Show all steps for each method and put your answer in simplest radical form possible. 4X2 + 4X = 5                                                                                                  2) Which part of the Quadratic Formula can help you to find the Nature of the roots for the Quadratic Equation. Explain how you can find the nature of the roots and provide one Example for...
Find all sixth roots of unity in two ways: (a) Factor x^6-1 = 0 over R...
Find all sixth roots of unity in two ways: (a) Factor x^6-1 = 0 over R into linear and quadratic factors and solve the equation. (b) Use the formula for nth roots of unity.
Kx^2+x+9K=0 i) Evaluate the discriminant for this quadratic equation ii) What does it mean when we...
Kx^2+x+9K=0 i) Evaluate the discriminant for this quadratic equation ii) What does it mean when we say the quadratic equation has one repeated solution? iii) How does the discriminant enable us to tell wether our quadratic equation has one repeated solution? iv) Show all necessary work to find the value(s) of K that will cause this equation to have one repeated solution. v) Replace K with the value(s) you found in part iv and write the quadratic equations that has/have...
*use quadratic formula to solve quadratic equation. output the solutions with clear explanations * see how...
*use quadratic formula to solve quadratic equation. output the solutions with clear explanations * see how the answers are close to zero when substitute them in the equation *Plot the function in the range of [-D,E] ( from -7 to 3 in the example given *Use of meaningful variable names *Use an array instead of six different variables *Use a for loop with the array *Depending on the sign of the discriminant ?2 − 4?? is less than zero, output...
So if we can find a number r satisfying r2=b2−4ac, then we can solve for z...
So if we can find a number r satisfying r2=b2−4ac, then we can solve for z in terms of a,b,c and r as z=−b2a±r2a. Hopefully you can recognize the usual quadratic formula here. If b2−4ac is a positive real number, we usually just replace r with b2−4ac−−−−−−−√. However if b2−4ac is a negative real number, or in fact a general complex number---which will happen if a,b and c are complex numbers---then there is no canonical b2−4ac−−−−−−−√, but we could still...
Solve the equation x^2-40x+1=0 using the quadratic formula. Use five-digit decimal arithmetic to find numerical values...
Solve the equation x^2-40x+1=0 using the quadratic formula. Use five-digit decimal arithmetic to find numerical values for the roots of the equation; for example, you will need (399)^(1/2)= 19.975. Identify any loss-of-significance error that you encounter. (b) Find both roots accurately by using only five-digit decimal arithmetic.
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT