clc
clear all
a = 1; b = 0; i = 1;
fa = sin(a) - 5*a + 2;
fb = sin(b) - 5*b + 2;
a, b, fa, fb
while( 1 )
c = ( ((a*fb)-(b*fa))/(fb-fa));
fc = sin(c) - 5*c + 2;
fcc = abs(fc);
if( fcc<=0.00005 )
fc, c, i
break;
elseif( fa*fc<0 )
b = c; fb = fc;
a, b, fa, fb
else
a = c; fa = fc;
a, b, fa, fb
end
i = i+1;
end
clear all
a = 1; b = 0; i = 1;
fa = sin(a) - 5*a + 2;
fb = sin(b) - 5*b + 2;
a, b, fa, fb
while( 1 )
c = ( ((a*fb)-(b*fa))/(fb-fa));
fc = sin(c) - 5*c + 2;
fcc = abs(fc);
if( fcc<=0.00005 )
fc, c, i
break;
elseif( fa*fc<0 )
b = c; fb = fc;
a, b, fa, fb
else
a = c; fa = fc;
a, b, fa, fb
end
i = i+1;
end
No comments:
Post a Comment