Program for finding the Integral of a given function using Boole 's Rule | Function to return the value of f ( x ) for the given value of x ; Function to computes the integrand of y at the given intervals of x with step size h and the initial limit a and final limit b ; Number of intervals ; Computing the step size ; Substituing a = 0 , b = 4 and h = 1 ; Driver Code
function y ( x ) { return ( 1 / ( 1 + x ) ) ; } function BooleRule ( a , b ) { let n = 4 ; let h ; h = ( ( b - a ) / n ) ; let sum = 0 ; let bl = ( 7 * y ( a ) + 32 * y ( a + h ) + 12 * y ( a + 2 * h ) + 32 * y ( a + 3 * h ) + 7 * y ( a + 4 * h ) ) * 2 * h / 45 ; sum = sum + bl ; return sum ; } document . write ( " " + BooleRule ( 0 , 4 ) . toFixed ( 4 ) ) ;