%Program 1.1 Regula False Method %Computes approximate solution of f(x)=0 %Input: inline function f; a,b such that f(a)*f(b)<0, % and iterartion number n positive integer %Output: Bracketing interval [an,bn] and approximate solution cn. function [an,cn,bn] = RegFal1(f,a,b,n) if sign(f(a))*sign(f(b)) >= 0 error('f(a)f(b)<0 not satisfied!') %ceases execution end an=a; bn=b; fa=f(a); fb=f(b); c=b-fb*(b-a)/(fb-fa); k = 1; while k1 A(j,3)=A(j,2)/A(j-1,2); end end disp(' ') % a blank line disp(' n en e(n)/e(n-1) ') disp('-------------------------------------------------------') for k=1:20 disp(sprintf('%2.0f %7.15g %7.15g',k,A(k,2),A(k,3))) end n en e(n)/e(n-1) ------------------------------------------------------- 1 0.8 0 2 0.642335766423358 0.802919708029197 3 0.507240816253692 0.789681725304043 4 0.390790151862501 0.770423316382038 5 0.292974712875094 0.749698300939211 6 0.213949069947435 0.730264628806549 7 0.152685489795746 0.713653440200785 8 0.106941252641754 0.700402197909009 9 0.073828661942057 0.690366534132327 10 0.0504288271173981 0.683052161462389 11 0.0341840137058098 0.677866523173929 12 0.0230489505492406 0.674261096066763 13 0.0154840093511178 0.671788041630728 14 0.0103759488205704 0.670107372404895 15 0.0069412231515642 0.668972377523989 16 0.00463818878117337 0.668209144108579 17 0.00309690645233931 0.667697370342018 18 0.00206673559246874 0.667354866630728 19 0.00137877292652342 0.667125940806227 20 0.000919604398566524 0.666973060520784