I need help.
I want to calculate the integral of f, by Milne's method, using the average of f on each subdivision.
let N be a multiple of 4, and be a subdivsion of
and
I knew F it is a vector of size N
Is this code correct:
%% My code
Milne=0;for i = 1 : 4 : (N-4) Milne = Milne + 7*F(i)+32*F(i+1)+12*F(i+2)+32*F(i+3)+7*F(i+4); end;Milne=2/45*Milneerr=abs(M-(exp(b)-1))
For f (x) = exp (x) on [0, 3] and for N = 120, I found the error equal to 0.25. However, when I use the Milne method (code below) I find for N = 12 the error is very small of order .
M=0;for i =1 : 4 : (N-3) M = M + 7*f(a+(i-1)*h)+32*f(a+i*h) +12*f(a+(i+1)*h) +32*f(a+(i+2)*h) +7*f(a+(i+3)*h);end;M = 2*h/45*Merr=abs(M-(exp(b)-1))
Best Answer