title: More efficient Integration Loop
body: <pre><code>public double Integral(double[] x, double intPointOne, double intPointTwo)
  {
      double integral = 0;
      double i = intPointOne;
      do
      {
          integral += Function(x[i])*.001;
          i = i + .001;
      }
      while (i &lt;= intPointTwo);
      return integral;
  }
  </code></pre>
  
  <p>Here's a function I have to integrate a function from x1-x2 simply using a summation of parts.  How can I make this loop more efficient (using less loops), but more accurate? </p>
  
  <p><em>Where <code>Function</code> changes every iteration, but it should be irrelevant as it's order of magnitude (or boundary) should stay relatively the same...</em></p>