text: function [c,err,yc]=regula(f,a,b,delta,epsilon,max1)\n\n%Input - f is the function input as a string 'f'\n%        - a and b are the left and right endpoints\n%        - delta is the tolerance for the zero\n%        - epsilon is the tolerance for the value of f at the zero\n%        - max1 is the maximum number of iterations\n%Output - c is the zero\n%         - yc=f(c)\n%         - err is the error estimate for c\n\nya=feval(f,a);\nyb=feval(f,b);\nif ya*yb>0\n    disp('Note: f(a)*f(b) >0'),\n    break,\nend\nfor k=1:max1\n    dx=yb*(b-a)/(yb-ya);\n    c=b-dx;\n    ac=c-a;\n    yc=feval(f,c);\n    if yc==0,break;\n    elseif yb*yc>0\n        b=c;\n        yb=yc;\n    else\n        a=c;\n        ya=yc;\n    end\n    dx=min(abs(dx),ac);\n    if abs(dx)<delta,break,end\n    if abs(yc)<epsilon, break,end\nend\n\nc;\nerr=abs(b-a)/2;\nyc=feval(f,c);