Hello guys and sorry for my bad English , i have the following homework i should composite Newtons polynomial interpolation 3d grade , Simpsons 3/8 method with matlab !
But i have some trouble, i have the following formula and i should make the algorithm in Matlab formula
which i create it but i don't know if its right or not any suggestion, please?
function x = three_eight_rule(fun,a,b,n);
h = (b-a) / n;
sum = feval(fun,a) + feval(fun,b);
sum1 = 0;
sum2 = 0;
for i = 2:3:n-1
x = a + i*h;
sum1 = sum1 + 3*(feval(fun,x) + feval(fun,x+h));
end
for i = 4:3:n-2
x = a + i*h;
sum2 = sum2 + 2*(feval(fun,x));
end
sum = sum + sum1 + sum2;
x = ((3*h)/8) * sum;