as an example if we take x^3-8*x^2+17*x-10,i want to calculate this zero polynomial using dichotomy method but it does'nt give me the good result , can anyone help to solve this problem ?
clcclear allclose allsyms xf=input( 'donnez la fonction :' );a=input( 'donnez la borne minimal de l intervalle :' ); c=input( 'donnez la borne maximal de l intervalle : ' );b=(a+c)/2;v=[];n=[];p=0;for i=1:100 x(i)=(a(i)+b(i))/2;if abs(f(x(i)))==0 v=[v,x(i)];breakendif (f(a(i))*f(x(i))<0) a(i+1)=a(i); b(i+1)=x(i);else b(i+1)=b(i); a(i+1)=x(i);endendfor j=1:100 x(j)=(b(j)+c(j))/2;if abs(f(x(j)))==0 n=[n,x(j)];breakendif (f(b(j))*f(x(j))<0) b(j+1)=b(j); c(j+1)=x(j);else c(j+1)=c(j); b(j+1)=x(j);endendp=[v,n]
Best Answer