#include <stdio.h>

#include <stdlib.h>

#include<math.h>

// Let the Function is : x^3-4x-4.224

double function(double x)

{

return (x/5 - cos(x));

}

int main()

{

double a,b,c;

double xmin=0,xmax=0;

printf("Enter a number for Xmin: ", xmin);

scanf("%lf", &xmin);

printf("\nEnter a number for Xmax: ", xmax);

scanf("%lf", &xmax);

while(function(xmin)function(xmax)>0)

{

xmin--;

xmax++;

}

if(function(xmax)function(xmax-1)<=0)

{

a=xmax-1;

b=xmax+1;

}

else

{

a=xmin-1;

b=xmin+1;

}

while(fabs(a-b)>=0.0001)

{

c=(a+b)/2;

printf("[%f %f %f]\n",a,b,c);

if(function(c)==0)

break;

else if(function(a)function(c)<0)

b=c;

else

a=c;

}

printf("The root is %.9f\n",c);

return 0;

}