function x = rfmethod( f, a, b, eps ) n = 0; while 1 n = n + 1; c = ( a*f(b) - b*f(a) ) / ( f(b) - f(a) ); if f(a)*f(c) > 0 a = c; else b = c; end if abs(f(c)) < eps break end end fprintf('%d iterations\n', n); x = c;