Write a Matlab script-file probl1.m to execute the requestedcommands (as much as possible) in the exercises below. Increase N anumber of times according to N = 4, 8, 16, 32, 64, 128, . . . (1)Determine for each N the (exact) error. (2) Determine for N ? 16also the convergence ratio q(h/2).
This script should be based on a function-file trap.m(trapezoidal integration) as follows:
function [totarea] = trap(N)
format long;
a = 0; b = 1/2; h = (b-a)/N;
x = a:h:b; totarea = 0;
for i = 1:N
xl = x(i);
xr = x(i+1);
fxl = myfunct(xl);
fxr = myfunct(xr);
locarea = (h/2)*(fxl+fxr);
totarea = totarea + locarea;
end
end
You can refer to the integral as myfunct(). The interval is[0,1/2].