clear // limpa todas variveis clc // limpa o console function [y]=f(x); y = -(%pi)*x^3+21*(%pi)*x^2-9; endfunction printf('A funo f(x)=-(pi)*x^3+21*(pi)*x^2-9') a=input('Entre com o valor de a: ') b=input('Entre com o valor de b: ') raiz=0 xi=a xf=a+1 while(xi<b) if (f(xi)*f(xf)>0) then xi=xf; xf=xf+1; else raiz=raiz+1; printf("Existe zero de funo no intervalo [%g,%g]\n",xi,xf); xi=xf; xf=xf+1 end end printf("Apresentou %g raz(es)",raiz);