In this section we will see how to get the absolute difference between the sum of the roots and the products of the root of a quartic equation?
The quartic equation is like 𝑎𝑥4+𝑏𝑥3+𝑐𝑥2+𝑑𝑥+𝑒
We can solve the equation and then try to get the product and sum of the roots by some normal process, but that takes much time and that approach is not so efficient. In this kind of equation, we have two formulae. The Sum of roots are always −𝑏∕𝑎 and the product of roots are always 𝑒∕𝑎 . So we have to find only the value of ∣−𝑏∕𝑎− 𝑒∕𝑎∣ ∣
Algorithm
rootSumProdDiff(a, b, c, d, e)
begin sum := -b/a prod := e/a return |sum - prod| end
Example
#include<iostream> #include<cmath> using namespace std; double rootSumProdDiff(double a, double b, double c, double d, double e){ double sum = double(-b/a); double prod = double(e/a); return abs(sum - prod); } main() { double a,b,c,d,e; cout << "Enter a, b, c, d, e for equation ax^4 + bx^3 + cx^2 + dx + e:"; cin >> a >> b >> c >> d >> e; cout << "Difference between sum and product of roots are: " << rootSumProdDiff(a, b, c, d, e); }
Output
Enter a, b, c, d, e for equation ax^4 + bx^3 + cx^2 + dx + e:8 4 6 4 1 Difference between sum and product of roots are: 0.625