You are on page 1of 1

public class Ecuacion {

static final double CERO=1e-10;
static final double ERROR=0.001;
static final int MAXITER=200;
public static void main(String[] args) {
double aIni=50*Math.PI/180;
double aFin=60*Math.PI/180;
double raiz=puntoMedio(aIni, aFin);
System.out.println(raiz*180/Math.PI);
}
static double puntoMedio(double a, double b) {
double m, ym;
int iter=0;
do{
m=(a+b)/2;
ym=f(m);
if(Math.abs(ym)<CERO) break;
if(Math.abs((a-b)/m)<ERROR) break;
if((f(a)*ym)<0) b=m;
else a=m;
iter++;
}while(iter<MAXITER);
if(iter==MAXITER){
System.out.println("No se ha encontrado la raíz");
}
return m;
}
static double f(double x){
double y=1.0-Math.sin(x)*Math.log((1+Math.sin(x))/Math.cos(x));
return y;
}
}