clc; close; clear; x=1:0.01:2; wzor = 'x^2-2'; for i=1:length(x) y(i)=x(i)^2-2; end plot(x,y) grid z=fzero(wzor,3) dok = 0.0001; a = 1; b = 2; iter = 1; while(1) x = a + (b - a) /2; y = eval(wzor); if(abs(b - a) < dok) break; end if(y < 0) a = x; else b = x; end iter = iter +1; end x iter
Wyszukiwarka