// Prof. Elano Diniz
// AULA DE CÁLCULO NUMÉRICO USANDO O
SCILAB
// REGRA DOS TRAPÉZIOS REPETIDA
clear //
limpa todas variáveis
clc //
limpa o console
function [y]=f(x);
y=%e^x;
endfunction;
a=input("Entre com a: ")
b=input("Entre com b: ")
n=input("Entre com n: ")
h=(b-a)/n;
xi=a
soma=0;
x=0
printf('\nx%g=%g',x,a)
c=f(xi)
printf(' f(x%g)=%g',x,c)
xi=a+h;
for i=1:n-1;
x=x+1
printf('\nx%g=%g',x,xi)
c=f(xi)
printf(' f(x%g)=%g',x,c)
soma=soma+f(xi);
xi=xi+h;
end
printf('\nx%g=%g',n,b)
c=f(xi)
printf(' f(x%g)=%g',n,c)
I=(h/2)*(f(a)+f(b)+2*soma);
printf("\nO valor da Integral numérica é: %f",I);