15
1.c
Normal file
15
1.c
Normal file
@@ -0,0 +1,15 @@
|
||||
#include <math.h>
|
||||
#include <stdio.h>
|
||||
#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));
|
||||
}
|
Reference in New Issue
Block a user