ph-math/src/main/java/com/helger/numbercruncher/mathutils/TrapezoidalIntegrator.java
public float integrate (final float a, final float b, final int intervals)
  {
    if (b <= a)
      return 0;

    final float h = (b - a) / intervals; // interval width
    float totalArea = 0;

    // Compute the area using the current number of intervals.
    for (int i = 0; i < intervals; ++i)
    {
      final float x1 = a + i * h;
      totalArea += _areaOf (x1, h);
    }

    return totalArea;
  }
public float integrate (final float a, final float b, final int intervals)
  {
    if (b <= a)
      return 0;

    final float h = (b - a) / intervals; // interval width
    float totalArea = 0;

    // Compute the area using the current number of intervals.
    for (int i = 0; i < intervals; ++i)
    {
      final float x1 = a + i * h;
      totalArea += _areaOf (x1, h);
    }

    return totalArea;
  }
public float integrate ( final float a , final float b , final int intervals ) { if ( b <= a ) return 0 ; final float h = ( b - a ) / intervals ; // interval width float totalArea = 0 ; // Compute the area using the current number of intervals. for ( int i = 0 ; i < intervals ; ++ i ) { final float x1 = a + i * h ; totalArea += _areaOf ( x1 , h ) ; } return totalArea ; }
Integrate the function from a to b using the trapezoidal algorithm, and
return an approximation to the area. (Integrator implementation.)

@param a
the lower limit
@param b
the upper limit
@param intervals
the number of equal-width intervals
@return an approximation to the area
Integrate the function from a to b using the trapezoidal algorithm and return an approximation to the area . ( Integrator implementation . )