%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
%exercise 6.3a
clear all; 
clc;
f62b=inline('log(2+cos(16*x))');

 n = 100;
 %stegl�ngd f�r plot
 h=1.6/n;
 x=0:h:1.6;
 f=f62b(x);
 plot(x,f);
 
 H = [];
 n=1;
 h=1.6/n;
 H = [H h];
 x=0:h:1.6;
 f=f62b(x);
 %Trapezregel
 T=h*(sum(f)-0.5*(f(1)+f(n+1)));
 
  for steghalvering=1:4
     n=2*n;
     h=h/2;
     H = [H h];
     x=0:h:1.6;
     f=f62b(x);
     
     T=[T h*(sum(f)-0.5*(f(1)+f(n+1)))];
  end
 H
 T
