#include<stdio.h> #include<stdlib.h> #include<math.h> double f(double x) { return sin(x); //return ((x-2)*(x+4)); } int main() { double a = 1; double b = 5; double epsilonX = 1e-6; double epsilonF = 1e-6; double fa = f(a); double x = (a + b) / 2; double fx = f(x); while ((b - a) / 2 > epsilonX && fabs(fx) > epsilonF) { if (fa * fx < 0) { b = x; } else { a = x; fa = fx; } x = (a + b) / 2; fx = f(x); } printf("Rozwiazanie: %f \n", x); return 0; }