Given the roots of a quadratic equation A and B, the task is to find the equation.
Note: The given roots are integral.
Input: A = 2, B = 3
Output: x^2 – (5x) + (6) = 0
x2 – 5x + 6 = 0
x2 -3x -2x + 6 = 0
x(x – 3) – 2(x – 3) = 0
(x – 3) (x – 2) = 0
x = 2, 3
Input: A = 5, B = 10
Output: x^2 – (15x) + (50) = 0
Approach: If the roots of a quadratic equation ax2 + bx + c = 0 are A and B then it known that
A + B = – b * a and A * B = c * a.
Now, ax2 + bx + c = 0 can be written as
x2 + (b / a)x + (c / a) = 0 (Since, a != 0)
x2 – (A + B)x + (A * B) = 0, [Since, A + B = -b * a and A * B = c * a]
i.e. x2 – (Sum of the roots)x + Product of the roots = 0
Below is the implementation of the above approach:
x^2 - (5x) + (6) = 0
GeeksforGeeks has prepared a complete interview preparation course with premium videos, theory, practice problems, TA support and many more features. Please refer Placement 100 for details
- Program to find the Roots of Quadratic equation
- Roots of the quadratic equation when a + b + c = 0 without using Shridharacharya formula
- Boundary Value Analysis : Nature of Roots of a Quadratic equation
- Check if roots of a Quadratic Equation are numerically equal but opposite in sign or not
- Find if two given Quadratic equations have common roots or not
- Program to find number of solutions in Quadratic Equation
- Form the Cubic equation from the given roots
- Absolute difference between sum and product of roots of a quartic equation
- Find the number of primitive roots modulo prime
- Find the missing value from the given equation a + b = c
- Find the number of solutions to the given equation
- Find count of numbers from 0 to n which satisfies the given equation for a value K
- Find number of solutions of a linear equation of n variables
- Roots of Unity
- Sum of first N terms of Quadratic Sequence 3 + 7 + 13 + ...
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.