The Integrate function does numerical integration a user-supplied function. The following C# code snippet illustrates its use.

// If the integrand is a defined method, you can simply name the method.
// Here we integrate over the "hump" of the cosine function.
double I1 = FunctionMath.Integrate(
  Math.Cos,
  Interval.FromEndpoints(-Math.PI/2.0, Math.PI/2.0)
);

// You can also use anonymous delegate notation to define the integrand inline.
double I2 = FunctionMath.Integrate(
  x => Math.Sqrt(Math.Sin(x)),
  Interval.FromEndpoints(0.0, Math.PI)
);

// Integrals can have infinite endpoints.
double I3 = FunctionMath.Integrate(
  x => Math.Exp(-x * x / 2.0),
  Interval.FromEndpoints(Double.NegativeInfinity, Double.PositiveInfinity)
);

// Integrable endpoint singularities are also allowed. (Log goes to negative infinity at zero.)
double I4 = FunctionMath.Integrate(Math.Log, Interval.FromEndpoints(0.0, 1.0));

// By default, we target nearly full precision and allow many thousands of function evaluations to achieve it.
// If your accuracy requirements are lower, or you want to change the number of allowed function
// evaluations, you can do so using EvaluationSettings.
EvaluationSettings integrationSettings = new EvaluationSettings() {
  RelativePrecision = 1.0E-5,
  EvaluationBudget = 500
};
double I5 = FunctionMath.Integrate(
  AdvancedMath.LogGamma,
  Interval.FromEndpoints(0.0, 1.0),
  integrationSettings
);