#include #include #define EPSILON 0.0000001 #define f(x) ((352 * x * x * x) - (64 * x * x) + (198 * x) - 36) #define f1(x) ((1056 * x * x) - (128 * x) + 198) double newtonRaphson(double x) { double h = f(x) / f1(x); if (f(x) == 0 || fabs(h) < EPSILON) return x; return newtonRaphson(x - h); } int main() { printf("Root for f(x) = 352x^3 - 64x^2 + 198x - 36 is %lf", newtonRaphson(-4)); }