Given a quadratic equation, the task is to find the possible solutions to it.
Input : enter the coef of x2 : 1 enter the coef of x : 2 enter the costant : 1 Output : the value for x is -1.0 Input : enter the coef of x2 : 2 enter the coef of x : 3 enter the costant : 2 Output : x1 = -3+5.656854249492381i/4 and x2 = -3-5.656854249492381i/4
Start. Prompt the values for a, b, c. Compute i = b**2-4*a*c If i get negative value g=square root(-i) Else h = sqrt(i) Compute e = -b+h/(2*a) Compute f = -b-h/(2*a) If condition e==f then Print e Else Print e and f If i is negative then Print -b+g/(2*a) and -b-g/(2*a) stop
Below is the Python implementation of the above mentioned task.
the values for x is -1.0
First, this program will get three inputs from the user. The values are the coefficient of , coefficient of and constant. Then it performs the formula
For complex the value of gets negative. Rooting negative values will throw a value error. In this case, turn the result of and then root it. Don’t forget to include at last.
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
- Finding nth term of any Polynomial Sequence
- Find number of solutions of a linear equation of n variables
- Number of integral solutions of the equation x1 + x2 +.... + xN = k
- Number of non-negative integral solutions of sum equation
- Number of integral solutions for equation x = b*(sumofdigits(x)^a)+c
- Program to find number of solutions in Quadratic Equation
- Number of solutions for the equation x + y + z <= n
- Find the number of solutions to the given equation
- Python | Implementation of Polynomial Regression
- Python | Numpy polynomial lagline() method
- Python | Numpy polynomial legline() method
- Python | Numpy polynomial legint() method
- How to add one polynomial to another using NumPy in Python?
- How to subtract one polynomial to another using NumPy in Python?
- How to divide a polynomial to another using NumPy in Python?
- How to multiply a polynomial to another using NumPy in Python?
- Polynomial Regression ( From Scratch using Python )
- Horner's Method for Polynomial Evaluation
- Complete the sequence generated by a polynomial
- Sgn value of a polynomial
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.