% qtrap,  Integralberäkning, trapetsregeln
  clear, clf 
%      function f=fq(x);
%            f=sqrt(0.5+2*exp(-x).*sin(2*x.^2));
% ------------------------------------------------------------------
  t=0:0.02:2;  ft=fq(t);
  n=10, h=2/n;  x=h*(0:n);  f=fq(x);  
  subplot(2,2,1), plot(0,0,'+', t,ft,':', x,f,'o', x,f)
  title('Trapetsregeln, n=10')
  T10=h*(sum(f)-(f(1)+f(n+1))/2)       
  n=2*n, h=h/2;  x=h*(0:n); f=fq(x); 
  subplot(2,2,2), plot(0,0,'+', t,ft,':', x,f,'*', x,f)
  title('Trapetsregeln, n=20')
  T20=h*(sum(f)-(f(1)+f(n+1))/2)      


