#include using std::cout; using std::cin; using std::endl; #include using std::abs; #include "TrapeziodalIntegration.h" int main() { cout << "Calculation of an integral with the Trapezius method" << endl; double startX, endX ; cout << "Low value of the integration interval: "; cin >> startX ; cout<< "High value of the integration interval: "; cin >> endX ; cout << "Precision: "; double epsilon; cin >> epsilon; double area; int nIntMax = 10000; double oldArea = 9999999.; int nSubIntervals = 2; bool convergence = false; while (nSubIntervals < nIntMax) { area = TrapezoidalArea(startX, endX, nSubIntervals); if ( (abs(area - oldArea) < epsilon * abs(area)) && nSubIntervals > 16) { convergence = true; break; } else { oldArea = area; nSubIntervals *= 2; } } if (convergence) cout << "The integral is: " << area << "\n" ; else cout << "Resquired precison non reached: " << endl; return 0; }