I've had a few attempts at this question and have developed my answer further each time. If people wouldn't mind giving feedback or correcting my code that'd be great.
This is the question:
and the code I have written to answer this is, there is more to th question but this is just my code for the first bit:
function [y] =MPR_Asgn4_Q4a_26024405(f,a,b,n)h=(b-a)/n;x=zeros(1,n+1);x(1)=a;x(n+1)=b;s1=0;s2=0;s3=0;for k = 2:n x(k)=a+h*(1i-1);endfor k=1:n/2 s1= s1 + f(x(2*1i-1));endfor k=1:n/2 s2=s2+f(x(2*1i)); endfor k= 1:n/2 s3 = s3 +f(x(2*1i+1));end y = (h/3)*(s1+(4*s2)+s3);disp(y);end
Best Answer