>> f=@(x) x*x-4 f = function_handle with value: @(x)x*x-4 >> [x,history] = HW2bisect(f,0,3,1e-8); >> format short >> x x = 2.0000 >> format long >> x x = 1.999999998137355 >> history history = 0 3.000000000000000 1.500000000000000 3.000000000000000 1.500000000000000 2.250000000000000 1.875000000000000 2.250000000000000 1.875000000000000 2.062500000000000 1.968750000000000 2.062500000000000 1.968750000000000 2.015625000000000 1.992187500000000 2.015625000000000 1.992187500000000 2.003906250000000 1.998046875000000 2.003906250000000 1.998046875000000 2.000976562500000 1.999511718750000 2.000976562500000 1.999511718750000 2.000244140625000 1.999877929687500 2.000244140625000 1.999877929687500 2.000061035156250 1.999969482421875 2.000061035156250 1.999969482421875 2.000015258789062 1.999992370605469 2.000015258789062 1.999992370605469 2.000003814697266 1.999998092651367 2.000003814697266 1.999998092651367 2.000000953674316 1.999999523162842 2.000000953674316 1.999999523162842 2.000000238418579 1.999999880790710 2.000000238418579 1.999999880790710 2.000000059604645 1.999999970197678 2.000000059604645 1.999999970197678 2.000000014901161 1.999999992549419 2.000000014901161 1.999999992549419 2.000000003725290 >> history(1,2) ans = 3 >> a=history(:,1); >> b=history(:,2); >> m=(a+b)/2; >> plot(m,'r*') >> k=1:length(m); >> plot(k,m,'r*')