#include #include #include #define EPSILON 0.0000001 #define f(x) ((352 * x * x * x) - (64 * x * x) + (198 * x) - 36) double bisection(double a, double b) { double x; if (f(a) * f(b) > 0) { printf("The values of function at the respective initial guesses must have " "opposite signs"); exit(1); } x = (a + b) / 2; if (f(x) == 0 || fabs(b - a) < EPSILON) return x; if (f(x) > 0) return bisection(x, b); return bisection(a, x); } int main() { printf("Root for f(x) = 352x^3 - 64x^2 + 198x - 36 is %lf", bisection(1.6, -4)); }