lib/numbers/calculus.js
function SimpsonRecursive(func, a, b, whole, eps) {
  var c = a + b;
  var left = SimpsonDef(func, a, c);
  var right = SimpsonDef(func, c, b);

  if (Math.abs(left + right - whole) <= 15 * eps) {
    return left + right + (left + right - whole) / 15;
  } else {
    return SimpsonRecursive(func, a, c, eps / 2, left) + SimpsonRecursive(func, c, b, eps / 2, right);
  }
}
function SimpsonRecursive(func, a, b, whole, eps) {
  var c = a + b;
  var left = SimpsonDef(func, a, c);
  var right = SimpsonDef(func, c, b);

  if (Math.abs(left + right - whole) <= 15 * eps) {
    return left + right + (left + right - whole) / 15;
  } else {
    return SimpsonRecursive(func, a, c, eps / 2, left) + SimpsonRecursive(func, c, b, eps / 2, right);
  }
}
function SimpsonRecursive ( func , a , b , whole , eps ) { var c = a + b ; var left = SimpsonDef ( func , a , c ) ; var right = SimpsonDef ( func , c , b ) ; if ( Math . abs ( left + right - whole ) <= 15 * eps ) { return left + right + ( left + right - whole ) / 15 ; } else { return SimpsonRecursive ( func , a , c , eps / 2 , left ) + SimpsonRecursive ( func , c , b , eps / 2 , right ) ; } }
Helper function in calculating integral of a function
from a to b using simpson quadrature.  Manages recursive
investigation, handling evaluations within an error bound.

@param {Function} math function to be evaluated.
@param {Number} point to initiate evaluation.
@param {Number} point to complete evaluation.
@param {Number} total value.
@param {Number} Error bound (epsilon).
@return {Number} recursive evaluation of left and right side.
Helper function in calculating integral of a function from a to b using simpson quadrature . Manages recursive investigation handling evaluations within an error bound .