HestonEstimator.HestonCall.PerformIntegral C# (CSharp) Method

PerformIntegral() private method

Numerical integral in R+ assuming the integrand is exponential decaying.
private PerformIntegral ( double a, double b, TAEDelegateFunction1D f ) : double
a double The left bound.
b double The right bound.
f TAEDelegateFunction1D
return double
        double PerformIntegral(double a, double b,TAEDelegateFunction1D f)
        {
            double sum = 0;
            double dt = a/10;
            double x=a;
            double y0 = f(a);
            double s0 = 1.05;
            do
            {
                if (x + dt > b)//fix for the last step
                  dt = b - x;

                x += dt;
                double y1 = f(x);
                sum += 0.5 * (y0 + y1) * dt;
                y0 = y1;
                dt *= s0;
                //s0 *= 1.0005;
            } while (x < b);
            return sum;
        }