#include #include #include double f(double x) { return x*x+x-1; } double fp(double x) { return 2*x+1; } int main() { double eps0,epsx,x0,x1,f0,f1; int i; eps0=1e-4; epsx=1e-4; printf("Podaj punkt startowy x0 ="); scanf("%lf", &x0); x1 = x0 -1; f0 = f(x0); i=64; while (i && (fabs(x1 - x0) > epsx) && (fabs(f0) >eps0)) { f1 = fp(x0); if(fabs(f1) < eps0) { printf("zly punkt startowy"); i=0; break; } x1 = x0; x0 = x0 - f0 / f1; f0 = f(x0); if(!(--i)) printf("przekroczono limit obiegow"); } if(i) printf("x0= %lf",x0); printf("\n-----------------------------------------------------"); return 0; }