You are on page 1of 1

clc

clear all
syms x
F=input('ingrese el polinomio en orden ');
a=input('ingrese el limite inferior ');
b=input('ingrese el limite superior ');
n=input('ingrese el numero de segmentos a usar ');
%e1=input('ingrese el valor real');
h=(b-a)/2;
f=inline(F);
sum=subs(f,x,a);
for i=2:n
sumprim=subs(f,x,a+(i-1)*h);
sum=sum+2*sumprim;
end
sumsec=subs(f,x,b);
sum=sum+sumsec;
Valor=h*sum/2;
fprintf('El valor es: %4.8',Valor)
et1=str2double(char(int(sym(F),a,b)));
et=(et1-Valor)*100/et1;
Ea=-((b-a)^3)*(str2double(char(int(diff(sym(F),2),a,b)))/(b-a))/(12*n^2);
fprintf('\n %7s %14s %11s\t','Valor','%et','Ea')
fprintf('\n %4.8f %15.8f %8.2f\n',Valor,et,Ea)