Closed aminiussi closed 3 years ago
Just an insignificant detail I'm sure but in the short version of the slides, slide 19/83:
double totalIntegral = 0; for (int64_t i = 0; i < numberOfIntervals; ++i) { const double x =lower+ (i/numberOfIntervals) * (upper-lower); const double thisIntervalsContribution =function(x); totalIntegral += thisIntervalsContribution; } totalIntegral *= dx;
assuming numberOfIntervals is of int type, isn't i/numberOfIntervals always 0 ?
numberOfIntervals
i/numberOfIntervals
You are correct, it should be const double x =lower+ ((double)i/numberOfIntervals) * (upper-lower);
const double x =lower+ ((double)i/numberOfIntervals) * (upper-lower);
Just an insignificant detail I'm sure but in the short version of the slides, slide 19/83:
assuming
numberOfIntervals
is of int type, isn'ti/numberOfIntervals
always 0 ?