function y = f(x) y = (x^3) - 2;format longeps_abs = 1e-6;eps_step = 1e-6;a = 1.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; endend[a b]abs(f(a))abs(f(b))
MATLAB: Error: “Not enough input arguments. Error in f (line 2) y = (x.^3) – 2.” I also want to verify that this code is using the bisection method to estimate a zero until two successive estimates have a diff. less than 10-6.
bisectionbisection method
Best Answer