%Written by Jeannette Spuhler, 2012-10-11

%NUM 6.4

% Trapetsmetod
clear all; clc;
funk= inline('30./(1+x.^4+sqrt(1+x.^3))');
T_trapets = [];
slut = 1;
for i = 1:3
    n=i;
    h=slut/n; 
    xapp=0:h:slut; 
    fapp = feval(funk, xapp);
    T = h*(sum(fapp)-0.5*(fapp(1)+fapp(n+1)));
    T_trapets = [T_trapets T];
end
T_trapets
T_Richard = T_trapets(end)-(T_trapets(end)-T_trapets(end-1))/3


