Given a quartic equation in the form , determine the absolute difference between the sum of its roots and the product of its roots. Note that roots need not be real – they can also be complex.
Input: 4x^4 + 3x^3 + 2x^2 + x - 1 Output: 0.5 Input: x^4 + 4x^3 + 6x^2 + 4x + 1 Output: 5
Approach: Solving the quartic equation to obtain each individual root would be time-consuming and inefficient, and would require much effort and computational power. A more efficient solution utilises the following formulae:
The quartic always has sum of roots , and product of roots .
Hence by computing we find the absolute difference between sum and product of roots.
Below is the implementation of above approach:
Explanation: The input equation is .
By finding , we get ,
which is , or .
- Roots of the quadratic equation when a + b + c = 0 without using Shridharacharya formula
- Program to find the Roots of Quadratic equation
- Absolute difference between the Product of Non-Prime numbers and Prime numbers of an Array
- Absolute difference between the first X and last X Digits of N
- Minimize the absolute difference of sum of two subsets
- Minimum absolute difference between N and any power of 2
- Maximum absolute difference in an array
- Minimum absolute difference between N and a power of 2
- Absolute Difference of even and odd indexed elements in an Array
- Count pairs in an array such that the absolute difference between them is ≥ K
- Largest subset where absolute difference of any two element is a power of 2
- Absolute Difference of all pairwise consecutive elements in an array
- Minimum absolute difference of a number and its closest prime
- Pair of prime numbers with a given sum and minimum absolute difference
- Print all n-digit numbers with absolute difference between sum of even and odd digits is 1
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.