#include using namespace std; #define EP 0.01 // Define EPSILON (min interval) here // An example function whose solution is found with // the numerical Bisection Method double func(double x) { return x*x*x - 2*x*x + 3; } // Prints root of func(x) with error in EPSILON void bisection(double a, double b) { if (func(a) * func(b) >= 0) { cout << "a and b should have opposite signs (incorrect [a,b] pair)"; cout << " " <= EP) { // Find mid-point m = (a+b)/2; // Check if mid-point is root if (func(m) == 0.0) break; // Decide the side to repeat the steps else if (func(m)*func(a) < 0) b = m; else a = m; n_iter++; } cout << "The value of root is : " << m << endl; cout << "Number of iterations is : " << n_iter << endl; cout << " " <