%Lab 2
%Written by Jeannette Spuhler, 2011-09-08
% Modified 2011-11-03

%Adaptive trapezoidal rule
%Pohl page 185

%first without adaptive method
clear all; clc;
a=-10; 
b= 10;
n= 100;
h=(b-a)/100;
x= a:h:b;
f=peakfkt(x);
T = h*(sum(f)-0.5*(f(1)+f(n+1)));

%plotting
xpeak = -10:0.01:10;
fpeak = peakfkt(xpeak);
plot(xpeak,fpeak);
title('Lab2 -without adaptivity'); 
ylabel('0.51+25*exp(-81*(11*x+45).^2)');
xlabel('x');
for i=1:n
 line([x(i) x(i)] ,[0 f(i)]);
end


disp('Integral calculated without adaptivity: ');
disp(T);
