I'm trying to write a script for the composite form of Boole's rule:
∫ g(t) dt = (2h/45)*[7g((a)+(a+4h))+32g((a+h)+(a+3h))+12g(a+2h)]
I have this code (below) that computes Boole's rule. I don't think I'm using the composite of Boole's rule though and I'd like to. Can anyone suggest how I could change my code? Any help would be much appreciated.
function r = boole_test(f,a,b,n)h = (b - a) / (n * 4);r = 7 * f(a);x = a + h;for i = 1 : n-1 r = r + 32 * f(x); x = x + h; r = r + 12 * f(x); x = x + h; r = r + 32 * f(x); x = x + h; r = r + 14 * f(x); x = x + h;endr = r + 32 * f(x);x = x + h;r = r + 12 * f(x);x = x + h;r = r + 32 * f(x);r = r + 7 * f(b);r = r * h*2/45;
Best Answer