Absolute difference between sum and product of roots of a quartic equation | Java implementation of above approach ; Function taking coefficient of each term of equation as input ; Finding sum of roots ; Finding product of roots ; Absolute difference ; Driver Code
public class GFG { static double sumProductDifference ( int a , int b , int c , int d , int e ) { double rootSum = ( double ) ( - 1 * b ) / a ; double rootProduct = ( double ) e / a ; return Math . abs ( rootSum - rootProduct ) ; } public static void main ( String args [ ] ) { System . out . println ( sumProductDifference ( 8 , 4 , 6 , 4 , 1 ) ) ; } }