function x3 = regula_falsi(f, x1, x2) % x = regula_falsi(f, x1, x2) where f is the function % whose root is sought and x1.... f1 = f(x1); f2 = f(x2); for i=1:10 % x1 and x2 bracket the root x3 = (f2*x1 - f1*x2) / (f2-f1); disp([x1 x2 x3 x2-x1]) f3 = f(x3); if (f1*f3 > 0) f1 = f3; x1 = x3; else f2 = f3; x2 = x3; end end