Given the roots of a cubic equation A, B and C, the task is to form the Cubic equation from the given roots.
Note: The given roots are integral.
Input: A = 1, B = 2, C = 3
Output: x^3 – 6x^2 + 11x – 6 = 0
Since 1, 2, and 3 are roots of the cubic equations, Then equation is given by:
(x – 1)(x – 2)(x – 3) = 0
(x – 1)(x^2 – 5x + 6) = 0
x^3 – 5x^2 + 6x – x^2 + 5x – 6 = 0
x^3 – 6x^2 + 11x – 6 = 0.
Input: A = 5, B = 2, C = 3
Output: x^3 – 10x^2 + 31x – 30 = 0
Since 5, 2, and 3 are roots of the cubic equations, Then equation is given by:
(x – 5)(x – 2)(x – 3) = 0
(x – 5)(x^2 – 5x + 6) = 0
x^3 – 5x^2 + 6x – 5x^2 + 25x – 30 = 0
x^3 – 10x^2 + 31x – 30 = 0.
Approach: Let the root of the cubic equation (ax3 + bx2 + cx + d = 0) be A, B and C. Then the given cubic equation can be represents as:
ax3 + bx2 + cx + d = x3 – (A + B + C)x2 + (AB + BC +CA)x + A*B*C = 0.
Let X = (A + B + C)
Y = (AB + BC +CA)
Z = A*B*C
Therefore using the above relation find the value of X, Y, and Z and form the required cubic equation.
Below is the implementation of the above approach:
x^3 - 10x^2 + 31x - 30 = 0
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.
- Find the integral roots of a given Cubic equation
- Find the quadratic equation from the given roots
- Roots of the quadratic equation when a + b + c = 0 without using Shridharacharya formula
- Program to find the Roots of Quadratic equation
- Check if roots of a Quadratic Equation are reciprocal of each other or not
- Boundary Value Analysis : Nature of Roots of a Quadratic equation
- Absolute difference between sum and product of roots of a quartic equation
- Check if roots of a Quadratic Equation are numerically equal but opposite in sign or not
- Find cubic root of a number
- Cubic Bezier Curve Implementation in C
- Program to check if N is a Centered Cubic Number
- Roots of Unity
- Seeds (Or Seed Roots) of a number
- Find if two given Quadratic equations have common roots or not
- Bakhshali Approximation for computing square roots
- Find the number of primitive roots modulo prime
- Find the missing value from the given equation a + b = c
- Number of solutions for the equation x + y + z <= n
- Sum of minimum value of x and y satisfying the equation ax + by = c
- Check whether one root of the Quadratic Equation is twice of other or not
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.