function xr=muller(f,x0,x1,x2)
% Finding real roots by using Muller method
%
iter=0;
es1=0.001;
es=es1;
ea=1.1*es;
maxit = 100;
xr=x0;
while (iter<maxit) && (ea>es)
    fx0=f(x0);
    fx1=f(x1);
    fx2=f(x2);
    h0=x1-x0;
    h1=x2-x1;
    d0=(fx1-fx0)/h0;
    d1=(fx2-fx1)/h1;
    a=(d1-d0)/(h1+h0);
    b=a*h1+d1;
    c=fx2;
    determinant=b*b-4.0*a*c;
    if determinant<=0  determinant=0;
    else determinant=sqrt(determinant);end
    if abs(b+determinant)>  abs(b-determinant) den=b+determinant;
    else den=b-determinant;end
    dxr=-2*c/den;
    xr=x2+dxr;
    ea=abs((xr-x2)/xr)*100;
    iter=iter+1;
    x0=x1;
    x1=x2;
    x2=xr;
end 
if iter>=maxit  fprintf('Warning : Maximum number of iteration is exceeded result may not be valis');end
end
