//PROGRAMA QUE CALCULA UNA OPERACION POR EL METODO DE LA BISECCION

//Operacion ( Cx4+ Bx3+Cx2+Dx+E )

#include<stdio.h>
#include<conio.h>
#include<math.h>
void main()
{
clrscr();
printf("LA ECUACION ES Cx4+ Bx3+Cx2+Dx+E\n");
float xl,xu,xr,fxlr,fxr,fxl,A,B,C,D,E;
printf("DAME EL VALOR DE A:");scanf("%f",&A);
printf("DAME EL VALOR DE B:");scanf("%f",&B);
printf("DAME EL VALOR DE C:");scanf("%f",&C);
printf("DAME EL VALOR DE D:");scanf("%f",&D);
printf("DAME EL VALOR DE E:");scanf("%f",&E);
printf("DAME EL VALOR DE xl:");scanf("%f",&xl);
printf("DAME EL VALOR DE xu:");scanf("%f",&xu);
for (int i=1;i<=20;i++)
{
xr=(xl+xu)/2;
fxr=A*pow(xr,3)+B*pow(xr,2)+C*xr+D;
fxl=A*pow(xl,3)+B*pow(xl,2)+C*xl+D;
fxlr=fxr*fxl;
printf("i=%d,xl=%f,xu=%f,xr=%f,fxlr=%f\n",i,xl,xu,xr,fxlr);
if(fxlr>0)xl=xr;
if(fxlr<0)xu=xr;
if(fxlr==0)break;
}
printf("PULSE CUALQUIER TECLA PARA SALIR...");
getch();
}