 Adaptive quadrature follows the general scheme

An approximation formula_8 to the integral of formula_1 over the interval formula_10 is computed (line 2), as well as an error estimate formula_11 (line 3).If the estimated error is larger than the required tolerance formula_2(line 4), the interval is subdivided (line 5) and the quadrature is applied on both halves separately (line 6).Either the initial estimate or the sum of the recursively computed halves is returned (line 7).