public double CalcIntegral(RectangleIntegralType type) { double result = 0; for (int i = 0; i < n; ++i) { result += GetValue(a + i * h, type); } return(result * h); }
double GetValue(double value, RectangleIntegralType type) { switch (type) { case RectangleIntegralType.Left: return(function(value)); case RectangleIntegralType.Right: return(function(value + h)); default: return(function(value + h / 2)); } }
public double GetErrorDiap(RectangleIntegralType type) { RectangleIntegral temp = new RectangleIntegral(this.function, a, b, n * 2); return(Math.Abs(temp.CalcIntegral(type) - this.CalcIntegral(type))); }