integrate method
Calculates the numerical value of the function definite integral between lowerBound and upperBound.
Implementation
@override
IntegralResults integrate() {
// The 'step' of the algorithm
final h = (upperBound - lowerBound) / intervals;
// The initial approximation of the result
var integralResult =
evaluateFunction(lowerBound) + evaluateFunction(upperBound);
// The list containing the various guesses of the algorithm
final guesses = List<double>.filled(intervals, 0);
// The actual algorithm
for (var i = 0; i < intervals; ++i) {
final x = lowerBound + i * h;
integralResult += 2 * evaluateFunction(x);
guesses[i] = integralResult;
}
return IntegralResults(
guesses: guesses,
result: integralResult * h / 2,
);
}