Question
Create a MATLAB program using the bisection method to solve for the needed cylinder to produce a cylinder with a volume of 1000 cubic meters using a height that is fixed at 2 meters
Explanation / Answer
>> format long >> eps_abs = 1e-5; >> eps_step = 1e-5; >> a = 0.0; >> b = 2.0; >> while (b - a >= eps_step || ( abs( f(a) ) >= eps_abs && abs( f(b) ) >= eps_abs ) ) c = (a + b)/2; if ( f(c) == 0 ) break; elseif ( f(a)*f(c) < 0 ) b = c; else a = c; end end >> [a b] ans = 1.259918212890625 1.259925842285156 >> abs(f(a)) ans = 0.0000135103601622 >> abs(f(b)) ans = 0.0000228224229404